@cloudbase/js-sdk 1.8.2-alpha.0 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/dist/index.esm.js +2 -2
- package/app/dist/index.js +4 -23
- package/app/package.json +1 -1
- package/dist/index.cjs.js +9 -28
- package/dist/index.esm.js +2 -2
- package/index.d.ts +101 -118
- package/miniprogram_dist/analytics.js +1 -1
- package/miniprogram_dist/app.js +1 -1
- package/miniprogram_dist/auth.js +1 -1
- package/miniprogram_dist/database.js +2 -8
- package/miniprogram_dist/functions.js +1 -1
- package/miniprogram_dist/index.js +2 -8
- package/miniprogram_dist/realtime.js +1 -1
- package/miniprogram_dist/storage.js +1 -1
- package/package.json +11 -39
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_database",[],t):"object"==typeof exports?exports.cloudbase_database=t():e.cloudbase_database=t()}("undefined"!=typeof window?window:this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(module,__webpack_exports__,__webpack_require__){"use strict";(function(global,Buffer){__webpack_require__.d(__webpack_exports__,"a",(function(){return bson_54}));var long__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(2),long__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(long__WEBPACK_IMPORTED_MODULE_0__),buffer__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1),buffer__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_1__),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}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 n=e[t],r=n[0],i=n[1];this._keys.push(r),this._values[r]={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 n=e._keys[t++];return{value:void 0!==n?[n,e._values[n].v]:void 0,done:void 0===n}}}},t.prototype.forEach=function(e,t){t=t||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];e.call(t,this._values[r].v,r,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 n=e._keys[t++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},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 n=e._keys[t++];return{value:void 0!==n?e._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(t.prototype,"size",{enumerable:!0,get:function(){return this._keys.length}}),e.exports=t}})),map_1=map.Map;long__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.toExtendedJSON=function(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}},long__WEBPACK_IMPORTED_MODULE_0___default.a.fromExtendedJSON=function(e,t){var n=long__WEBPACK_IMPORTED_MODULE_0___default.a.fromString(e.$numberLong);return t&&t.relaxed?n.toNumber():n},Object.defineProperty(long__WEBPACK_IMPORTED_MODULE_0___default.a.prototype,"_bsontype",{value:"Long"});var long_1=long__WEBPACK_IMPORTED_MODULE_0___default.a;function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}var Double=function(){function e(t){_classCallCheck(this,e),t instanceof Number&&(t=t.valueOf()),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.legacy||e.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-".concat(this.value.toFixed(1))}:(Number.isInteger(this.value)?(t=this.value.toFixed(1)).length>=13&&(t=this.value.toExponential(13).toUpperCase()):t=this.value.toString(),{$numberDouble:t});var t}}],[{key:"fromExtendedJSON",value:function(t,n){var r=parseFloat(t.$numberDouble);return n&&n.relaxed?r:new e(r)}}]),e}();Object.defineProperty(Double.prototype,"_bsontype",{value:"Double"});var double_1=Double;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$1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$1(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$1(e,t,n){return t&&_defineProperties$1(e.prototype,t),n&&_defineProperties$1(e,n),e}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!=typeof t?_assertThisInitialized(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 _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(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 _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Timestamp=function(e){function t(e,n){var r;return _classCallCheck$1(this,t),r=long_1.isLong(e)?_possibleConstructorReturn(this,_getPrototypeOf(t).call(this,e.low,e.high,!0)):_possibleConstructorReturn(this,_getPrototypeOf(t).call(this,e,n,!0)),_possibleConstructorReturn(r)}return _inherits(t,e),_createClass$1(t,[{key:"toJSON",value:function(){return{$timestamp:this.toString()}}},{key:"toExtendedJSON",value:function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}}}],[{key:"fromInt",value:function(e){return new t(long_1.fromInt(e,!0))}},{key:"fromNumber",value:function(e){return new t(long_1.fromNumber(e,!0))}},{key:"fromBits",value:function(e,n){return new t(e,n)}},{key:"fromString",value:function(e,n){return new t(long_1.fromString(e,n,!0))}},{key:"fromExtendedJSON",value:function(e){return new t(e.$timestamp.i,e.$timestamp.t)}}]),t}(long_1);Object.defineProperty(Timestamp.prototype,"_bsontype",{value:"Timestamp"}),Timestamp.MAX_VALUE=Timestamp.MAX_UNSIGNED_VALUE;var timestamp=Timestamp,require$$0={};function normalizedFunctionString(e){return e.toString().replace("function(","function (")}function insecureRandomBytes(e){for(var t=new Uint8Array(e),n=0;n<e;++n)t[n]=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 n=1;n<arguments.length;n++)t[n-1]=arguments[n];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),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]}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 n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e};var inherits$1=inherits;function _typeof$1(e){return(_typeof$1="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)}var formatRegExp=/%[sdj%]/g;function format(e){if(!isString(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(inspect(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,i=r.length,o=String(e).replace(formatRegExp,(function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),s=r[n];n<i;s=r[++n])isNull(s)||!isObject(s)?o+=" "+s:o+=" "+inspect(s);return o}function deprecate(e,t){if(isUndefined(global.process))return function(){return deprecate(e,t).apply(this,arguments)};var n=!1;return function(){return n||(console.error(t),n=!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 n={seen:[],stylize:stylizeNoColor};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),isBoolean(t)?n.showHidden=t:t&&_extend(n,t),isUndefined(n.showHidden)&&(n.showHidden=!1),isUndefined(n.depth)&&(n.depth=2),isUndefined(n.colors)&&(n.colors=!1),isUndefined(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=stylizeWithColor),formatValue(n,e,n.depth)}function stylizeWithColor(e,t){var n=inspect.styles[t];return n?"["+inspect.colors[n][0]+"m"+e+"["+inspect.colors[n][1]+"m":e}function stylizeNoColor(e,t){return e}function arrayToHash(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}function formatValue(e,t,n){if(e.customInspect&&t&&isFunction(t.inspect)&&t.inspect!==inspect&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(n,e);return isString(r)||(r=formatValue(e,r,n)),r}var i=formatPrimitive(e,t);if(i)return i;var o=Object.keys(t),s=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 u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","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="",c=!1,l=["{","}"];(isArray(t)&&(c=!0,l=["[","]"]),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||c&&0!=t.length?n<0?isRegExp(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),a=c?formatArray(e,t,n,s,o):o.map((function(r){return formatProperty(e,t,n,s,r,c)})),e.seen.pop(),reduceToSingleString(a,f,l)):l[0]+f+l[1]}function formatPrimitive(e,t){if(isUndefined(t))return e.stylize("undefined","undefined");if(isString(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"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,n,r,i){for(var o=[],s=0,u=t.length;s<u;++s)hasOwnProperty(t,String(s))?o.push(formatProperty(e,t,n,r,String(s),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(formatProperty(e,t,n,r,i,!0))})),o}function formatProperty(e,t,n,r,i,o){var s,u,a;if((a=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?u=a.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):a.set&&(u=e.stylize("[Setter]","special")),hasOwnProperty(r,i)||(s="["+i+"]"),u||(e.seen.indexOf(a.value)<0?(u=isNull(n)?formatValue(e,a.value,null):formatValue(e,a.value,n-1)).indexOf("\n")>-1&&(u=o?u.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+u.split("\n").map((function(e){return" "+e})).join("\n")):u=e.stylize("[Circular]","special")),isUndefined(s)){if(o&&i.match(/^\d+$/))return u;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+u}function reduceToSingleString(e,t,n){return e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[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$1(e)}function isUndefined(e){return void 0===e}function isRegExp(e){return isObject(e)&&"[object RegExp]"===objectToString(e)}function isObject(e){return"object"===_typeof$1(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$1(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 n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];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};function _classCallCheck$2(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$2(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$2(e,t,n){return t&&_defineProperties$2(e.prototype,t),n&&_defineProperties$2(e,n),e}var Buffer$1=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,randomBytes$1=utils.randomBytes,deprecate$1=util.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 n=e[t];return new TypeError('ObjectId string "'.concat(e,'" contains invalid character "').concat(n,'" 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$2(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 n=e.isValid(t);if(!n&&null!=t)throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");if(n&&"string"==typeof t&&24===t.length&&hasBufferType)return new e(Buffer$1.from(t,"hex"));if(n&&"string"==typeof t&&24===t.length)return e.createFromHexString(t);if(null==t||12!==t.length){if(null!=t&&"function"==typeof t.toHexString)return e.createFromHexString(t.toHexString());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$2(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 n=0;n<this.id.length;n++){var r=hexTable[this.id.charCodeAt(n)];if("string"!=typeof r)throw makeObjectIdError(this.id,n);t+=r}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.readUInt32BE(0);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 n=e.getInc(),r=Buffer$1.alloc(12);return r[3]=255&t,r[2]=t>>8&255,r[1]=t>>16&255,r[0]=t>>24&255,r[4]=PROCESS_UNIQUE[0],r[5]=PROCESS_UNIQUE[1],r[6]=PROCESS_UNIQUE[2],r[7]=PROCESS_UNIQUE[3],r[8]=PROCESS_UNIQUE[4],r[11]=255&n,r[10]=n>>8&255,r[9]=n>>16&255,r}},{key:"createPk",value:function(){return new e}},{key:"createFromTime",value:function(t){var n=Buffer$1.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n[3]=255&t,n[2]=t>>8&255,n[1]=t>>16&255,n[0]=t>>24&255,new e(n)}},{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 n=new _Buffer(12),r=0,i=0;i<24;)n[r++]=decodeLookup[t.charCodeAt(i++)]<<4|decodeLookup[t.charCodeAt(i++)];return new e(n)}},{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||"function"==typeof t.toHexString&&(t.id instanceof _Buffer||"string"==typeof t.id)&&(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[util.inspect.custom||"inspect"]=ObjectId.prototype.toString,ObjectId.index=~~(16777215*Math.random()),Object.defineProperty(ObjectId.prototype,"_bsontype",{value:"ObjectID"});var objectid=ObjectId;function _classCallCheck$3(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$3(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$3(e,t,n){return t&&_defineProperties$3(e.prototype,t),n&&_defineProperties$3(e,n),e}function alphabetize(e){return e.split("").sort().join("")}var BSONRegExp=function(){function e(t,n){_classCallCheck$3(this,e),this.pattern=t||"",this.options=n?alphabetize(n):"";for(var r=0;r<this.options.length;r++)if("i"!==this.options[r]&&"m"!==this.options[r]&&"x"!==this.options[r]&&"l"!==this.options[r]&&"s"!==this.options[r]&&"u"!==this.options[r])throw new Error("The regular expression option [".concat(this.options[r],"] is not supported"))}return _createClass$3(e,[{key:"toExtendedJSON",value:function(e){return(e=e||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}}],[{key:"parseOptions",value:function(e){return e?e.split("").sort().join(""):""}},{key:"fromExtendedJSON",value:function(t){return t.$regex?"BSONRegExp"===t.$regex._bsontype?t:new e(t.$regex,e.parseOptions(t.$options)):new e(t.$regularExpression.pattern,e.parseOptions(t.$regularExpression.options))}}]),e}();Object.defineProperty(BSONRegExp.prototype,"_bsontype",{value:"BSONRegExp"});var regexp=BSONRegExp;function _classCallCheck$4(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$4(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$4(e,t,n){return t&&_defineProperties$4(e.prototype,t),n&&_defineProperties$4(e,n),e}var BSONSymbol=function(){function e(t){_classCallCheck$4(this,e),this.value=t}return _createClass$4(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;function _classCallCheck$5(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$5(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$5(e,t,n){return t&&_defineProperties$5(e.prototype,t),n&&_defineProperties$5(e,n),e}var Int32=function(){function e(t){_classCallCheck$5(this,e),t instanceof Number&&(t=t.valueOf()),this.value=+t}return _createClass$5(e,[{key:"valueOf",value:function(){return this.value}},{key:"toJSON",value:function(){return this.value}},{key:"toExtendedJSON",value:function(e){return e&&(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}}}],[{key:"fromExtendedJSON",value:function(t,n){return n&&n.relaxed?parseInt(t.$numberInt,10):new e(t.$numberInt)}}]),e}();Object.defineProperty(Int32.prototype,"_bsontype",{value:"Int32"});var int_32=Int32;function _classCallCheck$6(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$6(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$6(e,t,n){return t&&_defineProperties$6(e.prototype,t),n&&_defineProperties$6(e,n),e}var Code=function(){function e(t,n){_classCallCheck$6(this,e),this.code=t,this.scope=n}return _createClass$6(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,Buffer$2=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,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),n=long_1.fromNumber(0);if(!(e.parts[0]||e.parts[1]||e.parts[2]||e.parts[3]))return{quotient:e,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new long_1(e.parts[r],0)),e.parts[r]=n.div(t).low,n=n.modulo(t);return{quotient:e,rem:n}}function multiply64x2(e,t){if(!e&&!t)return{high:long_1.fromNumber(0),low:long_1.fromNumber(0)};var n=e.shiftRightUnsigned(32),r=new long_1(e.getLowBits(),0),i=t.shiftRightUnsigned(32),o=new long_1(t.getLowBits(),0),s=n.multiply(i),u=n.multiply(o),a=r.multiply(i),f=r.multiply(o);return s=s.add(u.shiftRightUnsigned(32)),u=new long_1(u.getLowBits(),0).add(a).add(f.shiftRightUnsigned(32)),{high:s=s.add(u.shiftRightUnsigned(32)),low:f=u.shiftLeft(32).add(new long_1(f.getLowBits(),0))}}function lessThan(e,t){var n=e.high>>>0,r=t.high>>>0;return n<r||n===r&&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,n=!1,r=!1,i=!1,o=0,s=0,u=0,a=0,f=0,c=[0],l=0,h=0,p=0,d=0,y=0,_=0,g=[0,0],b=[0,0],m=0;if(e.length>=7e3)throw new TypeError(e+" not a valid Decimal128 string");var w=e.match(PARSE_STRING_REGEXP),v=e.match(PARSE_INF_REGEXP),E=e.match(PARSE_NAN_REGEXP);if(!w&&!v&&!E||0===e.length)throw new TypeError(e+" not a valid Decimal128 string");if(w){var N=w[2],O=w[4],S=w[5],A=w[6];O&&void 0===A&&invalidErr(e,"missing exponent power"),O&&void 0===N&&invalidErr(e,"missing exponent base"),void 0===O&&(S||A)&&invalidErr(e,"missing e before exponent")}if("+"!==e[m]&&"-"!==e[m]||(n="-"===e[m++]),!isDigit(e[m])&&"."!==e[m]){if("i"===e[m]||"I"===e[m])return new Decimal128(Buffer$2.from(n?INF_NEGATIVE_BUFFER:INF_POSITIVE_BUFFER));if("N"===e[m])return new Decimal128(Buffer$2.from(NAN_BUFFER))}for(;isDigit(e[m])||"."===e[m];)"."!==e[m]?(l<34&&("0"!==e[m]||i)&&(i||(f=s),i=!0,c[h++]=parseInt(e[m],10),l+=1),i&&(u+=1),r&&(a+=1),s+=1,m+=1):(r&&invalidErr(e,"contains multiple periods"),r=!0,m+=1);if(r&&!s)throw new TypeError(e+" not a valid Decimal128 string");if("e"===e[m]||"E"===e[m]){var T=e.substr(++m).match(EXPONENT_REGEX);if(!T||!T[2])return new Decimal128(Buffer$2.from(NAN_BUFFER));y=parseInt(T[0],10),m+=T[0].length}if(e[m])return new Decimal128(Buffer$2.from(NAN_BUFFER));if(p=0,l){if(d=l-1,1!==(o=u))for(;"0"===e[f+o-1];)o-=1}else p=0,d=0,c[0]=0,u=1,l=1,o=0;for(y<=a&&a-y>16384?y=EXPONENT_MIN:y-=a;y>EXPONENT_MAX;){if((d+=1)-p>MAX_DIGITS){if(c.join("").match(/^0+$/)){y=EXPONENT_MAX;break}invalidErr(e,"overflow")}y-=1}for(;y<EXPONENT_MIN||l<u;){if(0===d&&o<l){y=EXPONENT_MIN,o=0;break}if(l<u?u-=1:d-=1,y<EXPONENT_MAX)y+=1;else{if(c.join("").match(/^0+$/)){y=EXPONENT_MAX;break}invalidErr(e,"overflow")}}if(d-p+1<o){var B=s;r&&(f+=1,B+=1),n&&(f+=1,B+=1);var I=parseInt(e[f+d+1],10),D=0;if(I>=5&&(D=1,5===I))for(D=c[d]%2==1,_=f+d+2;_<B;_++)if(parseInt(e[_],10)){D=1;break}if(D)for(var P=d;P>=0;P--)if(++c[P]>9&&(c[P]=0,0===P)){if(!(y<EXPONENT_MAX))return new Decimal128(Buffer$2.from(n?INF_NEGATIVE_BUFFER:INF_POSITIVE_BUFFER));y+=1,c[P]=1}}if(g=long_1.fromNumber(0),b=long_1.fromNumber(0),0===o)g=long_1.fromNumber(0),b=long_1.fromNumber(0);else if(d-p<17){var $=p;for(b=long_1.fromNumber(c[$++]),g=new long_1(0,0);$<=d;$++)b=(b=b.multiply(long_1.fromNumber(10))).add(long_1.fromNumber(c[$]))}else{var R=p;for(g=long_1.fromNumber(c[R++]);R<=d-17;R++)g=(g=g.multiply(long_1.fromNumber(10))).add(long_1.fromNumber(c[R]));for(b=long_1.fromNumber(c[R++]);R<=d;R++)b=(b=b.multiply(long_1.fromNumber(10))).add(long_1.fromNumber(c[R]))}var x=multiply64x2(g,long_1.fromString("100000000000000000"));x.low=x.low.add(b),lessThan(x.low,b)&&(x.high=x.high.add(long_1.fromNumber(1))),t=y+EXPONENT_BIAS;var M={low:long_1.fromNumber(0),high:long_1.fromNumber(0)};x.high.shiftRightUnsigned(49).and(long_1.fromNumber(1)).equals(long_1.fromNumber(1))?(M.high=M.high.or(long_1.fromNumber(3).shiftLeft(61)),M.high=M.high.or(long_1.fromNumber(t).and(long_1.fromNumber(16383).shiftLeft(47))),M.high=M.high.or(x.high.and(long_1.fromNumber(0x7fffffffffff)))):(M.high=M.high.or(long_1.fromNumber(16383&t).shiftLeft(49)),M.high=M.high.or(x.high.and(long_1.fromNumber(562949953421311)))),M.low=x.low,n&&(M.high=M.high.or(long_1.fromString("9223372036854775808")));var C=Buffer$2.alloc(16);return m=0,C[m++]=255&M.low.low,C[m++]=M.low.low>>8&255,C[m++]=M.low.low>>16&255,C[m++]=M.low.low>>24&255,C[m++]=255&M.low.high,C[m++]=M.low.high>>8&255,C[m++]=M.low.high>>16&255,C[m++]=M.low.high>>24&255,C[m++]=255&M.high.low,C[m++]=M.high.low>>8&255,C[m++]=M.high.low>>16&255,C[m++]=M.high.low>>24&255,C[m++]=255&M.high.high,C[m++]=M.high.high>>8&255,C[m++]=M.high.high>>16&255,C[m++]=M.high.high>>24&255,new Decimal128(C)};var COMBINATION_MASK=31,EXPONENT_MASK=16383,COMBINATION_INFINITY=30,COMBINATION_NAN=31;Decimal128.prototype.toString=function(){for(var e,t,n,r,i,o,s=0,u=new Array(36),a=0;a<u.length;a++)u[a]=0;var f,c,l,h,p,d=0,y=!1,_={parts:new Array(4)},g=[];d=0;var b=this.bytes;if(r=b[d++]|b[d++]<<8|b[d++]<<16|b[d++]<<24,n=b[d++]|b[d++]<<8|b[d++]<<16|b[d++]<<24,t=b[d++]|b[d++]<<8|b[d++]<<16|b[d++]<<24,e=b[d++]|b[d++]<<8|b[d++]<<16|b[d++]<<24,d=0,{low:new long_1(r,n),high:new long_1(t,e)}.high.lessThan(long_1.ZERO)&&g.push("-"),(i=e>>26&COMBINATION_MASK)>>3==3){if(i===COMBINATION_INFINITY)return g.join("")+"Infinity";if(i===COMBINATION_NAN)return"NaN";o=e>>15&EXPONENT_MASK,l=8+(e>>14&1)}else l=e>>14&7,o=e>>17&EXPONENT_MASK;if(f=o-EXPONENT_BIAS,_.parts[0]=(16383&e)+((15&l)<<14),_.parts[1]=t,_.parts[2]=n,_.parts[3]=r,0===_.parts[0]&&0===_.parts[1]&&0===_.parts[2]&&0===_.parts[3])y=!0;else for(p=3;p>=0;p--){var m=0,w=divideu128(_);if(_=w.quotient,m=w.rem.low)for(h=8;h>=0;h--)u[9*p+h]=m%10,m=Math.floor(m/10)}if(y)s=1,u[d]=0;else for(s=36;!u[d];)s-=1,d+=1;if((c=s-1+f)>=34||c<=-7||f>0){if(s>34)return g.push(0),f>0?g.push("E+"+f):f<0&&g.push("E"+f),g.join("");g.push(u[d++]),(s-=1)&&g.push(".");for(var v=0;v<s;v++)g.push(u[d++]);g.push("E"),c>0?g.push("+"+c):g.push(c)}else if(f>=0)for(var E=0;E<s;E++)g.push(u[d++]);else{var N=s+f;if(N>0)for(var O=0;O<N;O++)g.push(u[d++]);else g.push("0");for(g.push(".");N++<0;)g.push("0");for(var S=0;S<s-Math.max(N-1,0);S++)g.push(u[d++])}return g.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;function _classCallCheck$7(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$7(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$7(e,t,n){return t&&_defineProperties$7(e.prototype,t),n&&_defineProperties$7(e,n),e}var MinKey=function(){function e(){_classCallCheck$7(this,e)}return _createClass$7(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;function _classCallCheck$8(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$8(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$8(e,t,n){return t&&_defineProperties$8(e.prototype,t),n&&_defineProperties$8(e,n),e}var MaxKey=function(){function e(){_classCallCheck$8(this,e)}return _createClass$8(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;function _classCallCheck$9(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$9(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$9(e,t,n){return t&&_defineProperties$9(e.prototype,t),n&&_defineProperties$9(e,n),e}var DBRef=function(){function e(t,n,r,i){_classCallCheck$9(this,e);var o=t.split(".");2===o.length&&(r=o.shift(),t=o.shift()),this.collection=t,this.oid=n,this.db=r,this.fields=i||{}}return _createClass$9(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(e){e=e||{};var t={$ref:this.collection,$id:this.oid};return e.legacy?t:(this.db&&(t.$db=this.db),t=Object.assign(t,this.fields))}}],[{key:"fromExtendedJSON",value:function(t){var n=Object.assign({},t);return["$ref","$id","$db"].forEach((function(e){return delete n[e]})),new e(t.$ref,t.$id,t.$db,n)}}]),e}();Object.defineProperty(DBRef.prototype,"_bsontype",{value:"DBRef"}),Object.defineProperty(DBRef.prototype,"namespace",{get:function(){return this.collection},set:function(e){this.collection=e},configurable:!1});var db_ref=DBRef;function _classCallCheck$a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$a(e,t,n){return t&&_defineProperties$a(e.prototype,t),n&&_defineProperties$a(e,n),e}var Buffer$3=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,Binary=function(){function e(t,n){if(_classCallCheck$a(this,e),!(null==t||"string"==typeof t||Buffer$3.isBuffer(t)||t instanceof Uint8Array||Array.isArray(t)))throw new TypeError("only String, Buffer, Uint8Array or Array accepted");if(this.sub_type=null==n?BSON_BINARY_SUBTYPE_DEFAULT:n,this.position=0,null==t||t instanceof Number)void 0!==Buffer$3?this.buffer=Buffer$3.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$3)this.buffer=Buffer$3.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$a(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 n=null;if(n="string"==typeof t?t.charCodeAt(0):null!=t.length?t[0]:t,this.buffer.length>this.position)this.buffer[this.position++]=n;else if(void 0!==Buffer$3&&Buffer$3.isBuffer(this.buffer)){var r=Buffer$3.alloc(e.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=n}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++]=n}}},{key:"write",value:function(e,t){if(t="number"==typeof t?t:this.position,this.buffer.length<t+e.length){var n=null;if(void 0!==Buffer$3&&Buffer$3.isBuffer(this.buffer))n=Buffer$3.alloc(this.buffer.length+e.length),this.buffer.copy(n,0,0,this.buffer.length);else if(isUint8Array(this.buffer)){n=new Uint8Array(new ArrayBuffer(this.buffer.length+e.length));for(var r=0;r<this.position;r++)n[r]=this.buffer[r]}this.buffer=n}if(void 0!==Buffer$3&&Buffer$3.isBuffer(e)&&Buffer$3.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$3&&"string"==typeof e&&Buffer$3.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 n="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(t)):new Array(t),r=0;r<t;r++)n[r]=this.buffer[e++];return n}},{key:"value",value:function(e){if((e=null!=e&&e)&&void 0!==Buffer$3&&Buffer$3.isBuffer(this.buffer)&&this.buffer.length===this.position)return this.buffer;if(void 0!==Buffer$3&&Buffer$3.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),n=0;n<this.position;n++)t[n]=this.buffer[n];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(e){e=e||{};var t=Buffer$3.isBuffer(this.buffer)?this.buffer.toString("base64"):Buffer$3.from(this.buffer).toString("base64"),n=Number(this.sub_type).toString(16);return e.legacy?{$binary:t,$type:1===n.length?"0"+n:n}:{$binary:{base64:t,subType:1===n.length?"0"+n:n}}}}],[{key:"fromExtendedJSON",value:function(t,n){var r,i;return(n=n||{}).legacy?(i=t.$type?parseInt(t.$type,16):0,r=Buffer$3.from(t.$binary,"base64")):(i=t.$binary.subType?parseInt(t.$binary.subType,16):0,r=Buffer$3.from(t.$binary.base64,"base64")),new e(r,i)}}]),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),n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function convertArraytoUtf8BinaryString(e,t,n){for(var r="",i=t;i<n;i++)r+=String.fromCharCode(e[i]);return r}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};function _typeof$2(e){return(_typeof$2="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)}var keysToCodecs={$oid:objectid,$binary:binary,$symbol:symbol,$numberInt:int_32,$numberDecimal:decimal128,$numberDouble:double_1,$numberLong:long_1,$minKey:min_key,$maxKey:max_key,$regex:regexp,$regularExpression:regexp,$timestamp:timestamp};function deserializeValue(e,t,n,r){if("number"==typeof n){if(r.relaxed||r.legacy)return n;if(Math.floor(n)===n){if(n>=BSON_INT32_MIN&&n<=BSON_INT32_MAX)return new int_32(n);if(n>=BSON_INT64_MIN&&n<=BSON_INT64_MAX)return new long_1.fromNumber(n)}return new double_1(n)}if(null==n||"object"!==_typeof$2(n))return n;if(n.$undefined)return null;for(var i=Object.keys(n).filter((function(e){return e.startsWith("$")&&null!=n[e]})),o=0;o<i.length;o++){var s=keysToCodecs[i[o]];if(s)return s.fromExtendedJSON(n,r)}if(null!=n.$date){var u=n.$date,a=new Date;return r.legacy?"number"==typeof u?a.setTime(u):"string"==typeof u&&a.setTime(Date.parse(u)):"string"==typeof u?a.setTime(Date.parse(u)):long_1.isLong(u)?a.setTime(u.toNumber()):"number"==typeof u&&r.relaxed&&a.setTime(u),a}if(null!=n.$code){var f=Object.assign({},n);return n.$scope&&(f.$scope=deserializeValue(e,null,n.$scope)),code.fromExtendedJSON(n)}if(null!=n.$ref||null!=n.$dbPointer){var c=n.$ref?n:n.$dbPointer;if(c instanceof db_ref)return c;var l=Object.keys(c).filter((function(e){return e.startsWith("$")})),h=!0;if(l.forEach((function(e){-1===["$ref","$id","$db"].indexOf(e)&&(h=!1)})),h)return db_ref.fromExtendedJSON(c)}return n}function parse(e,t){var n=this;return"boolean"==typeof(t=Object.assign({},{relaxed:!0,legacy:!1},t)).relaxed&&(t.strict=!t.relaxed),"boolean"==typeof t.strict&&(t.relaxed=!t.strict),JSON.parse(e,(function(e,r){return deserializeValue(n,e,r,t)}))}var BSON_INT32_MAX=2147483647,BSON_INT32_MIN=-2147483648,BSON_INT64_MAX=0x8000000000000000,BSON_INT64_MIN=-0x8000000000000000;function stringify(e,t,n,r){null!=n&&"object"===_typeof$2(n)&&(r=n,n=0),null==t||"object"!==_typeof$2(t)||Array.isArray(t)||(r=t,t=null,n=0);var i=serializeValue(e,r=Object.assign({},{relaxed:!0,legacy:!1},r));return JSON.stringify(i,t,n)}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 n=e.getTime(),r=n>-1&&n<2534023188e5;return t.legacy?t.relaxed&&r?{$date:e.getTime()}:{$date:getISOString(e)}:t.relaxed&&r?{$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()}}if(e instanceof RegExp){var o=e.flags;return void 0===o&&(o=e.toString().match(/[gimuy]*$/)[0]),new regexp(e.source,o).toExtendedJSON(t)}return null!=e&&"object"===_typeof$2(e)?serializeDocument(e,t):e}var BSON_TYPE_MAPPINGS={Binary:function(e){return new binary(e.value(),e.subtype)},Code:function(e){return new code(e.code,e.scope)},DBRef:function(e){return new db_ref(e.collection||e.namespace,e.oid,e.db,e.fields)},Decimal128:function(e){return new decimal128(e.bytes)},Double:function(e){return new double_1(e.value)},Int32:function(e){return new int_32(e.value)},Long:function(e){return long_1.fromBits(null!=e.low?e.low:e.low_,null!=e.low?e.high:e.high_,null!=e.low?e.unsigned:e.unsigned_)},MaxKey:function(){return new max_key},MinKey:function(){return new min_key},ObjectID:function(e){return new objectid(e)},ObjectId:function(e){return new objectid(e)},BSONRegExp:function(e){return new regexp(e.pattern,e.options)},Symbol:function(e){return new symbol(e.value)},Timestamp:function(e){return timestamp.fromBits(e.low,e.high)}};function serializeDocument(e,t){if(null==e||"object"!==_typeof$2(e))throw new Error("not an object instance");var n=e._bsontype;if(void 0===n){var r={};for(var i in e)r[i]=serializeValue(e[i],t);return r}if("string"==typeof n){var o=e;if("function"!=typeof o.toExtendedJSON){var s=BSON_TYPE_MAPPINGS[n];if(!s)throw new TypeError("Unrecognized or invalid _bsontype: "+n);o=s(o)}return"Code"===n&&o.scope?o=new code(o.code,serializeValue(o.scope,t)):"DBRef"===n&&o.oid&&(o=new db_ref(o.collection,serializeValue(o.oid,t),o.db,o.fields)),o.toExtendedJSON(t)}throw new Error("_bsontype must be a string, but was: "+_typeof$2(n))}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,n){for(var r=0,i=t;i<n;i+=1){var o=e[i];if(r){if((o&FIRST_TWO_BITS)!==CONTINUING_CHAR)return!1;r-=1}else if(o&FIRST_BIT)if((o&FIRST_THREE_BITS)===TWO_BIT_CHAR)r=1;else if((o&FIRST_FOUR_BITS)===THREE_BIT_CHAR)r=2;else{if((o&FIRST_FIVE_BITS)!==FOUR_BIT_CHAR)return!1;r=3}}return!r}var validateUtf8_1=validateUtf8,validate_utf8={validateUtf8:validateUtf8_1},Buffer$4=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.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,n){var r=(t=null==t?{}:t)&&t.index?t.index:0,i=e[r]|e[r+1]<<8|e[r+2]<<16|e[r+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+r>e.length)throw new Error("(bson size ".concat(i," + options.index ").concat(r," must be <= buffer length ").concat(Buffer$4.byteLength(e),")"));if(0!==e[r+i-1])throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return deserializeObject(e,r,t,n)}function deserializeObject(e,t,n,r){var i=null!=n.evalFunctions&&n.evalFunctions,o=null!=n.cacheFunctions&&n.cacheFunctions,s=null!=n.cacheFunctionsCrc32&&n.cacheFunctionsCrc32;if(!s)var u=null;var a=null==n.fieldsAsRaw?null:n.fieldsAsRaw,f=null!=n.raw&&n.raw,c="boolean"==typeof n.bsonRegExp&&n.bsonRegExp,l=null!=n.promoteBuffers&&n.promoteBuffers,h=null==n.promoteLongs||n.promoteLongs,p=null==n.promoteValues||n.promoteValues,d=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 _=r?[]:{},g=0;;){var b=e[t++];if(0===b)break;for(var m=t;0!==e[m]&&m<e.length;)m++;if(m>=Buffer$4.byteLength(e))throw new Error("Bad BSON Document: illegal CString");var w=r?g++:e.toString("utf8",t,m);if(t=m+1,b===constants.BSON_DATA_STRING){var v=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(v<=0||v>e.length-t||0!==e[t+v-1])throw new Error("bad string length in bson");if(!validateUtf8$1(e,t,t+v-1))throw new Error("Invalid UTF-8 string in BSON document");var E=e.toString("utf8",t,t+v-1);_[w]=E,t+=v}else if(b===constants.BSON_DATA_OID){var N=Buffer$4.alloc(12);e.copy(N,0,t,t+12),_[w]=new objectid(N),t+=12}else if(b===constants.BSON_DATA_INT&&!1===p)_[w]=new int_32(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24);else if(b===constants.BSON_DATA_INT)_[w]=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;else if(b===constants.BSON_DATA_NUMBER&&!1===p)_[w]=new double_1(e.readDoubleLE(t)),t+=8;else if(b===constants.BSON_DATA_NUMBER)_[w]=e.readDoubleLE(t),t+=8;else if(b===constants.BSON_DATA_DATE){var O=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,S=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;_[w]=new Date(new long_1(O,S).toNumber())}else if(b===constants.BSON_DATA_BOOLEAN){if(0!==e[t]&&1!==e[t])throw new Error("illegal boolean type value");_[w]=1===e[t++]}else if(b===constants.BSON_DATA_OBJECT){var A=t,T=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;if(T<=0||T>e.length-t)throw new Error("bad embedded document length in bson");_[w]=f?e.slice(t,t+T):deserializeObject(e,A,n,!1),t+=T}else if(b===constants.BSON_DATA_ARRAY){var B=t,I=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,D=n,P=t+I;if(a&&a[w]){for(var $ in D={},n)D[$]=n[$];D.raw=!0}if(_[w]=deserializeObject(e,B,D,!0),0!==e[(t+=I)-1])throw new Error("invalid array terminator byte");if(t!==P)throw new Error("corrupted array bson")}else if(b===constants.BSON_DATA_UNDEFINED)_[w]=void 0;else if(b===constants.BSON_DATA_NULL)_[w]=null;else if(b===constants.BSON_DATA_LONG){var R=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,x=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,M=new long_1(R,x);_[w]=h&&!0===p&&M.lessThanOrEqual(JS_INT_MAX_LONG)&&M.greaterThanOrEqual(JS_INT_MIN_LONG)?M.toNumber():M}else if(b===constants.BSON_DATA_DECIMAL128){var C=Buffer$4.alloc(16);e.copy(C,0,t,t+16),t+=16;var U=new decimal128(C);_[w]=U.toObject?U.toObject():U}else if(b===constants.BSON_DATA_BINARY){var j=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,L=j,z=e[t++];if(j<0)throw new Error("Negative binary type element size found");if(j>Buffer$4.byteLength(e))throw new Error("Binary type size larger than document size");if(null!=e.slice){if(z===binary.SUBTYPE_BYTE_ARRAY){if((j=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(j>L-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(j<L-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}_[w]=l&&p?e.slice(t,t+j):new binary(e.slice(t,t+j),z)}else{var k="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(j)):new Array(j);if(z===binary.SUBTYPE_BYTE_ARRAY){if((j=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(j>L-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(j<L-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}for(m=0;m<j;m++)k[m]=e[t+m];_[w]=l&&p?k:new binary(k,z)}t+=j}else if(b===constants.BSON_DATA_REGEXP&&!1===c){for(m=t;0!==e[m]&&m<e.length;)m++;if(m>=e.length)throw new Error("Bad BSON Document: illegal CString");var F=e.toString("utf8",t,m);for(m=t=m+1;0!==e[m]&&m<e.length;)m++;if(m>=e.length)throw new Error("Bad BSON Document: illegal CString");var q=e.toString("utf8",t,m);t=m+1;var Y=new Array(q.length);for(m=0;m<q.length;m++)switch(q[m]){case"m":Y[m]="m";break;case"s":Y[m]="g";break;case"i":Y[m]="i"}_[w]=new RegExp(F,Y.join(""))}else if(b===constants.BSON_DATA_REGEXP&&!0===c){for(m=t;0!==e[m]&&m<e.length;)m++;if(m>=e.length)throw new Error("Bad BSON Document: illegal CString");var J=e.toString("utf8",t,m);for(m=t=m+1;0!==e[m]&&m<e.length;)m++;if(m>=e.length)throw new Error("Bad BSON Document: illegal CString");var G=e.toString("utf8",t,m);t=m+1,_[w]=new regexp(J,G)}else if(b===constants.BSON_DATA_SYMBOL){var X=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(X<=0||X>e.length-t||0!==e[t+X-1])throw new Error("bad string length in bson");var H=e.toString("utf8",t,t+X-1);_[w]=p?H:new symbol(H),t+=X}else if(b===constants.BSON_DATA_TIMESTAMP){var K=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,W=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;_[w]=new timestamp(K,W)}else if(b===constants.BSON_DATA_MIN_KEY)_[w]=new min_key;else if(b===constants.BSON_DATA_MAX_KEY)_[w]=new max_key;else if(b===constants.BSON_DATA_CODE){var V=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(V<=0||V>e.length-t||0!==e[t+V-1])throw new Error("bad string length in bson");var Q=e.toString("utf8",t,t+V-1);if(i)if(o){var Z=s?u(Q):Q;_[w]=isolateEvalWithHash(functionCache,Z,Q,_)}else _[w]=isolateEval(Q);else _[w]=new code(Q);t+=V}else if(b===constants.BSON_DATA_CODE_W_SCOPE){var ee=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(ee<13)throw new Error("code_w_scope total size shorter minimum expected length");var te=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(te<=0||te>e.length-t||0!==e[t+te-1])throw new Error("bad string length in bson");var ne=e.toString("utf8",t,t+te-1),re=t+=te,ie=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,oe=deserializeObject(e,re,n,!1);if(t+=ie,ee<8+ie+te)throw new Error("code_w_scope total size is too short, truncating scope");if(ee>8+ie+te)throw new Error("code_w_scope total size is too long, clips outer document");if(i){if(o){var se=s?u(ne):ne;_[w]=isolateEvalWithHash(functionCache,se,ne,_)}else _[w]=isolateEval(ne);_[w].scope=oe}else _[w]=new code(ne,oe)}else{if(b!==constants.BSON_DATA_DBPOINTER)throw new Error("Detected unknown BSON type "+b.toString(16)+' for fieldname "'+w+'", 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 ae=e.toString("utf8",t,t+ue-1);t+=ue;var fe=Buffer$4.alloc(12);e.copy(fe,0,t,t+12);var ce=new objectid(fe);t+=12,_[w]=new db_ref(ae,ce)}}if(y!==t-d){if(r)throw new Error("corrupt array bson");throw new Error("corrupt object bson")}var le=Object.keys(_).filter((function(e){return e.startsWith("$")})),he=!0;if(le.forEach((function(e){-1===["$ref","$id","$db"].indexOf(e)&&(he=!1)})),!he)return _;if(null!=_.$id&&null!=_.$ref){var pe=Object.assign({},_);return delete pe.$ref,delete pe.$id,delete pe.$db,new db_ref(_.$ref,_.$id,_.$db||null,pe)}return _}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,n,r,i){var o,s,u="big"===n,a=8*i-r-1,f=(1<<a)-1,c=f>>1,l=-7,h=u?0:i-1,p=u?1:-1,d=e[t+h];for(h+=p,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+e[t+h],h+=p,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+e[t+h],h+=p,l-=8);if(0===o)o=1-c;else{if(o===f)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=c}return(d?-1:1)*s*Math.pow(2,o-r)}function writeIEEE754(e,t,n,r,i,o){var s,u,a,f="big"===r,c=8*o-i-1,l=(1<<c)-1,h=l>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=f?o-1:0,y=f?-1:1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-s))<1&&(s--,a*=2),(t+=s+h>=1?p/a:p*Math.pow(2,1-h))*a>=2&&(s++,a/=2),s+h>=l?(u=0,s=l):s+h>=1?(u=(t*a-1)*Math.pow(2,i),s+=h):(u=t*Math.pow(2,h-1)*Math.pow(2,i),s=0)),isNaN(t)&&(u=0);i>=8;)e[n+d]=255&u,d+=y,u/=256,i-=8;for(s=s<<i|u,isNaN(t)&&(s+=8),c+=i;c>0;)e[n+d]=255&s,d+=y,s/=256,c-=8;e[n+d-y]|=128*_}var float_parser={readIEEE754:readIEEE754,writeIEEE754:writeIEEE754};function _typeof$3(e){return(_typeof$3="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)}var Buffer$5=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.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$3(e)&&"[object Date]"===Object.prototype.toString.call(e)},isRegExp$1=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)};function serializeString(e,t,n,r,i){e[r++]=constants.BSON_DATA_STRING;var o=i?e.write(t,r,"ascii"):e.write(t,r,"utf8");e[(r=r+o+1)-1]=0;var s=e.write(n,r+4,"utf8");return e[r+3]=s+1>>24&255,e[r+2]=s+1>>16&255,e[r+1]=s+1>>8&255,e[r]=s+1&255,r=r+4+s,e[r++]=0,r}function serializeNumber(e,t,n,r,i){if(Math.floor(n)===n&&n>=constants.JS_INT_MIN&&n<=constants.JS_INT_MAX)if(n>=constants.BSON_INT32_MIN&&n<=constants.BSON_INT32_MAX)e[r++]=constants.BSON_DATA_INT,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,e[r++]=255&n,e[r++]=n>>8&255,e[r++]=n>>16&255,e[r++]=n>>24&255;else if(n>=constants.JS_INT_MIN&&n<=constants.JS_INT_MAX){e[r++]=constants.BSON_DATA_NUMBER,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,writeIEEE754$1(e,n,r,"little",52,8),r+=8}else{e[r++]=constants.BSON_DATA_LONG,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var o=long_1.fromNumber(n),s=o.getLowBits(),u=o.getHighBits();e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,e[r++]=255&u,e[r++]=u>>8&255,e[r++]=u>>16&255,e[r++]=u>>24&255}else e[r++]=constants.BSON_DATA_NUMBER,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,writeIEEE754$1(e,n,r,"little",52,8),r+=8;return r}function serializeNull(e,t,n,r,i){return e[r++]=constants.BSON_DATA_NULL,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,r}function serializeBoolean(e,t,n,r,i){return e[r++]=constants.BSON_DATA_BOOLEAN,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,e[r++]=n?1:0,r}function serializeDate(e,t,n,r,i){e[r++]=constants.BSON_DATA_DATE,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var o=long_1.fromNumber(n.getTime()),s=o.getLowBits(),u=o.getHighBits();return e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,e[r++]=255&u,e[r++]=u>>8&255,e[r++]=u>>16&255,e[r++]=u>>24&255,r}function serializeRegExp(e,t,n,r,i){if(e[r++]=constants.BSON_DATA_REGEXP,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,n.source&&null!=n.source.match(regexp$1))throw Error("value "+n.source+" must not contain null bytes");return r+=e.write(n.source,r,"utf8"),e[r++]=0,n.ignoreCase&&(e[r++]=105),n.global&&(e[r++]=115),n.multiline&&(e[r++]=109),e[r++]=0,r}function serializeBSONRegExp(e,t,n,r,i){if(e[r++]=constants.BSON_DATA_REGEXP,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,null!=n.pattern.match(regexp$1))throw Error("pattern "+n.pattern+" must not contain null bytes");return r+=e.write(n.pattern,r,"utf8"),e[r++]=0,r+=e.write(n.options.split("").sort().join(""),r,"utf8"),e[r++]=0,r}function serializeMinMax(e,t,n,r,i){return null===n?e[r++]=constants.BSON_DATA_NULL:"MinKey"===n._bsontype?e[r++]=constants.BSON_DATA_MIN_KEY:e[r++]=constants.BSON_DATA_MAX_KEY,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,r}function serializeObjectId(e,t,n,r,i){if(e[r++]=constants.BSON_DATA_OID,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,"string"==typeof n.id)e.write(n.id,r,"binary");else{if(!n.id||!n.id.copy)throw new TypeError("object ["+JSON.stringify(n)+"] is not a valid ObjectId");n.id.copy(e,r,0,12)}return r+12}function serializeBuffer(e,t,n,r,i){e[r++]=constants.BSON_DATA_BINARY,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var o=n.length;return e[r++]=255&o,e[r++]=o>>8&255,e[r++]=o>>16&255,e[r++]=o>>24&255,e[r++]=constants.BSON_BINARY_SUBTYPE_DEFAULT,n.copy(e,r,0,o),r+=o}function serializeObject(e,t,n,r,i,o,s,u,a,f){for(var c=0;c<f.length;c++)if(f[c]===n)throw new Error("cyclic dependency detected");f.push(n),e[r++]=Array.isArray(n)?constants.BSON_DATA_ARRAY:constants.BSON_DATA_OBJECT,r+=a?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var l=serializeInto(e,n,i,r,o+1,s,u,f);return f.pop(),l}function serializeDecimal128(e,t,n,r,i){return e[r++]=constants.BSON_DATA_DECIMAL128,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,n.bytes.copy(e,r,0,16),r+16}function serializeLong(e,t,n,r,i){e[r++]="Long"===n._bsontype?constants.BSON_DATA_LONG:constants.BSON_DATA_TIMESTAMP,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var o=n.getLowBits(),s=n.getHighBits();return e[r++]=255&o,e[r++]=o>>8&255,e[r++]=o>>16&255,e[r++]=o>>24&255,e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,r}function serializeInt32(e,t,n,r,i){return e[r++]=constants.BSON_DATA_INT,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,e[r++]=255&n,e[r++]=n>>8&255,e[r++]=n>>16&255,e[r++]=n>>24&255,r}function serializeDouble(e,t,n,r,i){return e[r++]=constants.BSON_DATA_NUMBER,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,writeIEEE754$1(e,n.value,r,"little",52,8),r+=8}function serializeFunction(e,t,n,r,i,o,s){e[r++]=constants.BSON_DATA_CODE,r+=s?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var u=normalizedFunctionString$1(n),a=e.write(u,r+4,"utf8")+1;return e[r]=255&a,e[r+1]=a>>8&255,e[r+2]=a>>16&255,e[r+3]=a>>24&255,r=r+4+a-1,e[r++]=0,r}function serializeCode(e,t,n,r,i,o,s,u,a){if(n.scope&&"object"===_typeof$3(n.scope)){e[r++]=constants.BSON_DATA_CODE_W_SCOPE,r+=a?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var f=r,c="string"==typeof n.code?n.code:n.code.toString();r+=4;var l=e.write(c,r+4,"utf8")+1;e[r]=255&l,e[r+1]=l>>8&255,e[r+2]=l>>16&255,e[r+3]=l>>24&255,e[r+4+l-1]=0,r=r+l+4;var h=serializeInto(e,n.scope,i,r,o+1,s,u);r=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[r++]=0}else{e[r++]=constants.BSON_DATA_CODE,r+=a?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var d=n.code.toString(),y=e.write(d,r+4,"utf8")+1;e[r]=255&y,e[r+1]=y>>8&255,e[r+2]=y>>16&255,e[r+3]=y>>24&255,r=r+4+y-1,e[r++]=0}return r}function serializeBinary(e,t,n,r,i){e[r++]=constants.BSON_DATA_BINARY,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var o=n.value(!0),s=n.position;return n.sub_type===binary.SUBTYPE_BYTE_ARRAY&&(s+=4),e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,e[r++]=n.sub_type,n.sub_type===binary.SUBTYPE_BYTE_ARRAY&&(s-=4,e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255),o.copy(e,r,0,n.position),r+=n.position}function serializeSymbol(e,t,n,r,i){e[r++]=constants.BSON_DATA_SYMBOL,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var o=e.write(n.value,r+4,"utf8")+1;return e[r]=255&o,e[r+1]=o>>8&255,e[r+2]=o>>16&255,e[r+3]=o>>24&255,r=r+4+o-1,e[r++]=0,r}function serializeDBRef(e,t,n,r,i,o,s){e[r++]=constants.BSON_DATA_OBJECT,r+=s?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var u,a=r,f={$ref:n.collection||n.namespace,$id:n.oid};null!=n.db&&(f.$db=n.db);var c=(u=serializeInto(e,f=Object.assign(f,n.fields),!1,r,i+1,o))-a;return e[a++]=255&c,e[a++]=c>>8&255,e[a++]=c>>16&255,e[a++]=c>>24&255,u}function serializeInto(e,t,n,r,i,o,s,u){r=r||0,(u=u||[]).push(t);var a=r+4;if(Array.isArray(t))for(var f=0;f<t.length;f++){var c=""+f,l=t[f];if(l&&l.toBSON){if("function"!=typeof l.toBSON)throw new TypeError("toBSON is not a function");l=l.toBSON()}var h=_typeof$3(l);if("string"===h)a=serializeString(e,c,l,a,!0);else if("number"===h)a=serializeNumber(e,c,l,a,!0);else if("boolean"===h)a=serializeBoolean(e,c,l,a,!0);else if(l instanceof Date||isDate$1(l))a=serializeDate(e,c,l,a,!0);else if(void 0===l)a=serializeNull(e,c,l,a,!0);else if(null===l)a=serializeNull(e,c,l,a,!0);else if("ObjectId"===l._bsontype||"ObjectID"===l._bsontype)a=serializeObjectId(e,c,l,a,!0);else if(Buffer$5.isBuffer(l))a=serializeBuffer(e,c,l,a,!0);else if(l instanceof RegExp||isRegExp$1(l))a=serializeRegExp(e,c,l,a,!0);else if("object"===h&&null==l._bsontype)a=serializeObject(e,c,l,a,n,i,o,s,!0,u);else if("object"===h&&"Decimal128"===l._bsontype)a=serializeDecimal128(e,c,l,a,!0);else if("Long"===l._bsontype||"Timestamp"===l._bsontype)a=serializeLong(e,c,l,a,!0);else if("Double"===l._bsontype)a=serializeDouble(e,c,l,a,!0);else if("function"==typeof l&&o)a=serializeFunction(e,c,l,a,n,i,o,!0);else if("Code"===l._bsontype)a=serializeCode(e,c,l,a,n,i,o,s,!0);else if("Binary"===l._bsontype)a=serializeBinary(e,c,l,a,!0);else if("Symbol"===l._bsontype)a=serializeSymbol(e,c,l,a,!0);else if("DBRef"===l._bsontype)a=serializeDBRef(e,c,l,a,i,o,!0);else if("BSONRegExp"===l._bsontype)a=serializeBSONRegExp(e,c,l,a,!0);else if("Int32"===l._bsontype)a=serializeInt32(e,c,l,a,!0);else if("MinKey"===l._bsontype||"MaxKey"===l._bsontype)a=serializeMinMax(e,c,l,a,!0);else if(void 0!==l._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+l._bsontype)}else if(t instanceof map)for(var p=t.entries(),d=!1;!d;){var y=p.next();if(!(d=y.done)){var _=y.value[0],g=y.value[1],b=_typeof$3(g);if("string"==typeof _&&!ignoreKeys.has(_)){if(null!=_.match(regexp$1))throw Error("key "+_+" must not contain null bytes");if(n){if("$"===_[0])throw Error("key "+_+" must not start with '$'");if(~_.indexOf("."))throw Error("key "+_+" must not contain '.'")}}if("string"===b)a=serializeString(e,_,g,a);else if("number"===b)a=serializeNumber(e,_,g,a);else if("boolean"===b)a=serializeBoolean(e,_,g,a);else if(g instanceof Date||isDate$1(g))a=serializeDate(e,_,g,a);else if(null===g||void 0===g&&!1===s)a=serializeNull(e,_,g,a);else if("ObjectId"===g._bsontype||"ObjectID"===g._bsontype)a=serializeObjectId(e,_,g,a);else if(Buffer$5.isBuffer(g))a=serializeBuffer(e,_,g,a);else if(g instanceof RegExp||isRegExp$1(g))a=serializeRegExp(e,_,g,a);else if("object"===b&&null==g._bsontype)a=serializeObject(e,_,g,a,n,i,o,s,!1,u);else if("object"===b&&"Decimal128"===g._bsontype)a=serializeDecimal128(e,_,g,a);else if("Long"===g._bsontype||"Timestamp"===g._bsontype)a=serializeLong(e,_,g,a);else if("Double"===g._bsontype)a=serializeDouble(e,_,g,a);else if("Code"===g._bsontype)a=serializeCode(e,_,g,a,n,i,o,s);else if("function"==typeof g&&o)a=serializeFunction(e,_,g,a,n,i,o);else if("Binary"===g._bsontype)a=serializeBinary(e,_,g,a);else if("Symbol"===g._bsontype)a=serializeSymbol(e,_,g,a);else if("DBRef"===g._bsontype)a=serializeDBRef(e,_,g,a,i,o);else if("BSONRegExp"===g._bsontype)a=serializeBSONRegExp(e,_,g,a);else if("Int32"===g._bsontype)a=serializeInt32(e,_,g,a);else if("MinKey"===g._bsontype||"MaxKey"===g._bsontype)a=serializeMinMax(e,_,g,a);else if(void 0!==g._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+g._bsontype)}}else{if(t.toBSON){if("function"!=typeof t.toBSON)throw new TypeError("toBSON is not a function");if(null!=(t=t.toBSON())&&"object"!==_typeof$3(t))throw new TypeError("toBSON function did not return an object")}for(var m in t){var w=t[m];if(w&&w.toBSON){if("function"!=typeof w.toBSON)throw new TypeError("toBSON is not a function");w=w.toBSON()}var v=_typeof$3(w);if("string"==typeof m&&!ignoreKeys.has(m)){if(null!=m.match(regexp$1))throw Error("key "+m+" must not contain null bytes");if(n){if("$"===m[0])throw Error("key "+m+" must not start with '$'");if(~m.indexOf("."))throw Error("key "+m+" must not contain '.'")}}if("string"===v)a=serializeString(e,m,w,a);else if("number"===v)a=serializeNumber(e,m,w,a);else if("boolean"===v)a=serializeBoolean(e,m,w,a);else if(w instanceof Date||isDate$1(w))a=serializeDate(e,m,w,a);else if(void 0===w)!1===s&&(a=serializeNull(e,m,w,a));else if(null===w)a=serializeNull(e,m,w,a);else if("ObjectId"===w._bsontype||"ObjectID"===w._bsontype)a=serializeObjectId(e,m,w,a);else if(Buffer$5.isBuffer(w))a=serializeBuffer(e,m,w,a);else if(w instanceof RegExp||isRegExp$1(w))a=serializeRegExp(e,m,w,a);else if("object"===v&&null==w._bsontype)a=serializeObject(e,m,w,a,n,i,o,s,!1,u);else if("object"===v&&"Decimal128"===w._bsontype)a=serializeDecimal128(e,m,w,a);else if("Long"===w._bsontype||"Timestamp"===w._bsontype)a=serializeLong(e,m,w,a);else if("Double"===w._bsontype)a=serializeDouble(e,m,w,a);else if("Code"===w._bsontype)a=serializeCode(e,m,w,a,n,i,o,s);else if("function"==typeof w&&o)a=serializeFunction(e,m,w,a,n,i,o);else if("Binary"===w._bsontype)a=serializeBinary(e,m,w,a);else if("Symbol"===w._bsontype)a=serializeSymbol(e,m,w,a);else if("DBRef"===w._bsontype)a=serializeDBRef(e,m,w,a,i,o);else if("BSONRegExp"===w._bsontype)a=serializeBSONRegExp(e,m,w,a);else if("Int32"===w._bsontype)a=serializeInt32(e,m,w,a);else if("MinKey"===w._bsontype||"MaxKey"===w._bsontype)a=serializeMinMax(e,m,w,a);else if(void 0!==w._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+w._bsontype)}}u.pop(),e[a++]=0;var E=a-r;return e[r++]=255&E,e[r++]=E>>8&255,e[r++]=E>>16&255,e[r++]=E>>24&255,a}var serializer=serializeInto;function _typeof$4(e){return(_typeof$4="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)}var Buffer$6=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,normalizedFunctionString$2=utils.normalizedFunctionString;function isDate$2(e){return"object"===_typeof$4(e)&&"[object Date]"===Object.prototype.toString.call(e)}function calculateObjectSize(e,t,n){var r=5;if(Array.isArray(e))for(var i=0;i<e.length;i++)r+=calculateElement(i.toString(),e[i],t,!0,n);else for(var o in e.toBSON&&(e=e.toBSON()),e)r+=calculateElement(o,e[o],t,!1,n);return r}function calculateElement(e,t,n,r,i){switch(t&&t.toBSON&&(t=t.toBSON()),_typeof$4(t)){case"string":return 1+Buffer$6.byteLength(e,"utf8")+1+4+Buffer$6.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$6.byteLength(e,"utf8")+1:0)+5:(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+9;case"undefined":return r||!i?(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1:0;case"boolean":return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+2;case"object":if(null==t||"MinKey"===t._bsontype||"MaxKey"===t._bsontype)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1;if("ObjectId"===t._bsontype||"ObjectID"===t._bsontype)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+13;if(t instanceof Date||isDate$2(t))return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+9;if(void 0!==Buffer$6&&Buffer$6.isBuffer(t))return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+6+t.length;if("Long"===t._bsontype||"Double"===t._bsontype||"Timestamp"===t._bsontype)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+9;if("Decimal128"===t._bsontype)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+17;if("Code"===t._bsontype)return null!=t.scope&&Object.keys(t.scope).length>0?(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+4+4+Buffer$6.byteLength(t.code.toString(),"utf8")+1+calculateObjectSize(t.scope,n,i):(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+4+Buffer$6.byteLength(t.code.toString(),"utf8")+1;if("Binary"===t._bsontype)return t.sub_type===binary.SUBTYPE_BYTE_ARRAY?(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+(t.position+1+4+1+4):(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+(t.position+1+4+1);if("Symbol"===t._bsontype)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+Buffer$6.byteLength(t.value,"utf8")+4+1+1;if("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$6.byteLength(e,"utf8")+1:0)+1+calculateObjectSize(o,n,i)}return t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)?(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+Buffer$6.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:"BSONRegExp"===t._bsontype?(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+Buffer$6.byteLength(t.pattern,"utf8")+1+Buffer$6.byteLength(t.options,"utf8")+1:(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+calculateObjectSize(t,n,i)+1;case"function":if(t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)||"[object RegExp]"===String.call(t))return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+Buffer$6.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1;if(n&&null!=t.scope&&Object.keys(t.scope).length>0)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+4+4+Buffer$6.byteLength(normalizedFunctionString$2(t),"utf8")+1+calculateObjectSize(t.scope,n,i);if(n)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+4+Buffer$6.byteLength(normalizedFunctionString$2(t),"utf8")+1}return 0}var calculate_size=calculateObjectSize,Buffer$7=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,ensure_buffer=function(e){if(e instanceof Buffer$7)return e;if(e instanceof Uint8Array)return Buffer$7.from(e.buffer);throw new TypeError("Must use either Buffer or Uint8Array")},Buffer$8=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,MAXSIZE=17825792,buffer$1=Buffer$8.alloc(MAXSIZE);function setInternalBufferSize(e){buffer$1.length<e&&(buffer$1=Buffer$8.alloc(e))}function serialize$1(e,t){var n="boolean"==typeof(t=t||{}).checkKeys&&t.checkKeys,r="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$8.alloc(o));var s=serializer(buffer$1,e,n,0,0,r,i,[]),u=Buffer$8.alloc(s);return buffer$1.copy(u,0,0,u.length),u}function serializeWithBufferAndIndex(e,t,n){var r="boolean"==typeof(n=n||{}).checkKeys&&n.checkKeys,i="boolean"==typeof n.serializeFunctions&&n.serializeFunctions,o="boolean"!=typeof n.ignoreUndefined||n.ignoreUndefined,s="number"==typeof n.index?n.index:0,u=serializer(buffer$1,e,r,0,0,i,o);return buffer$1.copy(t,s,0,u),s+u-1}function deserialize$2(e,t){return e=ensure_buffer(e),deserializer(e,t)}function calculateObjectSize$1(e,t){var n="boolean"==typeof(t=t||{}).serializeFunctions&&t.serializeFunctions,r="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined;return calculate_size(e,n,r)}function deserializeStream(e,t,n,r,i,o){o=Object.assign({allowObjectSmallerThanBufferSize:!0},o),e=ensure_buffer(e);for(var s=t,u=0;u<n;u++){var a=e[s]|e[s+1]<<8|e[s+2]<<16|e[s+3]<<24;o.index=s,r[i+u]=deserializer(e,o),s+=a}return s}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,_unused_webpack_default_export=bson}).call(this,__webpack_require__(3),__webpack_require__(1).Buffer)},function(e,t,n){"use strict";(function(e){
|
|
2
|
-
/*!
|
|
3
|
-
* The buffer module from node.js, for the browser.
|
|
4
|
-
*
|
|
5
|
-
* @author Feross Aboukhadijeh <http://feross.org>
|
|
6
|
-
* @license MIT
|
|
7
|
-
*/
|
|
8
|
-
var r=n(5),i=n(6),o=n(7);function s(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(e,t){if(s()<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,n){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return f(this,e,t,n)}function f(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);a.TYPED_ARRAY_SUPPORT?(e=t).__proto__=a.prototype:e=h(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!a.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|d(t,n),i=(e=u(e,r)).write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(a.isBuffer(t)){var n=0|p(t.length);return 0===(e=u(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?u(e,0):h(e,t);if("Buffer"===t.type&&o(t.data))return h(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function c(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 l(e,t){if(c(t),e=u(e,t<0?0:0|p(t)),!a.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t){var n=t.length<0?0:0|p(t.length);e=u(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function d(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 n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return k(e).length;default:if(r)return z(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,n);case"utf8":case"utf-8":return A(this,t,n);case"ascii":return T(this,t,n);case"latin1":case"binary":return B(this,t,n);case"base64":return S(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function _(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function g(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=a.from(t,r)),a.isBuffer(t))return 0===t.length?-1:b(e,t,n,r,i);if("number"==typeof t)return t&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):b(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,n,r,i){var o,s=1,u=e.length,a=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,u/=2,a/=2,n/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(o=n;o<u;o++)if(f(e,o)===f(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===a)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(n+a>u&&(n=u-a),o=n;o>=0;o--){for(var l=!0,h=0;h<a;h++)if(f(e,o+h)!==f(t,h)){l=!1;break}if(l)return o}return-1}function m(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var u=parseInt(t.substr(2*s,2),16);if(isNaN(u))return s;e[n+s]=u}return s}function w(e,t,n,r){return F(z(t,e.length-n),e,n,r)}function v(e,t,n,r){return F(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function E(e,t,n,r){return v(e,t,n,r)}function N(e,t,n,r){return F(k(t),e,n,r)}function O(e,t,n,r){return F(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function S(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function A(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,u,a,f=e[i],c=null,l=f>239?4:f>223?3:f>191?2:1;if(i+l<=n)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=e[i+1]))&&(a=(31&f)<<6|63&o)>127&&(c=a);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(a=(15&f)<<12|(63&o)<<6|63&s)>2047&&(a<55296||a>57343)&&(c=a);break;case 4:o=e[i+1],s=e[i+2],u=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&u)&&(a=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&u)>65535&&a<1114112&&(c=a)}null===c?(c=65533,l=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}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=s(),a.poolSize=8192,a._augment=function(e){return e.__proto__=a.prototype,e},a.from=function(e,t,n){return f(null,e,t,n)},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,n){return function(e,t,n,r){return c(t),t<=0?u(e,t):void 0!==n?"string"==typeof r?u(e,t).fill(n,r):u(e,t).fill(n):u(e,t)}(null,e,t,n)},a.allocUnsafe=function(e){return l(null,e)},a.allocUnsafeSlow=function(e){return l(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 n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?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 n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=a.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(!a.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},a.byteLength=d,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)_(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)_(this,t,t+3),_(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)_(this,t,t+7),_(this,t+1,t+6),_(this,t+2,t+5),_(this,t+3,t+4);return this},a.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?A(this,0,e):y.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="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},a.prototype.compare=function(e,t,n,r,i){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),u=Math.min(o,s),f=this.slice(r,i),c=e.slice(t,n),l=0;l<u;++l)if(f[l]!==c[l]){o=f[l],s=c[l];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},a.prototype.indexOf=function(e,t,n){return g(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return g(this,e,t,n,!1)},a.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return m(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return v(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return N(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function B(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function I(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=L(e[o]);return i}function D(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function P(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function $(e,t,n,r,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(n+r>e.length)throw new RangeError("Index out of range")}function R(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function x(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function M(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function C(e,t,n,r,o){return o||M(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function U(e,t,n,r,o){return o||M(e,0,n,8),i.write(e,t,n,r,52,8),n+8}a.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),a.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=a.prototype;else{var i=t-e;n=new a(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},a.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},a.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},a.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return t||P(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||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},a.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},a.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(e,t){return t||P(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||P(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||P(e,4,this.length),i.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||$(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},a.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||$(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},a.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||$(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,n){return e=+e,t|=0,n||$(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||$(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||$(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):x(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||$(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):x(this,e,t,!1),t+4},a.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);$(this,e,t,n,i-1,-i)}var o=0,s=1,u=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===u&&0!==this[t+o-1]&&(u=1),this[t+o]=(e/s>>0)-u&255;return t+n},a.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);$(this,e,t,n,i-1,-i)}var o=n-1,s=1,u=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===u&&0!==this[t+o+1]&&(u=1),this[t+o]=(e/s>>0)-u&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||$(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,n){return e=+e,t|=0,n||$(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||$(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||$(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):x(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||$(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):x(this,e,t,!1),t+4},a.prototype.writeFloatLE=function(e,t,n){return C(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return C(this,e,t,!1,n)},a.prototype.writeDoubleLE=function(e,t,n){return U(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return U(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},a.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=a.isBuffer(e)?e:z(new a(e,r).toString()),u=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%u]}return this};var j=/[^+\/0-9A-Za-z-_]/g;function L(e){return e<16?"0"+e.toString(16):e.toString(16)}function z(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function k(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(j,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(3))},function(e,t){e.exports=r;var n=null;try{n=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 r(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function i(e){return!0===(e&&e.__isLong__)}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0}),r.isLong=i;var o={},s={};function u(e,t){var n,r,i;return t?(i=0<=(e>>>=0)&&e<256)&&(r=s[e])?r:(n=f(e,(0|e)<0?-1:0,!0),i&&(s[e]=n),n):(i=-128<=(e|=0)&&e<128)&&(r=o[e])?r:(n=f(e,e<0?-1:0,!1),i&&(o[e]=n),n)}function a(e,t){if(isNaN(e))return t?b:g;if(t){if(e<0)return b;if(e>=d)return N}else{if(e<=-y)return O;if(e+1>=y)return E}return e<0?a(-e,t).neg():f(e%p|0,e/p|0,t)}function f(e,t,n){return new r(e,t,n)}r.fromInt=u,r.fromNumber=a,r.fromBits=f;var c=Math.pow;function l(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return l(e.substring(1),t,n).neg();for(var i=a(c(n,8)),o=g,s=0;s<e.length;s+=8){var u=Math.min(8,e.length-s),f=parseInt(e.substring(s,s+u),n);if(u<8){var h=a(c(n,u));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?l(e,t):f(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}r.fromString=l,r.fromValue=h;var p=4294967296,d=p*p,y=d/2,_=u(1<<24),g=u(0);r.ZERO=g;var b=u(0,!0);r.UZERO=b;var m=u(1);r.ONE=m;var w=u(1,!0);r.UONE=w;var v=u(-1);r.NEG_ONE=v;var E=f(-1,2147483647,!1);r.MAX_VALUE=E;var N=f(-1,-1,!0);r.MAX_UNSIGNED_VALUE=N;var O=f(0,-2147483648,!1);r.MIN_VALUE=O;var S=r.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(O)){var t=a(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=a(c(e,6),this.unsigned),o=this,s="";;){var u=o.div(i),f=(o.sub(u.mul(i)).toInt()>>>0).toString(e);if((o=u).isZero())return f+s;for(;f.length<6;)f="0"+f;s=""+f+s}},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(O)?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(),n=e.isNegative();return t&&!n?-1:!t&&n?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(O)?O:this.not().add(m)},S.neg=S.negate,S.add=function(e){i(e)||(e=h(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,o=65535&this.low,s=e.high>>>16,u=65535&e.high,a=e.low>>>16,c=0,l=0,p=0,d=0;return p+=(d+=o+(65535&e.low))>>>16,l+=(p+=r+a)>>>16,c+=(l+=n+u)>>>16,c+=t+s,f((p&=65535)<<16|(d&=65535),(c&=65535)<<16|(l&=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 g;if(i(e)||(e=h(e)),n)return f(n.mul(this.low,this.high,e.low,e.high),n.get_high(),this.unsigned);if(e.isZero())return g;if(this.eq(O))return e.isOdd()?O:g;if(e.eq(O))return this.isOdd()?O:g;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(_)&&e.lt(_))return a(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,r=65535&this.high,o=this.low>>>16,s=65535&this.low,u=e.high>>>16,c=65535&e.high,l=e.low>>>16,p=65535&e.low,d=0,y=0,b=0,m=0;return b+=(m+=s*p)>>>16,y+=(b+=o*p)>>>16,b&=65535,y+=(b+=s*l)>>>16,d+=(y+=r*p)>>>16,y&=65535,d+=(y+=o*l)>>>16,y&=65535,d+=(y+=s*c)>>>16,d+=t*p+r*l+o*c+s*u,f((b&=65535)<<16|(m&=65535),(d&=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,r,o;if(n)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?f((this.unsigned?n.div_u:n.div_s)(this.low,this.high,e.low,e.high),n.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?b:g;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return b;if(e.gt(this.shru(1)))return w;o=b}else{if(this.eq(O))return e.eq(m)||e.eq(v)?O:e.eq(O)?m:(t=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?m:v:(r=this.sub(e.mul(t)),o=t.add(r.div(e)));if(e.eq(O))return this.unsigned?b:g;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=g}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(t)/Math.LN2),u=s<=48?1:c(2,s-48),l=a(t),p=l.mul(e);p.isNegative()||p.gt(r);)p=(l=a(t-=u,this.unsigned)).mul(e);l.isZero()&&(l=m),o=o.add(l),r=r.sub(p)}return o},S.div=S.divide,S.modulo=function(e){return i(e)||(e=h(e)),n?f((this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,e.low,e.high),n.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]},r.fromBytes=function(e,t,n){return n?r.fromBytesLE(e,t):r.fromBytesBE(e,t)},r.fromBytesLE=function(e,t){return new r(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},r.fromBytesBE=function(e,t){return new r(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.registerDatabase=void 0;var i=n(8);var o={name:"database",entity:{database:function(e){var t=this.platform,n=t.adapter,o=t.runtime;return i.Db.reqClass=this.request.constructor,i.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},i.Db.runtime=o,this.wsClientClass&&(i.Db.wsClass=n.wsClass,i.Db.wsClientClass=this.wsClientClass),i.Db.ws||(i.Db.ws=null),new i.Db(r(r({},this.config),e))}}};try{cloudbase.registerComponent(o)}catch(e){}t.registerDatabase=function(e){try{e.registerComponent(o)}catch(e){console.warn(e)}}},function(e,t,n){"use strict";t.byteLength=function(e){var t=f(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=f(e),s=r[0],u=r[1],a=new o(function(e,t,n){return 3*(t+n)/4-n}(0,s,u)),c=0,l=u>0?s-4:s;for(n=0;n<l;n+=4)t=i[e.charCodeAt(n)]<<18|i[e.charCodeAt(n+1)]<<12|i[e.charCodeAt(n+2)]<<6|i[e.charCodeAt(n+3)],a[c++]=t>>16&255,a[c++]=t>>8&255,a[c++]=255&t;2===u&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,a[c++]=255&t);1===u&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,a[c++]=t>>8&255,a[c++]=255&t);return a},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=0,u=n-i;s<u;s+=16383)o.push(c(e,s,s+16383>u?u:s+16383));1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,a=s.length;u<a;++u)r[u]=s[u],i[s.charCodeAt(u)]=u;function f(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function c(e,t,n){for(var i,o,s=[],u=t;u<n;u+=3)i=(e[u]<<16&16711680)+(e[u+1]<<8&65280)+(255&e[u+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,r,i){var o,s,u=8*i-r-1,a=(1<<u)-1,f=a>>1,c=-7,l=n?i-1:0,h=n?-1:1,p=e[t+l];for(l+=h,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+e[t+l],l+=h,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;c>0;s=256*s+e[t+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===a)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=f}return(p?-1:1)*s*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var s,u,a,f=8*o-i-1,c=(1<<f)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-s))<1&&(s--,a*=2),(t+=s+l>=1?h/a:h*Math.pow(2,1-l))*a>=2&&(s++,a/=2),s+l>=c?(u=0,s=c):s+l>=1?(u=(t*a-1)*Math.pow(2,i),s+=l):(u=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[n+p]=255&u,p+=d,u/=256,i-=8);for(s=s<<i|u,f+=i;f>0;e[n+p]=255&s,p+=d,s/=256,f-=8);e[n+p-d]|=128*y}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){"use strict";n.r(t),n.d(t,"Query",(function(){return Ye})),n.d(t,"CollectionReference",(function(){return We})),n.d(t,"DocumentReference",(function(){return ze})),n.d(t,"Db",(function(){return gt}));var r,i,o={};n.r(o),n.d(o,"Point",(function(){return Z})),n.d(o,"LineString",(function(){return te})),n.d(o,"Polygon",(function(){return re})),n.d(o,"MultiPoint",(function(){return oe})),n.d(o,"MultiLineString",(function(){return ue})),n.d(o,"MultiPolygon",(function(){return fe})),function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined"}(i||(i={}));var s,u="Number",a="Object",f="Array",c="GeoPoint",l="GeoLineString",h="GeoPolygon",p="GeoMultiPoint",d="GeoMultiLineString",y="GeoMultiPolygon",_="Date",g="ServerDate",b="BsonDate",m=["desc","asc"],w=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(s||(s={}));var v;(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte";!function(e){e.WHERE="WHERE",e.DOC="DOC"}(v||(v={}));var E,N=(E=function(e,t){return(E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}E(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),O=[],S={},A=function(e){function t(t,n){if(n!==S)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return N(t,e),t.for=function(e){for(var n=0,r=O.length;n<r;n++)if(O[n].target===e)return O[n].instance;var i=new t(e,S);return O.push({target:e,instance:i}),i},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),T=A,B=T.for("UNSET_FIELD_NAME"),I=T.for("UPDATE_COMMAND"),D=T.for("QUERY_COMMAND"),P=T.for("LOGIC_COMMAND"),$=T.for("GEO_POINT"),R=T.for("SYMBOL_GEO_LINE_STRING"),x=T.for("SYMBOL_GEO_POLYGON"),M=T.for("SYMBOL_GEO_MULTI_POINT"),C=T.for("SYMBOL_GEO_MULTI_LINE_STRING"),U=T.for("SYMBOL_GEO_MULTI_POLYGON"),j=T.for("SERVER_DATE"),L=T.for("REGEXP"),z=function(){function e(e){var t=(void 0===e?{}:e).offset,n=void 0===t?0:t;this.offset=n}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function k(e){return new z(e)}var F,q=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},Y=function(){function e(){}return e.formatResDocumentData=function(t){return t.map((function(t){return e.formatField(t)}))},e.formatField=function(t){var n=Object.keys(t),r={};return Array.isArray(t)&&(r=[]),n.forEach((function(n){var i,o=t[n];switch(e.whichType(o)){case c:i=new Z(o.coordinates[0],o.coordinates[1]);break;case l:i=new te(o.coordinates.map((function(e){return new Z(e[0],e[1])})));break;case h:i=new re(o.coordinates.map((function(e){return new te(e.map((function(e){var t=q(e,2),n=t[0],r=t[1];return new Z(n,r)})))})));break;case p:i=new oe(o.coordinates.map((function(e){return new Z(e[0],e[1])})));break;case d:i=new ue(o.coordinates.map((function(e){return new te(e.map((function(e){var t=q(e,2),n=t[0],r=t[1];return new Z(n,r)})))})));break;case y:i=new fe(o.coordinates.map((function(e){return new re(e.map((function(e){return new te(e.map((function(e){var t=q(e,2),n=t[0],r=t[1];return new Z(n,r)})))})))})));break;case _:i=new Date(1e3*o.$timestamp);break;case a:case f:i=e.formatField(o);break;case g:i=new Date(o.$date);break;default:i=o}Array.isArray(r)?r.push(i):r[n]=i})),r},e.whichType=function(e){var t=Object.prototype.toString.call(e).slice(8,-1);if(t===_)return b;if(t===a){if(e instanceof Z)return c;if(e instanceof Date)return _;if(e instanceof z)return g;e.$timestamp?t=_:e.$date?t=g:Z.validate(e)?t=c:te.validate(e)?t=l:re.validate(e)?t=h:oe.validate(e)?t=p:ue.validate(e)?t=d:fe.validate(e)&&(t=y)}return t},e.generateDocId=function(){for(var e="ABCDEFabcdef0123456789",t="",n=0;n<24;n++)t+=e.charAt(Math.floor(Math.random()*e.length));return t},e}(),J=function(){function e(){}return e.isGeopoint=function(e,t){if(Y.whichType(t)!==u)throw new Error("Geo Point must be number type");var n=Math.abs(t);if("latitude"===e&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===e&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},e.isInteger=function(e,t){if(!Number.isInteger(t))throw new Error(e+i.IntergerError);return!0},e.isFieldOrder=function(e){if(-1===m.indexOf(e))throw new Error(i.DirectionError);return!0},e.isFieldPath=function(e){if(!/^[a-zA-Z0-9-_\.]/.test(e))throw new Error;return!0},e.isOperator=function(e){if(-1===w.indexOf(e))throw new Error(i.OpStrError);return!0},e.isCollName=function(e){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e))throw new Error(i.CollNameError);return!0},e.isDocID=function(e){if(!/^([a-fA-F0-9]){24}$/.test(e))throw new Error(i.DocIDError);return!0},e}(),G=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},X=function(e){return"object"===G(e)},H=function(e){return"number"===G(e)},K=function(e){return Array.isArray(e)},W=function(e){return"date"===G(e)},V=function(e){return"regexp"===G(e)},Q=function(e){return e&&e._internalType instanceof A},Z=function(){function e(e,t){J.isGeopoint("longitude",e),J.isGeopoint("latitude",t),this.longitude=e,this.latitude=t}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Point",coordinates:[this.longitude,this.latitude]},t},e.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},e.prototype.toReadableString=function(){return"["+this.longitude+","+this.latitude+"]"},e.validate=function(e){return"Point"===e.type&&K(e.coordinates)&&J.isGeopoint("longitude",e.coordinates[0])&&J.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return $},enumerable:!0,configurable:!0}),e}(),ee=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},te=function(){function e(e){if(!K(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(e.length<2)throw new Error('"points" must contain 2 points at least');e.forEach((function(e){if(!(e instanceof Z))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e+"[]")})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,n;if("LineString"!==e.type||!K(e.coordinates))return!1;try{for(var r=ee(e.coordinates),i=r.next();!i.done;i=r.next()){var o=i.value;if(!H(o[0])||!H(o[1]))return!1}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},e.isClosed=function(e){var t=e.points[0],n=e.points[e.points.length-1];if(t.latitude===n.latitude&&t.longitude===n.longitude)return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return R},enumerable:!0,configurable:!0}),e}(),ne=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},re=function(){function e(e){if(!K(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof te))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]");if(!te.isClosed(e))throw new Error("LineString "+e.points.map((function(e){return e.toReadableString()}))+" is not a closed cycle")})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,n,r,i;if("Polygon"!==e.type||!K(e.coordinates))return!1;try{for(var o=ne(e.coordinates),s=o.next();!s.done;s=o.next()){var u=s.value;if(!this.isCloseLineString(u))return!1;try{for(var a=(r=void 0,ne(u)),f=a.next();!f.done;f=a.next()){var c=f.value;if(!H(c[0])||!H(c[1]))return!1}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return!0},e.isCloseLineString=function(e){var t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]},Object.defineProperty(e.prototype,"_internalType",{get:function(){return U},enumerable:!0,configurable:!0}),e}(),ie=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},oe=function(){function e(e){if(!K(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(0===e.length)throw new Error('"points" must contain 1 point at least');e.forEach((function(e){if(!(e instanceof Z))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e+"[]")})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,n;if("MultiPoint"!==e.type||!K(e.coordinates))return!1;try{for(var r=ie(e.coordinates),i=r.next();!i.done;i=r.next()){var o=i.value;if(!H(o[0])||!H(o[1]))return!1}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return M},enumerable:!0,configurable:!0}),e}(),se=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ue=function(){function e(e){if(!K(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof te))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]")})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,n,r,i;if("MultiLineString"!==e.type||!K(e.coordinates))return!1;try{for(var o=se(e.coordinates),s=o.next();!s.done;s=o.next()){var u=s.value;try{for(var a=(r=void 0,se(u)),f=a.next();!f.done;f=a.next()){var c=f.value;if(!H(c[0])||!H(c[1]))return!1}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return C},enumerable:!0,configurable:!0}),e}(),ae=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},fe=function(){function e(e){var t,n;if(!K(e))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof e);if(0===e.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=ae(e),i=r.next();!i.done;i=r.next()){var o=i.value;if(!(o instanceof re))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof o+"[]")}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.polygons=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))},t},e.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))}},e.validate=function(e){var t,n,r,i,o,s;if("MultiPolygon"!==e.type||!K(e.coordinates))return!1;try{for(var u=ae(e.coordinates),a=u.next();!a.done;a=u.next()){var f=a.value;try{for(var c=(r=void 0,ae(f)),l=c.next();!l.done;l=c.next()){var h=l.value;try{for(var p=(o=void 0,ae(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!H(y[0])||!H(y[1]))return!1}}catch(e){o={error:e}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return x},enumerable:!0,configurable:!0}),e}(),ce=function(){var e;if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e};!function(e){e.SET="set",e.REMOVE="remove",e.INC="inc",e.MUL="mul",e.PUSH="push",e.PULL="pull",e.PULL_ALL="pullAll",e.POP="pop",e.SHIFT="shift",e.UNSHIFT="unshift",e.ADD_TO_SET="addToSet",e.BIT="bit",e.RENAME="rename",e.MAX="max",e.MIN="min"}(F||(F={}));var le=function(){function e(e,t,n){this._internalType=I,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||B}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function he(e){return e&&e instanceof le&&e._internalType===I}var pe;!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(pe||(pe={}));var de=function(){function e(e,t,n){if(this._internalType=P,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||B,this.fieldName!==B)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var r=0,i=t.length;r<i;r++){(ye(o=t[r])||me(o))&&(t[r]=o._setFieldName(this.fieldName))}}else{var o;(ye(o=t)||me(o))&&(t=o._setFieldName(this.fieldName))}}return e.prototype._setFieldName=function(t){var n=this.operands.map((function(n){return n instanceof e?n._setFieldName(t):n}));return new e(this.operator,n,t)},e.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new e(pe.AND,r,this.fieldName)},e.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new e(pe.OR,r,this.fieldName)},e}();function ye(e){return e&&e instanceof de&&e._internalType===P}var _e,ge=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){e.EQ="eq",e.NEQ="neq",e.GT="gt",e.GTE="gte",e.LT="lt",e.LTE="lte",e.IN="in",e.NIN="nin",e.ALL="all",e.ELEM_MATCH="elemMatch",e.EXISTS="exists",e.SIZE="size",e.MOD="mod",e.GEO_NEAR="geoNear",e.GEO_WITHIN="geoWithin",e.GEO_INTERSECTS="geoIntersects"}(_e||(_e={}));var be=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this;return i.operator=t,i._internalType=D,i}return ge(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case _e.IN:case _e.NIN:return(e={})["$"+this.operator]=this.operands,e;default:return(t={})["$"+this.operator]=this.operands[0],t}},t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t.prototype.eq=function(e){var n=new t(_e.EQ,[e],this.fieldName);return this.and(n)},t.prototype.neq=function(e){var n=new t(_e.NEQ,[e],this.fieldName);return this.and(n)},t.prototype.gt=function(e){var n=new t(_e.GT,[e],this.fieldName);return this.and(n)},t.prototype.gte=function(e){var n=new t(_e.GTE,[e],this.fieldName);return this.and(n)},t.prototype.lt=function(e){var n=new t(_e.LT,[e],this.fieldName);return this.and(n)},t.prototype.lte=function(e){var n=new t(_e.LTE,[e],this.fieldName);return this.and(n)},t.prototype.in=function(e){var n=new t(_e.IN,e,this.fieldName);return this.and(n)},t.prototype.nin=function(e){var n=new t(_e.NIN,e,this.fieldName);return this.and(n)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof Z))throw new TypeError('"geometry" must be of type Point. Received type '+typeof e.geometry);if(void 0!==e.maxDistance&&!H(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof e.maxDistance);if(void 0!==e.minDistance&&!H(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof e.minDistance);var n=new t(_e.GEO_NEAR,[e],this.fieldName);return this.and(n)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof fe||e.geometry instanceof re))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof e.geometry);var n=new t(_e.GEO_WITHIN,[e],this.fieldName);return this.and(n)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof Z||e.geometry instanceof te||e.geometry instanceof re||e.geometry instanceof oe||e.geometry instanceof ue||e.geometry instanceof fe))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof e.geometry);var n=new t(_e.GEO_INTERSECTS,[e],this.fieldName);return this.and(n)},t}(de);function me(e){return e&&e instanceof be&&e._internalType===D}function we(e){return me(e)}var ve={};for(var Ee in _e)ve[Ee]="$"+Ee;for(var Ee in pe)ve[Ee]="$"+Ee;for(var Ee in F)ve[Ee]="$"+Ee;function Ne(e){return ve[e]||"$"+e}ve[_e.NEQ]="$ne",ve[F.REMOVE]="$unset",ve[F.SHIFT]="$pop",ve[F.UNSHIFT]="$push";var Oe=function(){return(Oe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},Se=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},Ae=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Se(arguments[t]));return e};function Te(e){return function e(t,n){if(!Q(t)){if(W(t))return{$date:+t};if(V(t))return{$regex:t.source,$options:t.flags};if(K(t))return t.map((function(t){if(n.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return e(t,Ae(n,[t]))}));if(X(t)){var r=Oe({},t);for(var i in r){if(n.indexOf(r[i])>-1)throw new Error("Cannot convert circular structure to JSON");r[i]=e(r[i],Ae(n,[r[i]]))}return r}return t}switch(t._internalType){case $:return t.toJSON();case j:case L:return t.parse();default:return t.toJSON?t.toJSON():t}}(e,[e])}var Be=function(){return(Be=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},Ie=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},De=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ie(arguments[t]));return e};function Pe(e,t,n,r){var i=Be({},e);for(var o in e)if(!/^\$/.test(o)){var s=e[o];if(s&&X(s)&&!t(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var u=Pe(s,t,De(n,[o]),De(r,[s]));i[o]=u;var a=!1;for(var f in u)/^\$/.test(f)?a=!0:(i[o+"."+f]=u[f],delete i[o][f]);a||delete i[o]}}return i}function $e(e){return Pe(e,xe,[],[e])}function Re(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?K(e[r])?e[r].push(t[r]):X(e[r])?X(t[r])?Object.assign(e[r],t[r]):(console.warn("unmergable condition, query is object but condition is "+G(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+G(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]}function xe(e){return Q(e)||W(e)||V(e)}function Me(e){return Te(e)}var Ce=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.prototype.encodeUpdate=function(e){return he(e)?this.encodeUpdateCommand(e):"object"===G(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===B)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case F.PUSH:case F.PULL:case F.PULL_ALL:case F.POP:case F.SHIFT:case F.UNSHIFT:case F.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,n,r,i,o=Ne(e.operator);switch(e.operator){case F.REMOVE:return(t={})[o]=((n={})[e.fieldName]="",n),t;default:return(r={})[o]=((i={})[e.fieldName]=e.operands[0],i),r}},e.prototype.encodeArrayUpdateCommand=function(e){var t,n,r,i,o,s,u,a,f,c,l=Ne(e.operator);switch(e.operator){case F.PUSH:var h=void 0;return h=K(e.operands)?{$each:e.operands.map(Me)}:e.operands,(t={})[l]=((n={})[e.fieldName]=h,n),t;case F.UNSHIFT:h={$each:e.operands.map(Me),$position:0};return(r={})[l]=((i={})[e.fieldName]=h,i),r;case F.POP:return(o={})[l]=((s={})[e.fieldName]=1,s),o;case F.SHIFT:return(u={})[l]=((a={})[e.fieldName]=-1,a),u;default:return(f={})[l]=((c={})[e.fieldName]=Me(e.operands),c),f}},e.prototype.encodeUpdateObject=function(e){var t=$e(e);for(var n in t)if(!/^\$/.test(n)){var r=t[n];if(he(r)){t[n]=r._setFieldName(n),Re(t,this.encodeUpdateCommand(t[n]),n)}else{t[n]=r=Me(r);var i=new le(F.SET,[r],n);Re(t,this.encodeUpdateCommand(i),n)}}return t},e}(),Ue={};function je(e){if(!gt.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return Ue[t]||(Ue[t]=new gt.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new gt.reqClass(e.config)}}})),Ue[t]}var Le=function(){return(Le=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},ze=function(){function e(e,t,n,r){var i=this;void 0===r&&(r={}),this.watch=function(e){return je(i._db).watch(Le(Le({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify({_id:i.id})}))},this._db=e,this._coll=t,this.id=n,this.request=new gt.reqClass(this._db.config),this.projection=r}return e.prototype.create=function(e,t){t=t||ce();var n={collectionName:this._coll,data:Te(e)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(e){e.code?t(0,e):t(0,{id:e.data._id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.set=function(e,t){if(t=t||ce(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(e){if("object"==typeof e)for(var t in e)e[t]instanceof le?n=!0:"object"==typeof e[t]&&r(e[t])};if(r(e),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var i={collectionName:this._coll,queryType:v.DOC,data:Te(e),multi:!1,merge:!1,upsert:!0};return this.id&&(i.query={_id:this.id}),this.request.send("database.updateDocument",i).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.update=function(e,t){if(t=t||ce(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:Ce.encode(e),query:n,queryType:v.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.remove=function(e){e=e||ce();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:v.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(t){t.code?e(0,t):e(0,{deleted:t.data.deleted,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},e.prototype.get=function(e){e=e||ce();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:v.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n=Y.formatResDocumentData(t.data.list);e(0,{data:n,requestId:t.requestId,total:t.TotalCount,limit:t.Limit,offset:t.Offset})}})).catch((function(t){e(t)})),e.promise},e.prototype.field=function(t){for(var n in t)t[n]?t[n]=1:t[n]=0;return new e(this._db,this._coll,this.id,t)},e}(),ke=function(){function e(){}return e.encode=function(e){return(new Fe).encodeQuery(e)},e}(),Fe=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var n;return xe(e)?ye(e)?this.encodeLogicCommand(e):me(e)?this.encodeQueryCommand(e):((n={})[t]=this.encodeQueryObject(e),n):X(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regex:e.source,$options:e.flags}},e.prototype.encodeLogicCommand=function(e){var t,n,r,i,o,s,u,a=this;switch(e.operator){case pe.NOR:case pe.AND:case pe.OR:var f=Ne(e.operator),c=e.operands.map((function(t){return a.encodeQuery(t,e.fieldName)}));return(t={})[f]=c,t;case pe.NOT:f=Ne(e.operator);var l=e.operands[0];if(V(l))return(n={})[e.fieldName]=((r={})[f]=this.encodeRegExp(l),r),n;c=this.encodeQuery(l)[e.fieldName];return(i={})[e.fieldName]=((o={})[f]=c,o),i;default:f=Ne(e.operator);if(1===e.operands.length){var h=this.encodeQuery(e.operands[0]);return(s={})[f]=h,s}c=e.operands.map(this.encodeQuery.bind(this));return(u={})[f]=c,u}},e.prototype.encodeQueryCommand=function(e){return we(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,n,r,i,o,s,u,a,f;if(e.fieldName===B)throw new Error("Cannot encode a comparison command with unset field name");var c=Ne(e.operator);switch(e.operator){case _e.EQ:case _e.NEQ:case _e.LT:case _e.LTE:case _e.GT:case _e.GTE:case _e.ELEM_MATCH:case _e.EXISTS:case _e.SIZE:case _e.MOD:return(t={})[e.fieldName]=((n={})[c]=Me(e.operands[0]),n),t;case _e.IN:case _e.NIN:case _e.ALL:return(r={})[e.fieldName]=((i={})[c]=Me(e.operands),i),r;case _e.GEO_NEAR:var l=e.operands[0];return(o={})[e.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},o;case _e.GEO_WITHIN:l=e.operands[0];return(s={})[e.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case _e.GEO_INTERSECTS:l=e.operands[0];return(u={})[e.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},u;default:return(a={})[e.fieldName]=((f={})[c]=Me(e.operands[0]),f),a}},e.prototype.encodeQueryObject=function(e){var t=$e(e);for(var n in t){var r=t[n];if(ye(r)){t[n]=r._setFieldName(n);var i=this.encodeLogicCommand(t[n]);this.mergeConditionAfterEncode(t,i,n)}else if(we(r)){t[n]=r._setFieldName(n);i=this.encodeComparisonCommand(t[n]);this.mergeConditionAfterEncode(t,i,n)}else xe(r)&&(t[n]=Me(r))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?K(e[r])?e[r]=e[r].concat(t[r]):X(e[r])?X(t[r])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is "+G(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+G(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]},e}(),qe=function(){return(qe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},Ye=function(){function e(e,t,n,r,i){var o=this;this.watch=function(e){return je(o._db).watch(qe(qe({},e),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify(o._fieldFilters||{}),limit:o._queryOptions.limit,orderBy:o._fieldOrders?o._fieldOrders.reduce((function(e,t){return e[t.field]=t.direction,e}),{}):void 0}))},this._db=e,this._coll=t,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=i||{},this._request=new gt.reqClass(this._db.config)}return e.prototype.get=function(e){e=e||ce();var t=[];this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)}));var n={collectionName:this._coll,queryType:v.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),t.length>0&&(n.order=t),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n={data:Y.formatResDocumentData(t.data.list),requestId:t.requestId};t.TotalCount&&(n.total=t.TotalCount),t.Limit&&(n.limit=t.Limit),t.Offset&&(n.offset=t.Offset),e(0,n)}})).catch((function(t){e(t)})),e.promise},e.prototype.count=function(e){e=e||ce();var t={collectionName:this._coll,queryType:v.WHERE};return this._fieldFilters&&(t.query=this._fieldFilters),this._request.send("database.countDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,total:t.data.total})})).catch((function(t){e(t)})),e.promise},e.prototype.where=function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))throw Error(i.QueryParamTypeError);var n=Object.keys(t),r=n.some((function(e){return void 0!==t[e]}));if(n.length&&!r)throw Error(i.QueryParamValueError);return new e(this._db,this._coll,ke.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,n){J.isFieldPath(t),J.isFieldOrder(n);var r={field:t,direction:n},i=this._fieldOrders.concat(r);return new e(this._db,this._coll,this._fieldFilters,i,this._queryOptions)},e.prototype.limit=function(t){J.isInteger("limit",t);var n=qe({},this._queryOptions);return n.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.skip=function(t){J.isInteger("offset",t);var n=qe({},this._queryOptions);return n.offset=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.update=function(e,t){if(t=t||ce(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:v.WHERE,multi:!0,merge:!0,upsert:!1,data:Ce.encode(e)};return this._request.send("database.updateDocument",n).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,updated:e.data.updated,upsertId:e.data.upsert_id})})).catch((function(e){t(e)})),t.promise},e.prototype.field=function(t){for(var n in t)t[n]?"object"!=typeof t[n]&&(t[n]=1):t[n]=0;var r=qe({},this._queryOptions);return r.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.remove=function(e){e=e||ce(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var t={collectionName:this._coll,query:ke.encode(this._fieldFilters),queryType:v.WHERE,multi:!0};return this._request.send("database.deleteDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,deleted:t.data.deleted})})).catch((function(t){e(t)})),e.promise},e}(),Je=n(0),Ge=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function u(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},Xe=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}},He=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=new gt.reqClass(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return Ge(this,void 0,void 0,(function(){var e;return Xe(this,(function(t){switch(t.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(e=t.sent())&&e.data&&e.data.list?[2,{requestId:e.requestId,data:JSON.parse(e.data.list).map(Je.a.parse)}]:[2,e]}}))}))},e.prototype.unwrap=function(){return this._stages},e.prototype.done=function(){return this._stages.map((function(e){var t,n=e.stageKey,r=e.stageValue;return(t={})[n]=JSON.parse(r),t}))},e.prototype._pipe=function(e,t){return this._stages.push({stageKey:"$"+e,stageValue:JSON.stringify(t)}),this},e.prototype.addFields=function(e){return this._pipe("addFields",e)},e.prototype.bucket=function(e){return this._pipe("bucket",e)},e.prototype.bucketAuto=function(e){return this._pipe("bucketAuto",e)},e.prototype.count=function(e){return this._pipe("count",e)},e.prototype.geoNear=function(e){return this._pipe("geoNear",e)},e.prototype.group=function(e){return this._pipe("group",e)},e.prototype.limit=function(e){return this._pipe("limit",e)},e.prototype.match=function(e){return this._pipe("match",ke.encode(e))},e.prototype.project=function(e){return this._pipe("project",e)},e.prototype.lookup=function(e){return this._pipe("lookup",e)},e.prototype.replaceRoot=function(e){return this._pipe("replaceRoot",e)},e.prototype.sample=function(e){return this._pipe("sample",e)},e.prototype.skip=function(e){return this._pipe("skip",e)},e.prototype.sort=function(e){return this._pipe("sort",e)},e.prototype.sortByCount=function(e){return this._pipe("sortByCount",e)},e.prototype.unwind=function(e){return this._pipe("unwind",e)},e}(),Ke=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),We=function(e){function t(t,n){return e.call(this,t,n)||this}return Ke(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new ze(this._db,this._coll,e)},t.prototype.add=function(e,t){return new ze(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new He(this._db,this._coll)},t}(Ye),Ve={eq:function(e){return new be(_e.EQ,[e])},neq:function(e){return new be(_e.NEQ,[e])},lt:function(e){return new be(_e.LT,[e])},lte:function(e){return new be(_e.LTE,[e])},gt:function(e){return new be(_e.GT,[e])},gte:function(e){return new be(_e.GTE,[e])},in:function(e){return new be(_e.IN,e)},nin:function(e){return new be(_e.NIN,e)},all:function(e){return new be(_e.ALL,e)},elemMatch:function(e){return new be(_e.ELEM_MATCH,[e])},exists:function(e){return new be(_e.EXISTS,[e])},size:function(e){return new be(_e.SIZE,[e])},mod:function(e){return new be(_e.MOD,[e])},geoNear:function(e){return new be(_e.GEO_NEAR,[e])},geoWithin:function(e){return new be(_e.GEO_WITHIN,[e])},geoIntersects:function(e){return new be(_e.GEO_INTERSECTS,[e])},and:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=K(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.AND,n)},nor:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=K(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.NOR,n)},or:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=K(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.OR,n)},not:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=K(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.NOT,n)},set:function(e){return new le(F.SET,[e])},remove:function(){return new le(F.REMOVE,[])},inc:function(e){return new le(F.INC,[e])},mul:function(e){return new le(F.MUL,[e])},push:function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(X(t[0])&&t[0].hasOwnProperty("each")){var r=t[0];e={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else e=K(t[0])?t[0]:Array.from(t);return new le(F.PUSH,e)},pull:function(e){return new le(F.PULL,e)},pullAll:function(e){return new le(F.PULL_ALL,e)},pop:function(){return new le(F.POP,[])},shift:function(){return new le(F.SHIFT,[])},unshift:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=K(arguments[0])?arguments[0]:Array.from(arguments);return new le(F.UNSHIFT,n)},addToSet:function(e){return new le(F.ADD_TO_SET,e)},rename:function(e){return new le(F.RENAME,[e])},bit:function(e){return new le(F.BIT,[e])},max:function(e){return new le(F.MAX,[e])},min:function(e){return new le(F.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===G(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new He},abs:function(e){return new Qe("abs",e)},add:function(e){return new Qe("add",e)},ceil:function(e){return new Qe("ceil",e)},divide:function(e){return new Qe("divide",e)},exp:function(e){return new Qe("exp",e)},floor:function(e){return new Qe("floor",e)},ln:function(e){return new Qe("ln",e)},log:function(e){return new Qe("log",e)},log10:function(e){return new Qe("log10",e)},mod:function(e){return new Qe("mod",e)},multiply:function(e){return new Qe("multiply",e)},pow:function(e){return new Qe("pow",e)},sqrt:function(e){return new Qe("sqrt",e)},subtract:function(e){return new Qe("subtract",e)},trunc:function(e){return new Qe("trunc",e)},arrayElemAt:function(e){return new Qe("arrayElemAt",e)},arrayToObject:function(e){return new Qe("arrayToObject",e)},concatArrays:function(e){return new Qe("concatArrays",e)},filter:function(e){return new Qe("filter",e)},in:function(e){return new Qe("in",e)},indexOfArray:function(e){return new Qe("indexOfArray",e)},isArray:function(e){return new Qe("isArray",e)},map:function(e){return new Qe("map",e)},range:function(e){return new Qe("range",e)},reduce:function(e){return new Qe("reduce",e)},reverseArray:function(e){return new Qe("reverseArray",e)},size:function(e){return new Qe("size",e)},slice:function(e){return new Qe("slice",e)},zip:function(e){return new Qe("zip",e)},and:function(e){return new Qe("and",e)},not:function(e){return new Qe("not",e)},or:function(e){return new Qe("or",e)},cmp:function(e){return new Qe("cmp",e)},eq:function(e){return new Qe("eq",e)},gt:function(e){return new Qe("gt",e)},gte:function(e){return new Qe("gte",e)},lt:function(e){return new Qe("lt",e)},lte:function(e){return new Qe("lte",e)},neq:function(e){return new Qe("ne",e)},cond:function(e){return new Qe("cond",e)},ifNull:function(e){return new Qe("ifNull",e)},switch:function(e){return new Qe("switch",e)},dateFromParts:function(e){return new Qe("dateFromParts",e)},dateFromString:function(e){return new Qe("dateFromString",e)},dayOfMonth:function(e){return new Qe("dayOfMonth",e)},dayOfWeek:function(e){return new Qe("dayOfWeek",e)},dayOfYear:function(e){return new Qe("dayOfYear",e)},isoDayOfWeek:function(e){return new Qe("isoDayOfWeek",e)},isoWeek:function(e){return new Qe("isoWeek",e)},isoWeekYear:function(e){return new Qe("isoWeekYear",e)},millisecond:function(e){return new Qe("millisecond",e)},minute:function(e){return new Qe("minute",e)},month:function(e){return new Qe("month",e)},second:function(e){return new Qe("second",e)},hour:function(e){return new Qe("hour",e)},week:function(e){return new Qe("week",e)},year:function(e){return new Qe("year",e)},literal:function(e){return new Qe("literal",e)},mergeObjects:function(e){return new Qe("mergeObjects",e)},objectToArray:function(e){return new Qe("objectToArray",e)},allElementsTrue:function(e){return new Qe("allElementsTrue",e)},anyElementTrue:function(e){return new Qe("anyElementTrue",e)},setDifference:function(e){return new Qe("setDifference",e)},setEquals:function(e){return new Qe("setEquals",e)},setIntersection:function(e){return new Qe("setIntersection",e)},setIsSubset:function(e){return new Qe("setIsSubset",e)},setUnion:function(e){return new Qe("setUnion",e)},concat:function(e){return new Qe("concat",e)},dateToString:function(e){return new Qe("dateToString",e)},indexOfBytes:function(e){return new Qe("indexOfBytes",e)},indexOfCP:function(e){return new Qe("indexOfCP",e)},split:function(e){return new Qe("split",e)},strLenBytes:function(e){return new Qe("strLenBytes",e)},strLenCP:function(e){return new Qe("strLenCP",e)},strcasecmp:function(e){return new Qe("strcasecmp",e)},substr:function(e){return new Qe("substr",e)},substrBytes:function(e){return new Qe("substrBytes",e)},substrCP:function(e){return new Qe("substrCP",e)},toLower:function(e){return new Qe("toLower",e)},toUpper:function(e){return new Qe("toUpper",e)},meta:function(e){return new Qe("meta",e)},addToSet:function(e){return new Qe("addToSet",e)},avg:function(e){return new Qe("avg",e)},first:function(e){return new Qe("first",e)},last:function(e){return new Qe("last",e)},max:function(e){return new Qe("max",e)},min:function(e){return new Qe("min",e)},push:function(e){return new Qe("push",e)},stdDevPop:function(e){return new Qe("stdDevPop",e)},stdDevSamp:function(e){return new Qe("stdDevSamp",e)},sum:function(e){return new Qe("sum",e)},let:function(e){return new Qe("let",e)}},project:{slice:function(e){return new Ze("slice",e)},elemMatch:function(e){return new Ze("elemMatch",e)}}},Qe=function(e,t){this["$"+e]=t},Ze=function(e,t){this["$"+e]=t},et=function(){function e(e){var t=e.regexp,n=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regex=t,this.$options=n}return e.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return L},enumerable:!0,configurable:!0}),e}();function tt(e){return new et(e)}var nt={code:"INSERT_DOC_FAIL",message:"insert document failed"},rt={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},it=function(){return(it=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},ot=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function u(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},st=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}},ut="database.updateDocInTransaction",at=function(){function e(e,t,n){this._coll=t,this.id=n,this._transaction=e,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return e.prototype.create=function(e){return ot(this,void 0,void 0,(function(){var t,n,r,i;return st(this,(function(o){switch(o.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:Je.a.stringify(Te(e),{relaxed:!1})},this.id&&(t._id=this.id),[4,this._request.send("database.insertDocInTransaction",t)];case 1:if((n=o.sent()).code)throw n;if(r=Je.a.parse(n.inserted),1==(i=Je.a.parse(n.ok))&&1==r)return[2,it(it({},n),{ok:i,inserted:r})];throw new Error(nt.message)}}))}))},e.prototype.get=function(){return ot(this,void 0,void 0,(function(){var e,t;return st(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,{data:"null"!==t.data?Y.formatField(Je.a.parse(t.data)):Je.a.parse(t.data),requestId:t.requestId}]}}))}))},e.prototype.set=function(e){return ot(this,void 0,void 0,(function(){var t,n;return st(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Je.a.stringify(Te(e),{relaxed:!1}),upsert:!0},[4,this._request.send(ut,t)];case 1:if((n=r.sent()).code)throw n;return[2,it(it({},n),{updated:Je.a.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},e.prototype.update=function(e){return ot(this,void 0,void 0,(function(){var t,n;return st(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Je.a.stringify(Ce.encode(e),{relaxed:!1})},[4,this._request.send(ut,t)];case 1:if((n=r.sent()).code)throw n;return[2,it(it({},n),{updated:Je.a.parse(n.updated)})]}}))}))},e.prototype.delete=function(){return ot(this,void 0,void 0,(function(){var e,t;return st(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,it(it({},t),{deleted:Je.a.parse(t.deleted)})]}}))}))},e}(),ft=function(e,t){this._coll=t,this._transaction=e},ct=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),lt=function(e){function t(t,n){return e.call(this,t,n)||this}return ct(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new at(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new at(this._transaction,this._coll,t).create(e)},t}(ft),ht=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function u(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},pt=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}},dt=function(){function e(e){this._db=e,this._request=new gt.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return ht(this,void 0,void 0,(function(){var e;return pt(this,(function(t){switch(t.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((e=t.sent()).code)throw e;return this.inited=!0,this._id=e.transactionId,[2]}}))}))},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new lt(this,e)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return ht(this,void 0,void 0,(function(){var e,t;return pt(this,(function(n){switch(n.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.commitTransaction",e)];case 1:if((t=n.sent()).code)throw t;return this.commited=!0,[2,t]}}))}))},e.prototype.rollback=function(e){return ht(this,void 0,void 0,(function(){var t,n;return pt(this,(function(r){switch(r.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.abortTransaction",t)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=e,[2,n]}}))}))},e}();function yt(){return ht(this,void 0,void 0,(function(){var e;return pt(this,(function(t){switch(t.label){case 0:return[4,(e=new dt(this)).init()];case 1:return t.sent(),[2,e]}}))}))}function _t(e,t){return void 0===t&&(t=3),ht(this,void 0,void 0,(function(){var n,r,i,o,s=this;return pt(this,(function(u){switch(u.label){case 0:return u.trys.push([0,4,,10]),[4,(n=new dt(this)).init()];case 1:return u.sent(),[4,e(n)];case 2:if(r=u.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return u.sent(),[2,r];case 4:if(i=u.sent(),!1===n.inited)throw i;return o=function(e){return ht(s,void 0,void 0,(function(){return pt(this,(function(t){switch(t.label){case 0:if(n.aborted||n.commited)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,n.rollback()];case 2:return t.sent(),[3,4];case 3:return t.sent(),[3,4];case 4:throw e;case 5:if(!0===n.aborted)throw n.abortReason;throw e}}))}))},t<=0?[4,o(i)]:[3,6];case 5:u.sent(),u.label=6;case 6:return i&&i.code===rt.code?[4,_t.bind(this)(e,--t)]:[3,8];case 7:return[2,u.sent()];case 8:return[4,o(i)];case 9:return u.sent(),[3,10];case 10:return[2]}}))}))}var gt=function(){function e(e){this.config=e,this.Geo=o,this.serverDate=k,this.command=Ve,this.RegExp=tt,this.startTransaction=yt,this.runTransaction=_t,this.logicCommand=de,this.updateCommand=le,this.queryCommand=be}return e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new We(this,e)},e.prototype.createCollection=function(t){var n={collectionName:t};return new e.reqClass(this.config).send("database.addCollection",n)},e}()}])}));
|
|
1
|
+
/*! For license information please see database.js.LICENSE.txt */
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_database",[],e):"object"==typeof exports?exports.cloudbase_database=e():t.cloudbase_database=e()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var t={258:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.registerDatabase=void 0;var o=n(358),i={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,i=e.runtime;return o.Db.reqClass=this.request.constructor,o.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},o.Db.runtime=i,this.wsClientClass&&(o.Db.wsClass=n.wsClass,o.Db.wsClientClass=this.wsClientClass),o.Db.ws||(o.Db.ws=null),new o.Db(r(r({},this.config),t))}}};try{cloudbase.registerComponent(i)}catch(t){}e.registerDatabase=function(t){try{t.registerComponent(i)}catch(t){console.warn(t)}}},358:(t,e,n)=>{n.r(e),n.d(e,{CollectionReference:()=>dn,Db:()=>Un,DocumentReference:()=>$t,Query:()=>qt});var r,o,i={};n.r(i),n.d(i,{LineString:()=>Q,MultiLineString:()=>et,MultiPoint:()=>K,MultiPolygon:()=>rt,Point:()=>W,Polygon:()=>X}),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var u,s,a="Object",f="GeoPoint",c="GeoLineString",h="GeoPolygon",p="GeoMultiPoint",l="GeoMultiLineString",d="GeoMultiPolygon",y="Date",g="ServerDate",m=["desc","asc"],w=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(u||(u={})),(r={})[u.eq]="$eq",r[u.lt]="$lt",r[u.lte]="$lte",r[u.gt]="$gt",r[u.gte]="$gte",function(t){t.WHERE="WHERE",t.DOC="DOC"}(s||(s={}));var b=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),v=[],_={},E=function(t){function e(e,n){if(n!==_)throw new TypeError("InternalSymbol cannot be constructed with new operator");return t.call(this,e)||this}return b(e,t),e.for=function(t){for(var n=0,r=v.length;n<r;n++)if(v[n].target===t)return v[n].instance;var o=new e(t,_);return v.push({target:t,instance:o}),o},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})}));const O=E;var S=O.for("UNSET_FIELD_NAME"),N=O.for("UPDATE_COMMAND"),x=O.for("QUERY_COMMAND"),I=O.for("LOGIC_COMMAND"),T=O.for("GEO_POINT"),A=O.for("SYMBOL_GEO_LINE_STRING"),B=O.for("SYMBOL_GEO_POLYGON"),j=O.for("SYMBOL_GEO_MULTI_POINT"),P=O.for("SYMBOL_GEO_MULTI_LINE_STRING"),L=O.for("SYMBOL_GEO_MULTI_POLYGON"),U=O.for("SERVER_DATE"),$=O.for("REGEXP"),R=function(){function t(t){var e=(void 0===t?{}:t).offset,n=void 0===e?0:e;this.offset=n}return Object.defineProperty(t.prototype,"_internalType",{get:function(){return U},enumerable:!0,configurable:!0}),t.prototype.parse=function(){return{$date:{offset:this.offset}}},t}();function M(t){return new R(t)}var D,q=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u},C=function(){function t(){}return t.formatResDocumentData=function(e){return e.map((function(e){return t.formatField(e)}))},t.formatField=function(e){var n=Object.keys(e),r={};return Array.isArray(e)&&(r=[]),n.forEach((function(n){var o,i=e[n];switch(t.whichType(i)){case f:o=new W(i.coordinates[0],i.coordinates[1]);break;case c:o=new Q(i.coordinates.map((function(t){return new W(t[0],t[1])})));break;case h:o=new X(i.coordinates.map((function(t){return new Q(t.map((function(t){var e=q(t,2),n=e[0],r=e[1];return new W(n,r)})))})));break;case p:o=new K(i.coordinates.map((function(t){return new W(t[0],t[1])})));break;case l:o=new et(i.coordinates.map((function(t){return new Q(t.map((function(t){var e=q(t,2),n=e[0],r=e[1];return new W(n,r)})))})));break;case d:o=new rt(i.coordinates.map((function(t){return new X(t.map((function(t){return new Q(t.map((function(t){var e=q(t,2),n=e[0],r=e[1];return new W(n,r)})))})))})));break;case y:o=new Date(1e3*i.$timestamp);break;case a:case"Array":o=t.formatField(i);break;case g:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o})),r},t.whichType=function(t){var e=Object.prototype.toString.call(t).slice(8,-1);if(e===y)return"BsonDate";if(e===a){if(t instanceof W)return f;if(t instanceof Date)return y;if(t instanceof R)return g;t.$timestamp?e=y:t.$date?e=g:W.validate(t)?e=f:Q.validate(t)?e=c:X.validate(t)?e=h:K.validate(t)?e=p:et.validate(t)?e=l:rt.validate(t)&&(e=d)}return e},t.generateDocId=function(){for(var t="",e=0;e<24;e++)t+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return t},t}(),k=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==C.whichType(e))throw new Error("Geo Point must be number type");var n=Math.abs(e);if("latitude"===t&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===t&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},t.isInteger=function(t,e){if(!Number.isInteger(e))throw new Error(t+o.IntergerError);return!0},t.isFieldOrder=function(t){if(-1===m.indexOf(t))throw new Error(o.DirectionError);return!0},t.isFieldPath=function(t){if(!/^[a-zA-Z0-9-_\.]/.test(t))throw new Error;return!0},t.isOperator=function(t){if(-1===w.indexOf(t))throw new Error(o.OpStrError);return!0},t.isCollName=function(t){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(t))throw new Error(o.CollNameError);return!0},t.isDocID=function(t){if(!/^([a-fA-F0-9]){24}$/.test(t))throw new Error(o.DocIDError);return!0},t}(),J=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},F=function(t){return"object"===J(t)},V=function(t){return"number"===J(t)},H=function(t){return Array.isArray(t)},G=function(t){return"date"===J(t)},Z=function(t){return"regexp"===J(t)},Y=function(t){return t&&t._internalType instanceof E},W=function(){function t(t,e){k.isGeopoint("longitude",t),k.isGeopoint("latitude",e),this.longitude=t,this.latitude=e}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Point",coordinates:[this.longitude,this.latitude]},e},t.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},t.prototype.toReadableString=function(){return"["+this.longitude+","+this.latitude+"]"},t.validate=function(t){return"Point"===t.type&&H(t.coordinates)&&k.isGeopoint("longitude",t.coordinates[0])&&k.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return T},enumerable:!0,configurable:!0}),t}(),Q=function(){function t(t){if(!H(t))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t);if(t.length<2)throw new Error('"points" must contain 2 points at least');t.forEach((function(t){if(!(t instanceof W))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t+"[]")})),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"LineString",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))},e},t.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))}},t.validate=function(t){var e,n;if("LineString"!==t.type||!H(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!V(i[0])||!V(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},t.isClosed=function(t){var e=t.points[0],n=t.points[t.points.length-1];if(e.latitude===n.latitude&&e.longitude===n.longitude)return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return A},enumerable:!0,configurable:!0}),t}(),z=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},X=function(){function t(t){if(!H(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof Q))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]");if(!Q.isClosed(t))throw new Error("LineString "+t.points.map((function(t){return t.toReadableString()}))+" is not a closed cycle")})),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Polygon",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))},e},t.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}},t.validate=function(t){var e,n,r,o;if("Polygon"!==t.type||!H(t.coordinates))return!1;try{for(var i=z(t.coordinates),u=i.next();!u.done;u=i.next()){var s=u.value;if(!this.isCloseLineString(s))return!1;try{for(var a=(r=void 0,z(s)),f=a.next();!f.done;f=a.next()){var c=f.value;if(!V(c[0])||!V(c[1]))return!1}}catch(t){r={error:t}}finally{try{f&&!f.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},t.isCloseLineString=function(t){var e=t[0],n=t[t.length-1];return e[0]===n[0]&&e[1]===n[1]},Object.defineProperty(t.prototype,"_internalType",{get:function(){return L},enumerable:!0,configurable:!0}),t}(),K=function(){function t(t){if(!H(t))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t);if(0===t.length)throw new Error('"points" must contain 1 point at least');t.forEach((function(t){if(!(t instanceof W))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t+"[]")})),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPoint",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))},e},t.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))}},t.validate=function(t){var e,n;if("MultiPoint"!==t.type||!H(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!V(i[0])||!V(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),t}(),tt=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},et=function(){function t(t){if(!H(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof Q))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]")})),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiLineString",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))},e},t.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}},t.validate=function(t){var e,n,r,o;if("MultiLineString"!==t.type||!H(t.coordinates))return!1;try{for(var i=tt(t.coordinates),u=i.next();!u.done;u=i.next()){var s=u.value;try{for(var a=(r=void 0,tt(s)),f=a.next();!f.done;f=a.next()){var c=f.value;if(!V(c[0])||!V(c[1]))return!1}}catch(t){r={error:t}}finally{try{f&&!f.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return P},enumerable:!0,configurable:!0}),t}(),nt=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},rt=function(){function t(t){var e,n;if(!H(t))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof t);if(0===t.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=nt(t),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof X))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof i+"[]")}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.polygons=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPolygon",coordinates:this.polygons.map((function(t){return t.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}))},e},t.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(t){return t.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}))}},t.validate=function(t){var e,n,r,o,i,u;if("MultiPolygon"!==t.type||!H(t.coordinates))return!1;try{for(var s=nt(t.coordinates),a=s.next();!a.done;a=s.next()){var f=a.value;try{for(var c=(r=void 0,nt(f)),h=c.next();!h.done;h=c.next()){var p=h.value;try{for(var l=(i=void 0,nt(p)),d=l.next();!d.done;d=l.next()){var y=d.value;if(!V(y[0])||!V(y[1]))return!1}}catch(t){i={error:t}}finally{try{d&&!d.done&&(u=l.return)&&u.call(l)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{h&&!h.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return B},enumerable:!0,configurable:!0}),t}(),ot=function(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t};!function(t){t.SET="set",t.REMOVE="remove",t.INC="inc",t.MUL="mul",t.PUSH="push",t.PULL="pull",t.PULL_ALL="pullAll",t.POP="pop",t.SHIFT="shift",t.UNSHIFT="unshift",t.ADD_TO_SET="addToSet",t.BIT="bit",t.RENAME="rename",t.MAX="max",t.MIN="min"}(D||(D={}));var it,ut=function(){function t(t,e,n){this._internalType=N,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||S}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function st(t){return t&&t instanceof ut&&t._internalType===N}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(it||(it={}));var at=function(){function t(t,e,n){if(this._internalType=I,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||S,this.fieldName!==S)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++)(ft(i=e[r])||lt(i))&&(e[r]=i._setFieldName(this.fieldName))}else{var i;(ft(i=e)||lt(i))&&(e=i._setFieldName(this.fieldName))}}return t.prototype._setFieldName=function(e){var n=this.operands.map((function(n){return n instanceof t?n._setFieldName(e):n}));return new t(this.operator,n,e)},t.prototype.and=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(it.AND,r,this.fieldName)},t.prototype.or=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(it.OR,r,this.fieldName)},t}();function ft(t){return t&&t instanceof at&&t._internalType===I}var ct,ht=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t.EQ="eq",t.NEQ="neq",t.GT="gt",t.GTE="gte",t.LT="lt",t.LTE="lte",t.IN="in",t.NIN="nin",t.ALL="all",t.ELEM_MATCH="elemMatch",t.EXISTS="exists",t.SIZE="size",t.MOD="mod",t.GEO_NEAR="geoNear",t.GEO_WITHIN="geoWithin",t.GEO_INTERSECTS="geoIntersects"}(ct||(ct={}));var pt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.operator=e,o._internalType=x,o}return ht(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case ct.IN:case ct.NIN:return(t={})["$"+this.operator]=this.operands,t;default:return(e={})["$"+this.operator]=this.operands[0],e}},e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e.prototype.eq=function(t){var n=new e(ct.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(ct.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(ct.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(ct.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(ct.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(ct.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(ct.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(ct.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof W))throw new TypeError('"geometry" must be of type Point. Received type '+typeof t.geometry);if(void 0!==t.maxDistance&&!V(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof t.maxDistance);if(void 0!==t.minDistance&&!V(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof t.minDistance);var n=new e(ct.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof rt||t.geometry instanceof X))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof t.geometry);var n=new e(ct.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof W||t.geometry instanceof Q||t.geometry instanceof X||t.geometry instanceof K||t.geometry instanceof et||t.geometry instanceof rt))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof t.geometry);var n=new e(ct.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(at);function lt(t){return t&&t instanceof pt&&t._internalType===x}function dt(t){return lt(t)}var yt={};for(var gt in ct)yt[gt]="$"+gt;for(var gt in it)yt[gt]="$"+gt;for(var gt in D)yt[gt]="$"+gt;function mt(t){return yt[t]||"$"+t}yt[ct.NEQ]="$ne",yt[D.REMOVE]="$unset",yt[D.SHIFT]="$pop",yt[D.UNSHIFT]="$push";var wt=function(){return wt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},wt.apply(this,arguments)},bt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u},vt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(bt(arguments[e]));return t};function _t(t){return Et(t,[t])}function Et(t,e){if(!Y(t)){if(G(t))return{$date:+t};if(Z(t))return{$regex:t.source,$options:t.flags};if(H(t))return t.map((function(t){if(e.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return Et(t,vt(e,[t]))}));if(F(t)){var n=wt({},t);for(var r in n){if(e.indexOf(n[r])>-1)throw new Error("Cannot convert circular structure to JSON");n[r]=Et(n[r],vt(e,[n[r]]))}return n}return t}switch(t._internalType){case T:return t.toJSON();case U:case $:return t.parse();default:return t.toJSON?t.toJSON():t}}var Ot=function(){return Ot=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ot.apply(this,arguments)},St=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u},Nt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(St(arguments[e]));return t};function xt(t,e,n,r){var o=Ot({},t);for(var i in t)if(!/^\$/.test(i)){var u=t[i];if(u&&F(u)&&!e(u)){if(r.indexOf(u)>-1)throw new Error("Cannot convert circular structure to JSON");var s=xt(u,e,Nt(n,[i]),Nt(r,[u]));o[i]=s;var a=!1;for(var f in s)/^\$/.test(f)?a=!0:(o[i+"."+f]=s[f],delete o[i][f]);a||delete o[i]}}return o}function It(t){return xt(t,At,[],[t])}function Tt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?H(t[r])?t[r].push(e[r]):F(t[r])?F(e[r])?Object.assign(t[r],e[r]):(console.warn("unmergable condition, query is object but condition is "+J(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+J(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]}function At(t){return Y(t)||G(t)||Z(t)}function Bt(t){return _t(t)}var jt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return st(t)?this.encodeUpdateCommand(t):"object"===J(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===S)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case D.PUSH:case D.PULL:case D.PULL_ALL:case D.POP:case D.SHIFT:case D.UNSHIFT:case D.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=mt(t.operator);return t.operator===D.REMOVE?((e={})[i]=((n={})[t.fieldName]="",n),e):((r={})[i]=((o={})[t.fieldName]=t.operands[0],o),r)},t.prototype.encodeArrayUpdateCommand=function(t){var e,n,r,o,i,u,s,a,f,c,h=mt(t.operator);switch(t.operator){case D.PUSH:var p=void 0;return p=H(t.operands)?{$each:t.operands.map(Bt)}:t.operands,(e={})[h]=((n={})[t.fieldName]=p,n),e;case D.UNSHIFT:return p={$each:t.operands.map(Bt),$position:0},(r={})[h]=((o={})[t.fieldName]=p,o),r;case D.POP:return(i={})[h]=((u={})[t.fieldName]=1,u),i;case D.SHIFT:return(s={})[h]=((a={})[t.fieldName]=-1,a),s;default:return(f={})[h]=((c={})[t.fieldName]=Bt(t.operands),c),f}},t.prototype.encodeUpdateObject=function(t){var e=It(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(st(r))e[n]=r._setFieldName(n),Tt(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=Bt(r);var o=new ut(D.SET,[r],n);Tt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),Pt={};function Lt(t){if(!Un.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return Pt[e]||(Pt[e]=new Un.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new Un.reqClass(t.config)}}})),Pt[e]}for(var Ut=function(){return Ut=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ut.apply(this,arguments)},$t=function(){function t(t,e,n,r){var o=this;void 0===r&&(r={}),this.watch=function(t){return Lt(o._db).watch(Ut(Ut({},t),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=t,this._coll=e,this.id=n,this.request=new Un.reqClass(this._db.config),this.projection=r}return t.prototype.create=function(t,e){e=e||ot();var n={collectionName:this._coll,data:_t(t)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(t){t.code?e(0,t):e(0,{id:t.data._id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.set=function(t,e){if(e=e||ot(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(t){if("object"==typeof t)for(var e in t)t[e]instanceof ut?n=!0:"object"==typeof t[e]&&r(t[e])};if(r(t),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:s.DOC,data:_t(t),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.update=function(t,e){if(e=e||ot(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:jt.encode(t),query:n,queryType:s.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.remove=function(t){t=t||ot();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:s.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(e){e.code?t(0,e):t(0,{deleted:e.data.deleted,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},t.prototype.get=function(t){t=t||ot();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:s.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n=C.formatResDocumentData(e.data.list);t(0,{data:n,requestId:e.requestId})}})).catch((function(e){t(e)})),t.promise},t.prototype.field=function(e){for(var n in e)e[n]?e[n]=1:e[n]=0;return new t(this._db,this._coll,this.id,e)},t}(),Rt=function(){function t(){}return t.encode=function(t){return(new Mt).encodeQuery(t)},t}(),Mt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return At(t)?ft(t)?this.encodeLogicCommand(t):lt(t)?this.encodeQueryCommand(t):((n={})[e]=this.encodeQueryObject(t),n):F(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regex:t.source,$options:t.flags}},t.prototype.encodeLogicCommand=function(t){var e,n,r,o,i,u,s,a=this;switch(t.operator){case it.NOR:case it.AND:case it.OR:var f=mt(t.operator),c=t.operands.map((function(e){return a.encodeQuery(e,t.fieldName)}));return(e={})[f]=c,e;case it.NOT:f=mt(t.operator);var h=t.operands[0];return Z(h)?((n={})[t.fieldName]=((r={})[f]=this.encodeRegExp(h),r),n):(c=this.encodeQuery(h)[t.fieldName],(o={})[t.fieldName]=((i={})[f]=c,i),o);default:if(f=mt(t.operator),1===t.operands.length){var p=this.encodeQuery(t.operands[0]);return(u={})[f]=p,u}return c=t.operands.map(this.encodeQuery.bind(this)),(s={})[f]=c,s}},t.prototype.encodeQueryCommand=function(t){return dt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,u,s,a,f;if(t.fieldName===S)throw new Error("Cannot encode a comparison command with unset field name");var c=mt(t.operator);switch(t.operator){case ct.EQ:case ct.NEQ:case ct.LT:case ct.LTE:case ct.GT:case ct.GTE:case ct.ELEM_MATCH:case ct.EXISTS:case ct.SIZE:case ct.MOD:return(e={})[t.fieldName]=((n={})[c]=Bt(t.operands[0]),n),e;case ct.IN:case ct.NIN:case ct.ALL:return(r={})[t.fieldName]=((o={})[c]=Bt(t.operands),o),r;case ct.GEO_NEAR:var h=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:h.geometry.toJSON(),$maxDistance:h.maxDistance,$minDistance:h.minDistance}},i;case ct.GEO_WITHIN:return h=t.operands[0],(u={})[t.fieldName]={$geoWithin:{$geometry:h.geometry.toJSON()}},u;case ct.GEO_INTERSECTS:return h=t.operands[0],(s={})[t.fieldName]={$geoIntersects:{$geometry:h.geometry.toJSON()}},s;default:return(a={})[t.fieldName]=((f={})[c]=Bt(t.operands[0]),f),a}},t.prototype.encodeQueryObject=function(t){var e=It(t);for(var n in e){var r=e[n];if(ft(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else dt(r)?(e[n]=r._setFieldName(n),o=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,o,n)):At(r)&&(e[n]=Bt(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?H(t[r])?t[r]=t[r].concat(e[r]):F(t[r])?F(e[r])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is "+J(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+J(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),Dt=function(){return Dt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Dt.apply(this,arguments)},qt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return Lt(i._db).watch(Dt(Dt({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(t,e){return t[e.field]=e.direction,t}),{}):void 0}))},this._db=t,this._coll=e,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=new Un.reqClass(this._db.config)}return t.prototype.get=function(t){t=t||ot();var e=[];this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)}));var n={collectionName:this._coll,queryType:s.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),e.length>0&&(n.order=e),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n={data:C.formatResDocumentData(e.data.list),requestId:e.requestId};e.total&&(n.total=e.total),e.limit&&(n.limit=e.limit),e.offset&&(n.offset=e.offset),t(0,n)}})).catch((function(e){t(e)})),t.promise},t.prototype.count=function(t){t=t||ot();var e={collectionName:this._coll,queryType:s.WHERE};return this._fieldFilters&&(e.query=this._fieldFilters),this._request.send("database.countDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,total:e.data.total})})).catch((function(e){t(e)})),t.promise},t.prototype.where=function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(e),r=n.some((function(t){return void 0!==e[t]}));if(n.length&&!r)throw Error(o.QueryParamValueError);return new t(this._db,this._coll,Rt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){k.isFieldPath(e),k.isFieldOrder(n);var r={field:e,direction:n},o=this._fieldOrders.concat(r);return new t(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){k.isInteger("limit",e);var n=Dt({},this._queryOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){k.isInteger("offset",e);var n=Dt({},this._queryOptions);return n.offset=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.update=function(t,e){if(e=e||ot(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:s.WHERE,multi:!0,merge:!0,upsert:!1,data:jt.encode(t)};return this._request.send("database.updateDocument",n).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,updated:t.data.updated,upsertId:t.data.upsert_id})})).catch((function(t){e(t)})),e.promise},t.prototype.field=function(e){for(var n in e)e[n]?"object"!=typeof e[n]&&(e[n]=1):e[n]=0;var r=Dt({},this._queryOptions);return r.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.remove=function(t){t=t||ot(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var e={collectionName:this._coll,query:Rt.encode(this._fieldFilters),queryType:s.WHERE,multi:!0};return this._request.send("database.deleteDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,deleted:e.data.deleted})})).catch((function(e){t(e)})),t.promise},t}(),Ct=[],kt=[],Jt="undefined"!=typeof Uint8Array?Uint8Array:Array,Ft="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Vt=0;Vt<64;++Vt)Ct[Vt]=Ft[Vt],kt[Ft.charCodeAt(Vt)]=Vt;function Ht(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function Gt(t,e,n){for(var r,o,i=[],u=e;u<n;u+=3)r=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),i.push(Ct[(o=r)>>18&63]+Ct[o>>12&63]+Ct[o>>6&63]+Ct[63&o]);return i.join("")}kt["-".charCodeAt(0)]=62,kt["_".charCodeAt(0)]=63;var Zt=function(t){var e,n,r=Ht(t),o=r[0],i=r[1],u=new Jt(function(t,e,n){return 3*(e+n)/4-n}(0,o,i)),s=0,a=i>0?o-4:o;for(n=0;n<a;n+=4)e=kt[t.charCodeAt(n)]<<18|kt[t.charCodeAt(n+1)]<<12|kt[t.charCodeAt(n+2)]<<6|kt[t.charCodeAt(n+3)],u[s++]=e>>16&255,u[s++]=e>>8&255,u[s++]=255&e;return 2===i&&(e=kt[t.charCodeAt(n)]<<2|kt[t.charCodeAt(n+1)]>>4,u[s++]=255&e),1===i&&(e=kt[t.charCodeAt(n)]<<10|kt[t.charCodeAt(n+1)]<<4|kt[t.charCodeAt(n+2)]>>2,u[s++]=e>>8&255,u[s++]=255&e),u},Yt=function(t){for(var e,n=t.length,r=n%3,o=[],i=16383,u=0,s=n-r;u<s;u+=i)o.push(Gt(t,u,u+i>s?s:u+i));return 1===r?(e=t[n-1],o.push(Ct[e>>2]+Ct[e<<4&63]+"==")):2===r&&(e=(t[n-2]<<8)+t[n-1],o.push(Ct[e>>10]+Ct[e>>4&63]+Ct[e<<2&63]+"=")),o.join("")},Wt=function(t,e,n,r,o){var i,u,s=8*o-r-1,a=(1<<s)-1,f=a>>1,c=-7,h=n?o-1:0,p=n?-1:1,l=t[e+h];for(h+=p,i=l&(1<<-c)-1,l>>=-c,c+=s;c>0;i=256*i+t[e+h],h+=p,c-=8);for(u=i&(1<<-c)-1,i>>=-c,c+=r;c>0;u=256*u+t[e+h],h+=p,c-=8);if(0===i)i=1-f;else{if(i===a)return u?NaN:1/0*(l?-1:1);u+=Math.pow(2,r),i-=f}return(l?-1:1)*u*Math.pow(2,i-r)},Qt=function(t,e,n,r,o,i){var u,s,a,f=8*i-o-1,c=(1<<f)-1,h=c>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=r?0:i-1,d=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,u=c):(u=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-u))<1&&(u--,a*=2),(e+=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=(e*a-1)*Math.pow(2,o),u+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,o),u=0));o>=8;t[n+l]=255&s,l+=d,s/=256,o-=8);for(u=u<<o|s,f+=o;f>0;t[n+l]=255&u,l+=d,u/=256,f-=8);t[n+l-d]|=128*y},zt=function(t,e){return function(t,e){var n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=i,e.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},e.INSPECT_MAX_BYTES=50;var r=2147483647;function o(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,i.prototype),e}function i(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return u(t,e,n)}function u(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!i.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var n=0|p(t,e),r=o(n),u=r.write(t,e);return u!==n&&(r=r.slice(0,u)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(D(t,Uint8Array)){var e=new Uint8Array(t);return c(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t));if(D(t,ArrayBuffer)||t&&D(t.buffer,ArrayBuffer))return c(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(D(t,SharedArrayBuffer)||t&&D(t.buffer,SharedArrayBuffer)))return c(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return i.from(r,e,n);var u=function(t){if(i.isBuffer(t)){var e=0|h(t.length),n=o(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||q(t.length)?o(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(u)return u;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return i.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t))}function s(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return s(t),o(t<0?0:0|h(t))}function f(t){for(var e=t.length<0?0:0|h(t.length),n=o(e),r=0;r<e;r+=1)n[r]=255&t[r];return n}function c(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,i.prototype),r}function h(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function p(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||D(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+babelHelpers.typeof(t));var n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return $(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return R(t).length;default:if(o)return r?-1:$(t).length;e=(""+e).toLowerCase(),o=!0}}function l(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return N(this,e,n);case"latin1":case"binary":return x(this,e,n);case"base64":return E(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function d(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function y(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),q(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=i.from(e,r)),i.isBuffer(e))return 0===e.length?-1:g(t,e,n,r,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):g(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,n,r,o){var i,u=1,s=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;u=2,s/=2,a/=2,n/=2}function f(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(o){var c=-1;for(i=n;i<s;i++)if(f(t,i)===f(e,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===a)return c*u}else-1!==c&&(i-=i-c),c=-1}else for(n+a>s&&(n=s-a),i=n;i>=0;i--){for(var h=!0,p=0;p<a;p++)if(f(t,i+p)!==f(e,p)){h=!1;break}if(h)return i}return-1}function m(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=e.length;r>i/2&&(r=i/2);for(var u=0;u<r;++u){var s=parseInt(e.substr(2*u,2),16);if(q(s))return u;t[n+u]=s}return u}function w(t,e,n,r){return M($(e,t.length-n),t,n,r)}function b(t,e,n,r){return M(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function v(t,e,n,r){return M(R(e),t,n,r)}function _(t,e,n,r){return M(function(t,e){for(var n,r,o,i=[],u=0;u<t.length&&!((e-=2)<0);++u)r=(n=t.charCodeAt(u))>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function E(t,e,n){return 0===e&&n===t.length?Yt(t):Yt(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o<n;){var i,u,s,a,f=t[o],c=null,h=f>239?4:f>223?3:f>191?2:1;if(o+h<=n)switch(h){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(a=(31&f)<<6|63&i)>127&&(c=a);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(a=(15&f)<<12|(63&i)<<6|63&u)>2047&&(a<55296||a>57343)&&(c=a);break;case 4:i=t[o+1],u=t[o+2],s=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&s)&&(a=(15&f)<<18|(63&i)<<12|(63&u)<<6|63&s)>65535&&a<1114112&&(c=a)}null===c?(c=65533,h=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),o+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);for(var n="",r=0;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=S));return n}(r)}e.kMaxLength=r,i.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(t,e,n){return u(t,e,n)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,e,n){return function(t,e,n){return s(t),t<=0?o(t):void 0!==e?"string"==typeof n?o(t).fill(e,n):o(t).fill(e):o(t)}(t,e,n)},i.allocUnsafe=function(t){return a(t)},i.allocUnsafeSlow=function(t){return a(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(D(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),D(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,r=e.length,o=0,u=Math.min(n,r);o<u;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},i.isEncoding=function(t){switch(String(t).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}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=i.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var u=t[n];if(D(u,Uint8Array))o+u.length>r.length?i.from(u).copy(r,o):Uint8Array.prototype.set.call(r,u,o);else{if(!i.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(r,o)}o+=u.length}return r},i.byteLength=p,i.prototype._isBuffer=!0,i.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)d(this,e,e+1);return this},i.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)d(this,e,e+3),d(this,e+1,e+2);return this},i.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},i.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?O(this,0,t):l.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(i.prototype[n]=i.prototype.inspect),i.prototype.compare=function(t,e,n,r,o){if(D(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+babelHelpers.typeof(t));if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var u=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(e>>>=0),a=Math.min(u,s),f=this.slice(r,o),c=t.slice(e,n),h=0;h<a;++h)if(f[h]!==c[h]){u=f[h],s=c[h];break}return u<s?-1:s<u?1:0},i.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},i.prototype.indexOf=function(t,e,n){return y(this,t,e,n,!0)},i.prototype.lastIndexOf=function(t,e,n){return y(this,t,e,n,!1)},i.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return b(this,t,e,n);case"base64":return v(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function N(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function x(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function I(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=e;i<n;++i)o+=C[t[i]];return o}function T(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length-1;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function A(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,n,r,o,u){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<u)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function j(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function P(t,e,n,r,o){return e=+e,n>>>=0,o||j(t,0,n,4),Qt(t,e,n,r,23,4),n+4}function L(t,e,n,r,o){return e=+e,n>>>=0,o||j(t,0,n,8),Qt(t,e,n,r,52,8),n+8}i.prototype.slice=function(t,e){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r=this.subarray(t,e);return Object.setPrototypeOf(r,i.prototype),r},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||A(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||A(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||A(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||A(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||A(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||A(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||A(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||A(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},i.prototype.readInt8=function(t,e){return t>>>=0,e||A(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||A(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(t,e){t>>>=0,e||A(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||A(t,4,this.length),Wt(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||A(t,4,this.length),Wt(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||A(t,8,this.length),Wt(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||A(t,8,this.length),Wt(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||B(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||B(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);B(this,t,e,n,o-1,-o)}var i=0,u=1,s=0;for(this[e]=255&t;++i<n&&(u*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/u|0)-s&255;return e+n},i.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);B(this,t,e,n,o-1,-o)}var i=n-1,u=1,s=0;for(this[e+i]=255&t;--i>=0&&(u*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/u|0)-s&255;return e+n},i.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,n){return P(this,t,e,!0,n)},i.prototype.writeFloatBE=function(t,e,n){return P(this,t,e,!1,n)},i.prototype.writeDoubleLE=function(t,e,n){return L(this,t,e,!0,n)},i.prototype.writeDoubleBE=function(t,e,n){return L(this,t,e,!1,n)},i.prototype.copy=function(t,e,n,r){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),o},i.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!i.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){var o=t.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var u;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(u=e;u<n;++u)this[u]=t;else{var s=i.isBuffer(t)?t:i.from(t,r),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(u=0;u<n-e;++u)this[u+e]=s[u%a]}return this};var U=/[^+/0-9A-Za-z-_]/g;function $(t,e){var n;e=e||1/0;for(var r=t.length,o=null,i=[],u=0;u<r;++u){if((n=t.charCodeAt(u))>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(u+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function R(t){return Zt(function(t){if((t=(t=t.split("=")[0]).trim().replace(U,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function M(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function D(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function q(t){return t!=t}var C=function(){for(var t="0123456789abcdef",e=new Array(256),n=0;n<16;++n)for(var r=16*n,o=0;o<16;++o)e[r+o]=t[n]+t[o];return e}()}(e={exports:{}},e.exports),e.exports}(),Xt=zt.Buffer;zt.SlowBuffer,zt.INSPECT_MAX_BYTES,zt.kMaxLength;var Kt=function(t,e){return Kt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},Kt(t,e)};function te(t,e){function n(){this.constructor=t}Kt(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var ee=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return te(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),e}(Error),ne=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return te(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),e}(TypeError);function re(t){return t&&t.Math==Math&&t}function oe(){return re("object"==typeof globalThis&&globalThis)||re("object"==typeof window&&window)||re("object"==typeof self&&self)||re("object"==typeof n.g&&n.g)||Function("return this")()}var ie=function(t){var e,n="object"==typeof(e=oe()).navigator&&"ReactNative"===e.navigator.product?"BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.":"BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.";console.warn(n);for(var r=Xt.alloc(t),o=0;o<t;++o)r[o]=Math.floor(256*Math.random());return r},ue=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(t&&t.getRandomValues)return function(e){return t.getRandomValues(Xt.alloc(e))}}return void 0!==n.g&&n.g.crypto&&n.g.crypto.getRandomValues?function(t){return n.g.crypto.getRandomValues(Xt.alloc(t))}:ie}();function se(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function ae(t){return"object"==typeof t&&null!==t}function fe(t,e){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return n||(console.warn(e),n=!0),t.apply(this,r)}}function ce(t){if(ArrayBuffer.isView(t))return Xt.from(t.buffer,t.byteOffset,t.byteLength);if(e=t,["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e)))return Xt.from(t);var e;throw new ne("Must use either Buffer or TypedArray")}var he=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i,pe=function(t){return"string"==typeof t&&he.test(t)},le=function(t){if(!pe(t))throw new ne('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var e=t.replace(/-/g,"");return Xt.from(e,"hex")},de=function(t,e){return void 0===e&&(e=!0),e?t.toString("hex",0,4)+"-"+t.toString("hex",4,6)+"-"+t.toString("hex",6,8)+"-"+t.toString("hex",8,10)+"-"+t.toString("hex",10,16):t.toString("hex")},ye=(Math.pow(2,63),Math.pow(2,63),Math.pow(2,53)),ge=-Math.pow(2,53),me=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(!(null==e||"string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Array.isArray(e)))throw new ne("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=n?n:t.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=Xt.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=Xt.from(e,"binary"):Array.isArray(e)?this.buffer=Xt.from(e):this.buffer=ce(e),this.position=this.buffer.byteLength)}return t.prototype.put=function(e){if("string"==typeof e&&1!==e.length)throw new ne("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new ne("only accepts single character Uint8Array or Array");var n;if((n="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0])<0||n>255)throw new ne("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=n;else{var r=Xt.alloc(t.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=n}},t.prototype.write=function(t,e){if(e="number"==typeof e?e:this.position,this.buffer.length<e+t.length){var n=Xt.alloc(this.buffer.length+t.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n}ArrayBuffer.isView(t)?(this.buffer.set(ce(t),e),this.position=e+t.byteLength>this.position?e+t.length:this.position):"string"==typeof t&&(this.buffer.write(t,e,t.length,"binary"),this.position=e+t.length>this.position?e+t.length:this.position)},t.prototype.read=function(t,e){return e=e&&e>0?e:this.position,this.buffer.slice(t,t+e)},t.prototype.value=function(t){return(t=!!t)&&this.buffer.length===this.position?this.buffer:t?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)},t.prototype.length=function(){return this.position},t.prototype.toJSON=function(){return this.buffer.toString("base64")},t.prototype.toString=function(t){return this.buffer.toString(t)},t.prototype.toExtendedJSON=function(t){t=t||{};var e=this.buffer.toString("base64"),n=Number(this.sub_type).toString(16);return t.legacy?{$binary:e,$type:1===n.length?"0"+n:n}:{$binary:{base64:e,subType:1===n.length?"0"+n:n}}},t.prototype.toUUID=function(){if(this.sub_type===t.SUBTYPE_UUID)return new we(this.buffer.slice(0,this.position));throw new ee('Binary sub_type "'.concat(this.sub_type,'" is not supported for converting to UUID. Only "').concat(t.SUBTYPE_UUID,'" is currently supported.'))},t.fromExtendedJSON=function(e,n){var r,o;if(n=n||{},"$binary"in e?n.legacy&&"string"==typeof e.$binary&&"$type"in e?(o=e.$type?parseInt(e.$type,16):0,r=Xt.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=Xt.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,r=le(e.$uuid)),!r)throw new ne("Unexpected Binary Extended JSON format ".concat(JSON.stringify(e)));return 4===o?new we(r):new t(r,o)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.value(!0);return'new Binary(Buffer.from("'.concat(t.toString("hex"),'", "hex"), ').concat(this.sub_type,")")},t.BSON_BINARY_SUBTYPE_DEFAULT=0,t.BUFFER_SIZE=256,t.SUBTYPE_DEFAULT=0,t.SUBTYPE_FUNCTION=1,t.SUBTYPE_BYTE_ARRAY=2,t.SUBTYPE_UUID_OLD=3,t.SUBTYPE_UUID=4,t.SUBTYPE_MD5=5,t.SUBTYPE_ENCRYPTED=6,t.SUBTYPE_COLUMN=7,t.SUBTYPE_USER_DEFINED=128,t}();Object.defineProperty(me.prototype,"_bsontype",{value:"Binary"});var we=function(t){function e(n){var r,o,i=this;if(null==n)r=e.generate();else if(n instanceof e)r=Xt.from(n.buffer),o=n.__id;else if(ArrayBuffer.isView(n)&&16===n.byteLength)r=ce(n);else{if("string"!=typeof n)throw new ne("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");r=le(n)}return(i=t.call(this,r,4)||this).__id=o,i}return te(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.buffer},set:function(t){this.buffer=t,e.cacheHexString&&(this.__id=de(t))},enumerable:!1,configurable:!0}),e.prototype.toHexString=function(t){if(void 0===t&&(t=!0),e.cacheHexString&&this.__id)return this.__id;var n=de(this.id,t);return e.cacheHexString&&(this.__id=n),n},e.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},e.prototype.toJSON=function(){return this.toHexString()},e.prototype.equals=function(t){if(!t)return!1;if(t instanceof e)return t.id.equals(this.id);try{return new e(t).id.equals(this.id)}catch(t){return!1}},e.prototype.toBinary=function(){return new me(this.id,me.SUBTYPE_UUID)},e.generate=function(){var t=ue(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,Xt.from(t)},e.isValid=function(t){return!!t&&(t instanceof e||("string"==typeof t?pe(t):!(!se(t)||16!==t.length||64!=(240&t[6])||128&~t[8])))},e.createFromHexString=function(t){return new e(le(t))},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},e}(me),be=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);this.code=e,this.scope=n}return t.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},t.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},t.fromExtendedJSON=function(e){return new t(e.$code,e.$scope)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toJSON();return'new Code("'.concat(String(t.code),'"').concat(t.scope?", ".concat(JSON.stringify(t.scope)):"",")")},t}();Object.defineProperty(be.prototype,"_bsontype",{value:"Code"});var ve=function(){function t(e,n,r,o){if(!(this instanceof t))return new t(e,n,r,o);var i=e.split(".");2===i.length&&(r=i.shift(),e=i.shift()),this.collection=e,this.oid=n,this.db=r,this.fields=o||{}}return Object.defineProperty(t.prototype,"namespace",{get:function(){return this.collection},set:function(t){this.collection=t},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){var t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(t.$db=this.db),t},t.prototype.toExtendedJSON=function(t){t=t||{};var e={$ref:this.collection,$id:this.oid};return t.legacy?e:(this.db&&(e.$db=this.db),e=Object.assign(e,this.fields))},t.fromExtendedJSON=function(e){var n=Object.assign({},e);return delete n.$ref,delete n.$id,delete n.$db,new t(e.$ref,e.$id,e.$db,n)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return'new DBRef("'.concat(this.namespace,'", new ObjectId("').concat(String(t),'")').concat(this.db?', "'.concat(this.db,'"'):"",")")},t}();Object.defineProperty(ve.prototype,"_bsontype",{value:"DBRef"});var _e=void 0;try{_e=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(r){}var Ee=4294967296,Oe=0x10000000000000000,Se=Oe/2,Ne={},xe={},Ie=function(){function t(e,n,r){if(void 0===e&&(e=0),!(this instanceof t))return new t(e,n,r);"bigint"==typeof e?Object.assign(this,t.fromBigInt(e,!!n)):"string"==typeof e?Object.assign(this,t.fromString(e,!!n)):(this.low=0|e,this.high=0|n,this.unsigned=!!r),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return t.fromBits=function(e,n,r){return new t(e,n,r)},t.fromInt=function(e,n){var r,o,i;return n?(i=0<=(e>>>=0)&&e<256)&&(o=xe[e])?o:(r=t.fromBits(e,(0|e)<0?-1:0,!0),i&&(xe[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(o=Ne[e])?o:(r=t.fromBits(e,e<0?-1:0,!1),i&&(Ne[e]=r),r)},t.fromNumber=function(e,n){if(isNaN(e))return n?t.UZERO:t.ZERO;if(n){if(e<0)return t.UZERO;if(e>=Oe)return t.MAX_UNSIGNED_VALUE}else{if(e<=-Se)return t.MIN_VALUE;if(e+1>=Se)return t.MAX_VALUE}return e<0?t.fromNumber(-e,n).neg():t.fromBits(e%Ee|0,e/Ee|0,n)},t.fromBigInt=function(e,n){return t.fromString(e.toString(),n)},t.fromString=function(e,n,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t.ZERO;if("number"==typeof n?(r=n,n=!1):n=!!n,(r=r||10)<2||36<r)throw RangeError("radix");var o;if((o=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===o)return t.fromString(e.substring(1),n,r).neg();for(var i=t.fromNumber(Math.pow(r,8)),u=t.ZERO,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),f=parseInt(e.substring(s,s+a),r);if(a<8){var c=t.fromNumber(Math.pow(r,a));u=u.mul(c).add(t.fromNumber(f))}else u=(u=u.mul(i)).add(t.fromNumber(f))}return u.unsigned=n,u},t.fromBytes=function(e,n,r){return r?t.fromBytesLE(e,n):t.fromBytesBE(e,n)},t.fromBytesLE=function(e,n){return new t(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)},t.fromBytesBE=function(e,n){return new t(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)},t.isLong=function(t){return ae(t)&&!0===t.__isLong__},t.fromValue=function(e,n){return"number"==typeof e?t.fromNumber(e,n):"string"==typeof e?t.fromString(e,n):t.fromBits(e.low,e.high,"boolean"==typeof n?n:e.unsigned)},t.prototype.add=function(e){t.isLong(e)||(e=t.fromValue(e));var n=this.high>>>16,r=65535&this.high,o=this.low>>>16,i=65535&this.low,u=e.high>>>16,s=65535&e.high,a=e.low>>>16,f=0,c=0,h=0,p=0;return h+=(p+=i+(65535&e.low))>>>16,p&=65535,c+=(h+=o+a)>>>16,h&=65535,f+=(c+=r+s)>>>16,c&=65535,f+=n+u,f&=65535,t.fromBits(h<<16|p,f<<16|c,this.unsigned)},t.prototype.and=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low&e.low,this.high&e.high,this.unsigned)},t.prototype.compare=function(e){if(t.isLong(e)||(e=t.fromValue(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&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},t.prototype.comp=function(t){return this.compare(t)},t.prototype.divide=function(e){if(t.isLong(e)||(e=t.fromValue(e)),e.isZero())throw Error("division by zero");if(_e){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;var n=(this.unsigned?_e.div_u:_e.div_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,_e.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?t.UZERO:t.ZERO;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return t.UZERO;if(e.gt(this.shru(1)))return t.UONE;i=t.UZERO}else{if(this.eq(t.MIN_VALUE))return e.eq(t.ONE)||e.eq(t.NEG_ONE)?t.MIN_VALUE:e.eq(t.MIN_VALUE)?t.ONE:(r=this.shr(1).div(e).shl(1)).eq(t.ZERO)?e.isNegative()?t.ONE:t.NEG_ONE:(o=this.sub(e.mul(r)),i=r.add(o.div(e)));if(e.eq(t.MIN_VALUE))return this.unsigned?t.UZERO:t.ZERO;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();i=t.ZERO}for(o=this;o.gte(e);){r=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var u=Math.ceil(Math.log(r)/Math.LN2),s=u<=48?1:Math.pow(2,u-48),a=t.fromNumber(r),f=a.mul(e);f.isNegative()||f.gt(o);)r-=s,f=(a=t.fromNumber(r,this.unsigned)).mul(e);a.isZero()&&(a=t.ONE),i=i.add(a),o=o.sub(f)}return i},t.prototype.div=function(t){return this.divide(t)},t.prototype.equals=function(e){return t.isLong(e)||(e=t.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},t.prototype.eq=function(t){return this.equals(t)},t.prototype.getHighBits=function(){return this.high},t.prototype.getHighBitsUnsigned=function(){return this.high>>>0},t.prototype.getLowBits=function(){return this.low},t.prototype.getLowBitsUnsigned=function(){return this.low>>>0},t.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(t.MIN_VALUE)?64:this.neg().getNumBitsAbs();var e,n=0!==this.high?this.high:this.low;for(e=31;e>0&&!(n&1<<e);e--);return 0!==this.high?e+33:e+1},t.prototype.greaterThan=function(t){return this.comp(t)>0},t.prototype.gt=function(t){return this.greaterThan(t)},t.prototype.greaterThanOrEqual=function(t){return this.comp(t)>=0},t.prototype.gte=function(t){return this.greaterThanOrEqual(t)},t.prototype.ge=function(t){return this.greaterThanOrEqual(t)},t.prototype.isEven=function(){return!(1&this.low)},t.prototype.isNegative=function(){return!this.unsigned&&this.high<0},t.prototype.isOdd=function(){return!(1&~this.low)},t.prototype.isPositive=function(){return this.unsigned||this.high>=0},t.prototype.isZero=function(){return 0===this.high&&0===this.low},t.prototype.lessThan=function(t){return this.comp(t)<0},t.prototype.lt=function(t){return this.lessThan(t)},t.prototype.lessThanOrEqual=function(t){return this.comp(t)<=0},t.prototype.lte=function(t){return this.lessThanOrEqual(t)},t.prototype.modulo=function(e){if(t.isLong(e)||(e=t.fromValue(e)),_e){var n=(this.unsigned?_e.rem_u:_e.rem_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,_e.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},t.prototype.mod=function(t){return this.modulo(t)},t.prototype.rem=function(t){return this.modulo(t)},t.prototype.multiply=function(e){if(this.isZero())return t.ZERO;if(t.isLong(e)||(e=t.fromValue(e)),_e){var n=_e.mul(this.low,this.high,e.low,e.high);return t.fromBits(n,_e.get_high(),this.unsigned)}if(e.isZero())return t.ZERO;if(this.eq(t.MIN_VALUE))return e.isOdd()?t.MIN_VALUE:t.ZERO;if(e.eq(t.MIN_VALUE))return this.isOdd()?t.MIN_VALUE:t.ZERO;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(t.TWO_PWR_24)&&e.lt(t.TWO_PWR_24))return t.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,o=65535&this.high,i=this.low>>>16,u=65535&this.low,s=e.high>>>16,a=65535&e.high,f=e.low>>>16,c=65535&e.low,h=0,p=0,l=0,d=0;return l+=(d+=u*c)>>>16,d&=65535,p+=(l+=i*c)>>>16,l&=65535,p+=(l+=u*f)>>>16,l&=65535,h+=(p+=o*c)>>>16,p&=65535,h+=(p+=i*f)>>>16,p&=65535,h+=(p+=u*a)>>>16,p&=65535,h+=r*c+o*f+i*a+u*s,h&=65535,t.fromBits(l<<16|d,h<<16|p,this.unsigned)},t.prototype.mul=function(t){return this.multiply(t)},t.prototype.negate=function(){return!this.unsigned&&this.eq(t.MIN_VALUE)?t.MIN_VALUE:this.not().add(t.ONE)},t.prototype.neg=function(){return this.negate()},t.prototype.not=function(){return t.fromBits(~this.low,~this.high,this.unsigned)},t.prototype.notEquals=function(t){return!this.equals(t)},t.prototype.neq=function(t){return this.notEquals(t)},t.prototype.ne=function(t){return this.notEquals(t)},t.prototype.or=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low|e.low,this.high|e.high,this.unsigned)},t.prototype.shiftLeft=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):t.fromBits(0,this.low<<e-32,this.unsigned)},t.prototype.shl=function(t){return this.shiftLeft(t)},t.prototype.shiftRight=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):t.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},t.prototype.shr=function(t){return this.shiftRight(t)},t.prototype.shiftRightUnsigned=function(e){if(t.isLong(e)&&(e=e.toInt()),0==(e&=63))return this;var n=this.high;if(e<32){var r=this.low;return t.fromBits(r>>>e|n<<32-e,n>>>e,this.unsigned)}return 32===e?t.fromBits(n,0,this.unsigned):t.fromBits(n>>>e-32,0,this.unsigned)},t.prototype.shr_u=function(t){return this.shiftRightUnsigned(t)},t.prototype.shru=function(t){return this.shiftRightUnsigned(t)},t.prototype.subtract=function(e){return t.isLong(e)||(e=t.fromValue(e)),this.add(e.neg())},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},t.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*Ee+(this.low>>>0):this.high*Ee+(this.low>>>0)},t.prototype.toBigInt=function(){return BigInt(this.toString())},t.prototype.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},t.prototype.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},t.prototype.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},t.prototype.toSigned=function(){return this.unsigned?t.fromBits(this.low,this.high,!1):this},t.prototype.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(t.MIN_VALUE)){var n=t.fromNumber(e),r=this.div(n),o=r.mul(n).sub(this);return r.toString(e)+o.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=t.fromNumber(Math.pow(e,6),this.unsigned),u=this,s="";;){var a=u.div(i),f=(u.sub(a.mul(i)).toInt()>>>0).toString(e);if((u=a).isZero())return f+s;for(;f.length<6;)f="0"+f;s=""+f+s}},t.prototype.toUnsigned=function(){return this.unsigned?this:t.fromBits(this.low,this.high,!0)},t.prototype.xor=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low^e.low,this.high^e.high,this.unsigned)},t.prototype.eqz=function(){return this.isZero()},t.prototype.le=function(t){return this.lessThanOrEqual(t)},t.prototype.toExtendedJSON=function(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}},t.fromExtendedJSON=function(e,n){var r=t.fromString(e.$numberLong);return n&&n.relaxed?r.toNumber():r},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Long("'.concat(this.toString(),'"').concat(this.unsigned?", true":"",")")},t.TWO_PWR_24=t.fromInt(16777216),t.MAX_UNSIGNED_VALUE=t.fromBits(-1,-1,!0),t.ZERO=t.fromInt(0),t.UZERO=t.fromInt(0,!0),t.ONE=t.fromInt(1),t.UONE=t.fromInt(1,!0),t.NEG_ONE=t.fromInt(-1),t.MAX_VALUE=t.fromBits(-1,2147483647,!1),t.MIN_VALUE=t.fromBits(0,-2147483648,!1),t}();Object.defineProperty(Ie.prototype,"__isLong__",{value:!0}),Object.defineProperty(Ie.prototype,"_bsontype",{value:"Long"});var Te=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Ae=/^(\+|-)?(Infinity|inf)$/i,Be=/^(\+|-)?NaN$/i,je=6111,Pe=-6176,Le=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),Ue=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),$e=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),Re=/^([-+])?(\d+)?$/;function Me(t){return!isNaN(parseInt(t,10))}function De(t){var e=Ie.fromNumber(1e9),n=Ie.fromNumber(0);if(!(t.parts[0]||t.parts[1]||t.parts[2]||t.parts[3]))return{quotient:t,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new Ie(t.parts[r],0)),t.parts[r]=n.div(e).low,n=n.modulo(e);return{quotient:t,rem:n}}function qe(t,e){throw new ne('"'.concat(t,'" is not a valid Decimal128 string - ').concat(e))}var Ce=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!se(e))throw new ne("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new ne("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(e){var n,r=!1,o=!1,i=!1,u=0,s=0,a=0,f=0,c=0,h=[0],p=0,l=0,d=0,y=0,g=0,m=0,w=new Ie(0,0),b=new Ie(0,0),v=0;if(e.length>=7e3)throw new ne(e+" not a valid Decimal128 string");var _=e.match(Te),E=e.match(Ae),O=e.match(Be);if(!_&&!E&&!O||0===e.length)throw new ne(e+" not a valid Decimal128 string");if(_){var S=_[2],N=_[4],x=_[5],I=_[6];N&&void 0===I&&qe(e,"missing exponent power"),N&&void 0===S&&qe(e,"missing exponent base"),void 0===N&&(x||I)&&qe(e,"missing e before exponent")}if("+"!==e[v]&&"-"!==e[v]||(r="-"===e[v++]),!Me(e[v])&&"."!==e[v]){if("i"===e[v]||"I"===e[v])return new t(Xt.from(r?Ue:$e));if("N"===e[v])return new t(Xt.from(Le))}for(;Me(e[v])||"."===e[v];)"."!==e[v]?(p<34&&("0"!==e[v]||i)&&(i||(c=s),i=!0,h[l++]=parseInt(e[v],10),p+=1),i&&(a+=1),o&&(f+=1),s+=1,v+=1):(o&&qe(e,"contains multiple periods"),o=!0,v+=1);if(o&&!s)throw new ne(e+" not a valid Decimal128 string");if("e"===e[v]||"E"===e[v]){var T=e.substr(++v).match(Re);if(!T||!T[2])return new t(Xt.from(Le));g=parseInt(T[0],10),v+=T[0].length}if(e[v])return new t(Xt.from(Le));if(d=0,p){if(y=p-1,1!==(u=a))for(;0===h[c+u-1];)u-=1}else d=0,y=0,h[0]=0,a=1,p=1,u=0;for(g<=f&&f-g>16384?g=Pe:g-=f;g>je;){if((y+=1)-d>34){if(h.join("").match(/^0+$/)){g=je;break}qe(e,"overflow")}g-=1}for(;g<Pe||p<a;){if(0===y&&u<p){g=Pe,u=0;break}if(p<a?a-=1:y-=1,g<je)g+=1;else{if(h.join("").match(/^0+$/)){g=je;break}qe(e,"overflow")}}if(y-d+1<u){var A=s;o&&(c+=1,A+=1),r&&(c+=1,A+=1);var B=parseInt(e[c+y+1],10),j=0;if(B>=5&&(j=1,5===B))for(j=h[y]%2==1?1:0,m=c+y+2;m<A;m++)if(parseInt(e[m],10)){j=1;break}if(j)for(var P=y;P>=0;P--)if(++h[P]>9&&(h[P]=0,0===P)){if(!(g<je))return new t(Xt.from(r?Ue:$e));g+=1,h[P]=1}}if(w=Ie.fromNumber(0),b=Ie.fromNumber(0),0===u)w=Ie.fromNumber(0),b=Ie.fromNumber(0);else if(y-d<17)for(P=d,b=Ie.fromNumber(h[P++]),w=new Ie(0,0);P<=y;P++)b=(b=b.multiply(Ie.fromNumber(10))).add(Ie.fromNumber(h[P]));else{for(P=d,w=Ie.fromNumber(h[P++]);P<=y-17;P++)w=(w=w.multiply(Ie.fromNumber(10))).add(Ie.fromNumber(h[P]));for(b=Ie.fromNumber(h[P++]);P<=y;P++)b=(b=b.multiply(Ie.fromNumber(10))).add(Ie.fromNumber(h[P]))}var L,U,$,R,M=function(t,e){if(!t&&!e)return{high:Ie.fromNumber(0),low:Ie.fromNumber(0)};var n=t.shiftRightUnsigned(32),r=new Ie(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new Ie(e.getLowBits(),0),u=n.multiply(o),s=n.multiply(i),a=r.multiply(o),f=r.multiply(i);return u=u.add(s.shiftRightUnsigned(32)),s=new Ie(s.getLowBits(),0).add(a).add(f.shiftRightUnsigned(32)),{high:u=u.add(s.shiftRightUnsigned(32)),low:f=s.shiftLeft(32).add(new Ie(f.getLowBits(),0))}}(w,Ie.fromString("100000000000000000"));M.low=M.low.add(b),U=b,(($=(L=M.low).high>>>0)<(R=U.high>>>0)||$===R&&L.low>>>0<U.low>>>0)&&(M.high=M.high.add(Ie.fromNumber(1))),n=g+6176;var D={low:Ie.fromNumber(0),high:Ie.fromNumber(0)};M.high.shiftRightUnsigned(49).and(Ie.fromNumber(1)).equals(Ie.fromNumber(1))?(D.high=D.high.or(Ie.fromNumber(3).shiftLeft(61)),D.high=D.high.or(Ie.fromNumber(n).and(Ie.fromNumber(16383).shiftLeft(47))),D.high=D.high.or(M.high.and(Ie.fromNumber(0x7fffffffffff)))):(D.high=D.high.or(Ie.fromNumber(16383&n).shiftLeft(49)),D.high=D.high.or(M.high.and(Ie.fromNumber(562949953421311)))),D.low=M.low,r&&(D.high=D.high.or(Ie.fromString("9223372036854775808")));var q=Xt.alloc(16);return v=0,q[v++]=255&D.low.low,q[v++]=D.low.low>>8&255,q[v++]=D.low.low>>16&255,q[v++]=D.low.low>>24&255,q[v++]=255&D.low.high,q[v++]=D.low.high>>8&255,q[v++]=D.low.high>>16&255,q[v++]=D.low.high>>24&255,q[v++]=255&D.high.low,q[v++]=D.high.low>>8&255,q[v++]=D.high.low>>16&255,q[v++]=D.high.low>>24&255,q[v++]=255&D.high.high,q[v++]=D.high.high>>8&255,q[v++]=D.high.high>>16&255,q[v++]=D.high.high>>24&255,new t(q)},t.prototype.toString=function(){for(var t,e=0,n=new Array(36),r=0;r<n.length;r++)n[r]=0;var o,i,u,s=0,a=!1,f={parts:[0,0,0,0]},c=[];s=0;var h=this.bytes,p=h[s++]|h[s++]<<8|h[s++]<<16|h[s++]<<24,l=h[s++]|h[s++]<<8|h[s++]<<16|h[s++]<<24,d=h[s++]|h[s++]<<8|h[s++]<<16|h[s++]<<24,y=h[s++]|h[s++]<<8|h[s++]<<16|h[s++]<<24;s=0,(new Ie(p,l),new Ie(d,y)).lessThan(Ie.ZERO)&&c.push("-");var g=y>>26&31;if(g>>3==3){if(30===g)return c.join("")+"Infinity";if(31===g)return"NaN";t=y>>15&16383,o=8+(y>>14&1)}else o=y>>14&7,t=y>>17&16383;var m=t-6176;if(f.parts[0]=(16383&y)+((15&o)<<14),f.parts[1]=d,f.parts[2]=l,f.parts[3]=p,0===f.parts[0]&&0===f.parts[1]&&0===f.parts[2]&&0===f.parts[3])a=!0;else for(u=3;u>=0;u--){var w=0,b=De(f);if(f=b.quotient,w=b.rem.low)for(i=8;i>=0;i--)n[9*u+i]=w%10,w=Math.floor(w/10)}if(a)e=1,n[s]=0;else for(e=36;!n[s];)e-=1,s+=1;var v=e-1+m;if(v>=34||v<=-7||m>0){if(e>34)return c.push("".concat(0)),m>0?c.push("E+".concat(m)):m<0&&c.push("E".concat(m)),c.join("");for(c.push("".concat(n[s++])),(e-=1)&&c.push("."),r=0;r<e;r++)c.push("".concat(n[s++]));c.push("E"),v>0?c.push("+".concat(v)):c.push("".concat(v))}else if(m>=0)for(r=0;r<e;r++)c.push("".concat(n[s++]));else{var _=e+m;if(_>0)for(r=0;r<_;r++)c.push("".concat(n[s++]));else c.push("0");for(c.push(".");_++<0;)c.push("0");for(r=0;r<e-Math.max(_-1,0);r++)c.push("".concat(n[s++]))}return c.join("")},t.prototype.toJSON=function(){return{$numberDecimal:this.toString()}},t.prototype.toExtendedJSON=function(){return{$numberDecimal:this.toString()}},t.fromExtendedJSON=function(e){return t.fromString(e.$numberDecimal)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Decimal128("'.concat(this.toString(),'")')},t}();Object.defineProperty(Ce.prototype,"_bsontype",{value:"Decimal128"});var ke=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toJSON=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toExtendedJSON=function(t){return t&&(t.legacy||t.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-".concat(this.value.toFixed(1))}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}},t.fromExtendedJSON=function(e,n){var r=parseFloat(e.$numberDouble);return n&&n.relaxed?r:new t(r)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toExtendedJSON();return"new Double(".concat(t.$numberDouble,")")},t}();Object.defineProperty(ke.prototype,"_bsontype",{value:"Double"});var Je=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=0|+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(t){return t&&(t.relaxed||t.legacy)?this.value:{$numberInt:this.value.toString()}},t.fromExtendedJSON=function(e,n){return n&&n.relaxed?parseInt(e.$numberInt,10):new t(e.$numberInt)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new Int32(".concat(this.valueOf(),")")},t}();Object.defineProperty(Je.prototype,"_bsontype",{value:"Int32"});var Fe=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$maxKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MaxKey()"},t}();Object.defineProperty(Fe.prototype,"_bsontype",{value:"MaxKey"});var Ve=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$minKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MinKey()"},t}();Object.defineProperty(Ve.prototype,"_bsontype",{value:"MinKey"});var He=new RegExp("^[0-9a-fA-F]{24}$"),Ge=null,Ze=Symbol("id"),Ye=function(){function t(e){if(!(this instanceof t))return new t(e);var n;if("object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new ne("Argument passed in must have an id that is of type string or Buffer");n="toHexString"in e&&"function"==typeof e.toHexString?Xt.from(e.toHexString(),"hex"):e.id}else n=e;if(null==n||"number"==typeof n)this[Ze]=t.generate("number"==typeof n?n:void 0);else if(ArrayBuffer.isView(n)&&12===n.byteLength)this[Ze]=n instanceof Xt?n:ce(n);else{if("string"!=typeof n)throw new ne("Argument passed in does not match the accepted types");if(12===n.length){var r=Xt.from(n);if(12!==r.byteLength)throw new ne("Argument passed in must be a string of 12 bytes");this[Ze]=r}else{if(24!==n.length||!He.test(n))throw new ne("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[Ze]=Xt.from(n,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[Ze]},set:function(e){this[Ze]=e,t.cacheHexString&&(this.__id=e.toString("hex"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"generationTime",{get:function(){return this.id.readInt32BE(0)},set:function(t){this.id.writeUInt32BE(t,0)},enumerable:!1,configurable:!0}),t.prototype.toHexString=function(){if(t.cacheHexString&&this.__id)return this.__id;var e=this.id.toString("hex");return t.cacheHexString&&!this.__id&&(this.__id=e),e},t.getInc=function(){return t.index=(t.index+1)%16777215},t.generate=function(e){"number"!=typeof e&&(e=Math.floor(Date.now()/1e3));var n=t.getInc(),r=Xt.alloc(12);return r.writeUInt32BE(e,0),null===Ge&&(Ge=ue(5)),r[4]=Ge[0],r[5]=Ge[1],r[6]=Ge[2],r[7]=Ge[3],r[8]=Ge[4],r[11]=255&n,r[10]=n>>8&255,r[9]=n>>16&255,r},t.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},t.prototype.toJSON=function(){return this.toHexString()},t.prototype.equals=function(e){if(null==e)return!1;if(e instanceof t)return this[Ze][11]===e[Ze][11]&&this[Ze].equals(e[Ze]);if("string"==typeof e&&t.isValid(e)&&12===e.length&&se(this.id))return e===Xt.prototype.toString.call(this.id,"latin1");if("string"==typeof e&&t.isValid(e)&&24===e.length)return e.toLowerCase()===this.toHexString();if("string"==typeof e&&t.isValid(e)&&12===e.length)return Xt.from(e).equals(this.id);if("object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString){var n=e.toHexString(),r=this.toHexString().toLowerCase();return"string"==typeof n&&n.toLowerCase()===r}return!1},t.prototype.getTimestamp=function(){var t=new Date,e=this.id.readUInt32BE(0);return t.setTime(1e3*Math.floor(e)),t},t.createPk=function(){return new t},t.createFromTime=function(e){var n=Xt.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n.writeUInt32BE(e,0),new t(n)},t.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new ne("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(Xt.from(e,"hex"))},t.isValid=function(e){if(null==e)return!1;try{return new t(e),!0}catch(t){return!1}},t.prototype.toExtendedJSON=function(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}},t.fromExtendedJSON=function(e){return new t(e.$oid)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new ObjectId("'.concat(this.toHexString(),'")')},t.index=Math.floor(16777215*Math.random()),t}();Object.defineProperty(Ye.prototype,"generate",{value:fe((function(t){return Ye.generate(t)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(Ye.prototype,"getInc",{value:fe((function(){return Ye.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Ye.prototype,"get_inc",{value:fe((function(){return Ye.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Ye,"get_inc",{value:fe((function(){return Ye.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Ye.prototype,"_bsontype",{value:"ObjectID"});var We=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(this.pattern=e,this.options=(null!=n?n:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new ee("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new ee("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.options)));for(var r=0;r<this.options.length;r++)if("i"!==this.options[r]&&"m"!==this.options[r]&&"x"!==this.options[r]&&"l"!==this.options[r]&&"s"!==this.options[r]&&"u"!==this.options[r])throw new ee("The regular expression option [".concat(this.options[r],"] is not supported"))}return t.parseOptions=function(t){return t?t.split("").sort().join(""):""},t.prototype.toExtendedJSON=function(t){return(t=t||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}},t.fromExtendedJSON=function(e){if("$regex"in e){if("string"==typeof e.$regex)return new t(e.$regex,t.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new t(e.$regularExpression.pattern,t.parseOptions(e.$regularExpression.options));throw new ne("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(e)))},t}();Object.defineProperty(We.prototype,"_bsontype",{value:"BSONRegExp"});var Qe=function(){function t(e){if(!(this instanceof t))return new t(e);this.value=e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(){return this.value},t.prototype.inspect=function(){return'new BSONSymbol("'.concat(this.value,'")')},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(){return{$symbol:this.value}},t.fromExtendedJSON=function(e){return new t(e.$symbol)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t}();Object.defineProperty(Qe.prototype,"_bsontype",{value:"Symbol"});var ze=function(t){function e(n,r){var o=this;return o instanceof e?(o=Ie.isLong(n)?t.call(this,n.low,n.high,!0)||this:ae(n)&&void 0!==n.t&&void 0!==n.i?t.call(this,n.i,n.t,!0)||this:t.call(this,n,r,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new e(n,r)}return te(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(Ie.fromInt(t,!0))},e.fromNumber=function(t){return new e(Ie.fromNumber(t,!0))},e.fromBits=function(t,n){return new e(t,n)},e.fromString=function(t,n){return new e(Ie.fromString(t,!0,n))},e.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},e.fromExtendedJSON=function(t){return new e(t.$timestamp)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Timestamp({ t: ".concat(this.getHighBits(),", i: ").concat(this.getLowBits()," })")},e.MAX_VALUE=Ie.MAX_UNSIGNED_VALUE,e}(Ie);var Xe=2147483647,Ke=-2147483648,tn=0x8000000000000000,en=-0x8000000000000000,nn={$oid:Ye,$binary:me,$uuid:me,$symbol:Qe,$numberInt:Je,$numberDecimal:Ce,$numberDouble:ke,$numberLong:Ie,$minKey:Ve,$maxKey:Fe,$regex:We,$regularExpression:We,$timestamp:ze};function rn(t,e){if(void 0===e&&(e={}),"number"==typeof t){if(e.relaxed||e.legacy)return t;if(Math.floor(t)===t){if(t>=Ke&&t<=Xe)return new Je(t);if(t>=en&&t<=tn)return Ie.fromNumber(t)}return new ke(t)}if(null==t||"object"!=typeof t)return t;if(t.$undefined)return null;for(var n=Object.keys(t).filter((function(e){return e.startsWith("$")&&null!=t[e]})),r=0;r<n.length;r++){var o=nn[n[r]];if(o)return o.fromExtendedJSON(t,e)}if(null!=t.$date){var i=t.$date,u=new Date;return e.legacy?"number"==typeof i?u.setTime(i):"string"==typeof i&&u.setTime(Date.parse(i)):"string"==typeof i?u.setTime(Date.parse(i)):Ie.isLong(i)?u.setTime(i.toNumber()):"number"==typeof i&&e.relaxed&&u.setTime(i),u}if(null!=t.$code){var s=Object.assign({},t);return t.$scope&&(s.$scope=rn(t.$scope)),be.fromExtendedJSON(t)}if(function(t){return ae(t)&&null!=t.$id&&"string"==typeof t.$ref&&(null==t.$db||"string"==typeof t.$db)}(t)||t.$dbPointer){var a=t.$ref?t:t.$dbPointer;if(a instanceof ve)return a;var f=Object.keys(a).filter((function(t){return t.startsWith("$")})),c=!0;if(f.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(c=!1)})),c)return ve.fromExtendedJSON(a)}return t}function on(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function un(t,e){if(("object"==typeof t||"function"==typeof t)&&null!==t){var n=e.seenObjects.findIndex((function(e){return e.obj===t}));if(-1!==n){var r=e.seenObjects.map((function(t){return t.propertyName})),o=r.slice(0,n).map((function(t){return"".concat(t," -> ")})).join(""),i=r[n],u=" -> "+r.slice(n+1,r.length-1).map((function(t){return"".concat(t," -> ")})).join(""),s=r[r.length-1],a=" ".repeat(o.length+i.length/2),f="-".repeat(u.length+(i.length+s.length)/2-1);throw new ne("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(u).concat(s,"\n")+" ".concat(a,"\\").concat(f,"/"))}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((function(t,n){e.seenObjects.push({propertyName:"index ".concat(n),obj:null});try{return un(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||ae(p=t)&&"[object Date]"===Object.prototype.toString.call(p)){var c=t.getTime(),h=c>-1&&c<2534023188e5;return e.legacy?e.relaxed&&h?{$date:t.getTime()}:{$date:on(t)}:e.relaxed&&h?{$date:on(t)}:{$date:{$numberLong:t.getTime().toString()}}}var p;if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Math.floor(t)===t){var l=t>=en&&t<=tn;if(t>=Ke&&t<=Xe)return{$numberInt:t.toString()};if(l)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||function(t){return"[object RegExp]"===Object.prototype.toString.call(t)}(t)){var d=t.flags;if(void 0===d){var y=t.toString().match(/[gimuy]*$/);y&&(d=y[0])}return new We(t.source,d).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new ee("not an object instance");var n=t._bsontype;if(void 0===n){var r={};for(var o in t){e.seenObjects.push({propertyName:o,obj:null});try{var i=un(t[o],e);"__proto__"===o?Object.defineProperty(r,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):r[o]=i}finally{e.seenObjects.pop()}}return r}if(function(t){return ae(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}(t)){var u=t;if("function"!=typeof u.toExtendedJSON){var s=an[t._bsontype];if(!s)throw new ne("Unrecognized or invalid _bsontype: "+t._bsontype);u=s(u)}return"Code"===n&&u.scope?u=new be(u.code,un(u.scope,e)):"DBRef"===n&&u.oid&&(u=new ve(un(u.collection,e),un(u.oid,e),un(u.db,e),un(u.fields,e))),u.toExtendedJSON(e)}throw new ee("_bsontype must be a string, but was: "+typeof n)}(t,e):t}var sn,an={Binary:function(t){return new me(t.value(),t.sub_type)},Code:function(t){return new be(t.code,t.scope)},DBRef:function(t){return new ve(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new Ce(t.bytes)},Double:function(t){return new ke(t.value)},Int32:function(t){return new Je(t.value)},Long:function(t){return Ie.fromBits(null!=t.low?t.low:t.low_,null!=t.low?t.high:t.high_,null!=t.low?t.unsigned:t.unsigned_)},MaxKey:function(){return new Fe},MinKey:function(){return new Ve},ObjectID:function(t){return new Ye(t)},ObjectId:function(t){return new Ye(t)},BSONRegExp:function(t){return new We(t.pattern,t.options)},Symbol:function(t){return new Qe(t.value)},Timestamp:function(t){return ze.fromBits(t.low,t.high)}};!function(t){function e(t,e){var n=Object.assign({},{relaxed:!0,legacy:!1},e);return"boolean"==typeof n.relaxed&&(n.strict=!n.relaxed),"boolean"==typeof n.strict&&(n.relaxed=!n.strict),JSON.parse(t,(function(t,e){if(-1!==t.indexOf("\0"))throw new ee("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(t)));return rn(e,n)}))}function n(t,e,n,r){null!=n&&"object"==typeof n&&(r=n,n=0),null==e||"object"!=typeof e||Array.isArray(e)||(r=e,e=void 0,n=0);var o=un(t,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,n)}t.parse=e,t.stringify=n,t.serialize=function(t,e){return e=e||{},JSON.parse(n(t,e))},t.deserialize=function(t,n){return n=n||{},e(JSON.stringify(t),n)}}(sn||(sn={}));var fn=oe();fn.Map?fn.Map:function(){function t(t){void 0===t&&(t=[]),this._keys=[],this._values={};for(var e=0;e<t.length;e++)if(null!=t[e]){var n=t[e],r=n[0],o=n[1];this._keys.push(r),this._values[r]={v:o,i:this._keys.length-1}}}t.prototype.clear=function(){this._keys=[],this._values={}},t.prototype.delete=function(t){var e=this._values[t];return null!=e&&(delete this._values[t],this._keys.splice(e.i,1),!0)},t.prototype.entries=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?[n,t._values[n].v]:void 0,done:void 0===n}}}},t.prototype.forEach=function(t,e){e=e||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];t.call(e,this._values[r].v,r,e)}},t.prototype.get=function(t){return this._values[t]?this._values[t].v:void 0},t.prototype.has=function(t){return null!=this._values[t]},t.prototype.keys=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},t.prototype.set=function(t,e){return this._values[t]?(this._values[t].v=e,this):(this._keys.push(t),this._values[t]={v:e,i:this._keys.length-1},this)},t.prototype.values=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?t._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0})}(),Ie.fromNumber(ye),Ie.fromNumber(ge),new Set(["$db","$ref","$id","$clusterTime"]);var cn=new Uint8Array(8);new DataView(cn.buffer,cn.byteOffset,cn.byteLength);Xt.alloc(17825792);var hn=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=new Un.reqClass(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return t=this,e=void 0,r=function(){var t;return function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(e){switch(e.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(t=e.sent())&&t.data&&t.data.list?[2,{requestId:t.requestId,data:JSON.parse(t.data.list).map(sn.parse)}]:[2,t]}}))},new((n=void 0)||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}));var t,e,n,r},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map((function(t){var e,n=t.stageKey,r=t.stageValue;return(e={})[n]=JSON.parse(r),e}))},t.prototype._pipe=function(t,e){return this._stages.push({stageKey:"$"+t,stageValue:JSON.stringify(e)}),this},t.prototype.addFields=function(t){return this._pipe("addFields",t)},t.prototype.bucket=function(t){return this._pipe("bucket",t)},t.prototype.bucketAuto=function(t){return this._pipe("bucketAuto",t)},t.prototype.count=function(t){return this._pipe("count",t)},t.prototype.geoNear=function(t){return t.query&&(t.query=Rt.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new W(t.near.longitude,t.near.latitude).toJSON()),this._pipe("geoNear",t)},t.prototype.group=function(t){return this._pipe("group",t)},t.prototype.limit=function(t){return this._pipe("limit",t)},t.prototype.match=function(t){return this._pipe("match",Rt.encode(t))},t.prototype.project=function(t){return this._pipe("project",t)},t.prototype.lookup=function(t){return this._pipe("lookup",t)},t.prototype.replaceRoot=function(t){return this._pipe("replaceRoot",t)},t.prototype.sample=function(t){return this._pipe("sample",t)},t.prototype.skip=function(t){return this._pipe("skip",t)},t.prototype.sort=function(t){return this._pipe("sort",t)},t.prototype.sortByCount=function(t){return this._pipe("sortByCount",t)},t.prototype.unwind=function(t){return this._pipe("unwind",t)},t}();const pn=hn;var ln=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),dn=function(t){function e(e,n){return t.call(this,e,n)||this}return ln(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new $t(this._db,this._coll,t)},e.prototype.add=function(t,e){return new $t(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new pn(this._db,this._coll)},e}(qt),yn={eq:function(t){return new pt(ct.EQ,[t])},neq:function(t){return new pt(ct.NEQ,[t])},lt:function(t){return new pt(ct.LT,[t])},lte:function(t){return new pt(ct.LTE,[t])},gt:function(t){return new pt(ct.GT,[t])},gte:function(t){return new pt(ct.GTE,[t])},in:function(t){return new pt(ct.IN,t)},nin:function(t){return new pt(ct.NIN,t)},all:function(t){return new pt(ct.ALL,t)},elemMatch:function(t){return new pt(ct.ELEM_MATCH,[t])},exists:function(t){return new pt(ct.EXISTS,[t])},size:function(t){return new pt(ct.SIZE,[t])},mod:function(t){return new pt(ct.MOD,[t])},geoNear:function(t){return new pt(ct.GEO_NEAR,[t])},geoWithin:function(t){return new pt(ct.GEO_WITHIN,[t])},geoIntersects:function(t){return new pt(ct.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=H(arguments[0])?arguments[0]:Array.from(arguments);return new at(it.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=H(arguments[0])?arguments[0]:Array.from(arguments);return new at(it.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=H(arguments[0])?arguments[0]:Array.from(arguments);return new at(it.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=H(arguments[0])?arguments[0]:Array.from(arguments);return new at(it.NOT,n)},set:function(t){return new ut(D.SET,[t])},remove:function(){return new ut(D.REMOVE,[])},inc:function(t){return new ut(D.INC,[t])},mul:function(t){return new ut(D.MUL,[t])},push:function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(F(e[0])&&e[0].hasOwnProperty("each")){var r=e[0];t={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else t=H(e[0])?e[0]:Array.from(e);return new ut(D.PUSH,t)},pull:function(t){return new ut(D.PULL,t)},pullAll:function(t){return new ut(D.PULL_ALL,t)},pop:function(){return new ut(D.POP,[])},shift:function(){return new ut(D.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=H(arguments[0])?arguments[0]:Array.from(arguments);return new ut(D.UNSHIFT,n)},addToSet:function(t){return new ut(D.ADD_TO_SET,t)},rename:function(t){return new ut(D.RENAME,[t])},bit:function(t){return new ut(D.BIT,[t])},max:function(t){return new ut(D.MAX,[t])},min:function(t){return new ut(D.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===J(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new pn},abs:function(t){return new gn("abs",t)},add:function(t){return new gn("add",t)},ceil:function(t){return new gn("ceil",t)},divide:function(t){return new gn("divide",t)},exp:function(t){return new gn("exp",t)},floor:function(t){return new gn("floor",t)},ln:function(t){return new gn("ln",t)},log:function(t){return new gn("log",t)},log10:function(t){return new gn("log10",t)},mod:function(t){return new gn("mod",t)},multiply:function(t){return new gn("multiply",t)},pow:function(t){return new gn("pow",t)},sqrt:function(t){return new gn("sqrt",t)},subtract:function(t){return new gn("subtract",t)},trunc:function(t){return new gn("trunc",t)},arrayElemAt:function(t){return new gn("arrayElemAt",t)},arrayToObject:function(t){return new gn("arrayToObject",t)},concatArrays:function(t){return new gn("concatArrays",t)},filter:function(t){return new gn("filter",t)},in:function(t){return new gn("in",t)},indexOfArray:function(t){return new gn("indexOfArray",t)},isArray:function(t){return new gn("isArray",t)},map:function(t){return new gn("map",t)},range:function(t){return new gn("range",t)},reduce:function(t){return new gn("reduce",t)},reverseArray:function(t){return new gn("reverseArray",t)},size:function(t){return new gn("size",t)},slice:function(t){return new gn("slice",t)},zip:function(t){return new gn("zip",t)},and:function(t){return new gn("and",t)},not:function(t){return new gn("not",t)},or:function(t){return new gn("or",t)},cmp:function(t){return new gn("cmp",t)},eq:function(t){return new gn("eq",t)},gt:function(t){return new gn("gt",t)},gte:function(t){return new gn("gte",t)},lt:function(t){return new gn("lt",t)},lte:function(t){return new gn("lte",t)},neq:function(t){return new gn("ne",t)},cond:function(t){return new gn("cond",t)},ifNull:function(t){return new gn("ifNull",t)},switch:function(t){return new gn("switch",t)},dateFromParts:function(t){return new gn("dateFromParts",t)},dateFromString:function(t){return new gn("dateFromString",t)},dayOfMonth:function(t){return new gn("dayOfMonth",t)},dayOfWeek:function(t){return new gn("dayOfWeek",t)},dayOfYear:function(t){return new gn("dayOfYear",t)},isoDayOfWeek:function(t){return new gn("isoDayOfWeek",t)},isoWeek:function(t){return new gn("isoWeek",t)},isoWeekYear:function(t){return new gn("isoWeekYear",t)},millisecond:function(t){return new gn("millisecond",t)},minute:function(t){return new gn("minute",t)},month:function(t){return new gn("month",t)},second:function(t){return new gn("second",t)},hour:function(t){return new gn("hour",t)},week:function(t){return new gn("week",t)},year:function(t){return new gn("year",t)},literal:function(t){return new gn("literal",t)},mergeObjects:function(t){return new gn("mergeObjects",t)},objectToArray:function(t){return new gn("objectToArray",t)},allElementsTrue:function(t){return new gn("allElementsTrue",t)},anyElementTrue:function(t){return new gn("anyElementTrue",t)},setDifference:function(t){return new gn("setDifference",t)},setEquals:function(t){return new gn("setEquals",t)},setIntersection:function(t){return new gn("setIntersection",t)},setIsSubset:function(t){return new gn("setIsSubset",t)},setUnion:function(t){return new gn("setUnion",t)},concat:function(t){return new gn("concat",t)},dateToString:function(t){return new gn("dateToString",t)},indexOfBytes:function(t){return new gn("indexOfBytes",t)},indexOfCP:function(t){return new gn("indexOfCP",t)},split:function(t){return new gn("split",t)},strLenBytes:function(t){return new gn("strLenBytes",t)},strLenCP:function(t){return new gn("strLenCP",t)},strcasecmp:function(t){return new gn("strcasecmp",t)},substr:function(t){return new gn("substr",t)},substrBytes:function(t){return new gn("substrBytes",t)},substrCP:function(t){return new gn("substrCP",t)},toLower:function(t){return new gn("toLower",t)},toUpper:function(t){return new gn("toUpper",t)},meta:function(t){return new gn("meta",t)},addToSet:function(t){return new gn("addToSet",t)},avg:function(t){return new gn("avg",t)},first:function(t){return new gn("first",t)},last:function(t){return new gn("last",t)},max:function(t){return new gn("max",t)},min:function(t){return new gn("min",t)},push:function(t){return new gn("push",t)},stdDevPop:function(t){return new gn("stdDevPop",t)},stdDevSamp:function(t){return new gn("stdDevSamp",t)},sum:function(t){return new gn("sum",t)},let:function(t){return new gn("let",t)}},project:{slice:function(t){return new mn("slice",t)},elemMatch:function(t){return new mn("elemMatch",t)}}},gn=function(t,e){this["$"+t]=e},mn=function(t,e){this["$"+t]=e},wn=function(){function t(t){var e=t.regexp,n=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regex=e,this.$options=n}return t.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return $},enumerable:!0,configurable:!0}),t}();function bn(t){return new wn(t)}var vn="insert document failed",_n="DATABASE_TRANSACTION_CONFLICT",En=function(){return En=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},En.apply(this,arguments)},On=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},Sn=function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},Nn="database.updateDocInTransaction",xn=function(){function t(t,e,n){this._coll=e,this.id=n,this._transaction=t,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.create=function(t){return On(this,void 0,void 0,(function(){var e,n,r,o;return Sn(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:sn.stringify(_t(t),{relaxed:!1})},this.id&&(e._id=this.id),[4,this._request.send("database.insertDocInTransaction",e)];case 1:if((n=i.sent()).code)throw n;if(r=sn.parse(n.inserted),1==(o=sn.parse(n.ok))&&1==r)return[2,En(En({},n),{ok:o,inserted:r})];throw new Error(vn)}}))}))},t.prototype.get=function(){return On(this,void 0,void 0,(function(){var t,e;return Sn(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,{data:"null"!==e.data?C.formatField(sn.parse(e.data)):sn.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return On(this,void 0,void 0,(function(){var e,n;return Sn(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:sn.stringify(_t(t),{relaxed:!1}),upsert:!0},[4,this._request.send(Nn,e)];case 1:if((n=r.sent()).code)throw n;return[2,En(En({},n),{updated:sn.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},t.prototype.update=function(t){return On(this,void 0,void 0,(function(){var e,n;return Sn(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:sn.stringify(jt.encode(t),{relaxed:!1})},[4,this._request.send(Nn,e)];case 1:if((n=r.sent()).code)throw n;return[2,En(En({},n),{updated:sn.parse(n.updated)})]}}))}))},t.prototype.delete=function(){return On(this,void 0,void 0,(function(){var t,e;return Sn(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,En(En({},e),{deleted:sn.parse(e.deleted)})]}}))}))},t}(),In=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Tn=function(t){function e(e,n){return t.call(this,e,n)||this}return In(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new xn(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new xn(this._transaction,this._coll,e).create(t)},e}((function(t,e){this._coll=e,this._transaction=t})),An=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},Bn=function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},jn=function(){function t(t){this._db=t,this._request=new Un.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return An(this,void 0,void 0,(function(){var t;return Bn(this,(function(e){switch(e.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((t=e.sent()).code)throw t;return this.inited=!0,this._id=t.transactionId,[2]}}))}))},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new Tn(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return An(this,void 0,void 0,(function(){var t,e;return Bn(this,(function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.commitTransaction",t)];case 1:if((e=n.sent()).code)throw e;return this.commited=!0,[2,e]}}))}))},t.prototype.rollback=function(t){return An(this,void 0,void 0,(function(){var e,n;return Bn(this,(function(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.abortTransaction",e)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=t,[2,n]}}))}))},t}();function Pn(){return An(this,void 0,void 0,(function(){var t;return Bn(this,(function(e){switch(e.label){case 0:return[4,(t=new jn(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function Ln(t,e){return void 0===e&&(e=3),An(this,void 0,void 0,(function(){var n,r,o,i,u=this;return Bn(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,10]),[4,(n=new jn(this)).init()];case 1:return s.sent(),[4,t(n)];case 2:if(r=s.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return s.sent(),[2,r];case 4:if(o=s.sent(),!1===n.inited)throw o;return i=function(t){return An(u,void 0,void 0,(function(){return Bn(this,(function(e){switch(e.label){case 0:if(n.aborted||n.commited)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.rollback()];case 2:case 3:return e.sent(),[3,4];case 4:throw t;case 5:if(!0===n.aborted)throw n.abortReason;throw t}}))}))},e<=0?[4,i(o)]:[3,6];case 5:s.sent(),s.label=6;case 6:return o&&o.code===_n?[4,Ln.bind(this)(t,--e)]:[3,8];case 7:return[2,s.sent()];case 8:return[4,i(o)];case 9:return s.sent(),[3,10];case 10:return[2]}}))}))}var Un=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=M,this.command=yn,this.RegExp=bn,this.startTransaction=Pn,this.runTransaction=Ln,this.logicCommand=at,this.updateCommand=ut,this.queryCommand=pt}return t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new dn(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return new t.reqClass(this.config).send("database.addCollection",n)},t}()}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}return n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(258)})()));
|