@cloudbase/js-sdk 2.5.5-alpha.0 → 2.5.7-beta.0

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.
@@ -14,4 +14,4 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
14
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
15
  PERFORMANCE OF THIS SOFTWARE.
16
16
  ***************************************************************************** */
17
- var b=function(t,e){return(b=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)};function w(t,e){function n(){this.constructor=t}b(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var _=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return w(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),e}(Error),E=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return w(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),e}(TypeError);function I(t){return t&&t.Math==Math&&t}function S(){return I("object"==typeof globalThis&&globalThis)||I("object"==typeof window&&window)||I("object"==typeof self&&self)||I("object"==typeof t&&t)||Function("return this")()}var O=function(t){var e,n="object"==typeof(e=S()).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=m.alloc(t),o=0;o<t;++o)r[o]=Math.floor(256*Math.random());return r},A=function(){if("undefined"!=typeof window){var e=window.crypto||window.msCrypto;if(e&&e.getRandomValues)return function(t){return e.getRandomValues(m.alloc(t))}}return void 0!==t&&t.crypto&&t.crypto.getRandomValues?function(e){return t.crypto.getRandomValues(m.alloc(e))}:O}();function T(t){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(t))}function N(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function R(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function x(t){return C(t)&&"[object Date]"===Object.prototype.toString.call(t)}function C(t){return"object"==typeof t&&null!==t}function P(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 L(t){if(ArrayBuffer.isView(t))return m.from(t.buffer,t.byteOffset,t.byteLength);if(T(t))return m.from(t);throw new E("Must use either Buffer or TypedArray")}var U=/^(?:[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,D=function(t){return"string"==typeof t&&U.test(t)},j=function(t){if(!D(t))throw new E('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 m.from(e,"hex")},k=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")},M=(Math.pow(2,63),Math.pow(2,63),Math.pow(2,53)),B=-Math.pow(2,53),q=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 E("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=m.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=m.from(e,"binary"):Array.isArray(e)?this.buffer=m.from(e):this.buffer=L(e),this.position=this.buffer.byteLength)}return t.prototype.put=function(e){if("string"==typeof e&&1!==e.length)throw new E("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new E("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 E("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=m.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=m.alloc(this.buffer.length+t.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n}ArrayBuffer.isView(t)?(this.buffer.set(L(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 F(this.buffer.slice(0,this.position));throw new _('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=m.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=m.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,r=j(e.$uuid)),!r)throw new E("Unexpected Binary Extended JSON format ".concat(JSON.stringify(e)));return 4===o?new F(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(q.prototype,"_bsontype",{value:"Binary"});var F=function(t){function e(n){var r,o,i=this;if(null==n)r=e.generate();else if(n instanceof e)r=m.from(n.buffer),o=n.__id;else if(ArrayBuffer.isView(n)&&16===n.byteLength)r=L(n);else{if("string"!=typeof n)throw new E("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=j(n)}return(i=t.call(this,r,4)||this).__id=o,i}return w(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.buffer},set:function(t){this.buffer=t,e.cacheHexString&&(this.__id=k(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=k(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 q(this.id,q.SUBTYPE_UUID)},e.generate=function(){var t=A(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,m.from(t)},e.isValid=function(t){return!!t&&(t instanceof e||("string"==typeof t?D(t):!!N(t)&&(16===t.length&&(64==(240&t[6])&&128==(128&t[8])))))},e.createFromHexString=function(t){return new e(j(t))},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},e}(q),W=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}();function $(t){return C(t)&&null!=t.$id&&"string"==typeof t.$ref&&(null==t.$db||"string"==typeof t.$db)}Object.defineProperty(W.prototype,"_bsontype",{value:"Code"});var V=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(V.prototype,"_bsontype",{value:"DBRef"});var H=void 0;try{H=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(t){}var G={},J={},K=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=J[e])?o:(r=t.fromBits(e,(0|e)<0?-1:0,!0),i&&(J[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(o=G[e])?o:(r=t.fromBits(e,e<0?-1:0,!1),i&&(G[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>=0x10000000000000000)return t.MAX_UNSIGNED_VALUE}else{if(e<=-0x8000000000000000)return t.MIN_VALUE;if(e+1>=0x8000000000000000)return t.MAX_VALUE}return e<0?t.fromNumber(-e,n).neg():t.fromBits(e%4294967296|0,e/4294967296|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)),s=t.ZERO,a=0;a<e.length;a+=8){var u=Math.min(8,e.length-a),c=parseInt(e.substring(a,a+u),r);if(u<8){var f=t.fromNumber(Math.pow(r,u));s=s.mul(f).add(t.fromNumber(c))}else s=(s=s.mul(i)).add(t.fromNumber(c))}return s.unsigned=n,s},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 C(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,s=e.high>>>16,a=65535&e.high,u=e.low>>>16,c=0,f=0,l=0,h=0;return l+=(h+=i+(65535&e.low))>>>16,h&=65535,f+=(l+=o+u)>>>16,l&=65535,c+=(f+=r+a)>>>16,f&=65535,c+=n+s,c&=65535,t.fromBits(l<<16|h,c<<16|f,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(H){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;var n=(this.unsigned?H.div_u:H.div_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,H.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 s=Math.ceil(Math.log(r)/Math.LN2),a=s<=48?1:Math.pow(2,s-48),u=t.fromNumber(r),c=u.mul(e);c.isNegative()||c.gt(o);)r-=a,c=(u=t.fromNumber(r,this.unsigned)).mul(e);u.isZero()&&(u=t.ONE),i=i.add(u),o=o.sub(c)}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&&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 0==(1&this.low)},t.prototype.isNegative=function(){return!this.unsigned&&this.high<0},t.prototype.isOdd=function(){return 1==(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)),H){var n=(this.unsigned?H.rem_u:H.rem_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,H.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)),H){var n=H.mul(this.low,this.high,e.low,e.high);return t.fromBits(n,H.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,s=65535&this.low,a=e.high>>>16,u=65535&e.high,c=e.low>>>16,f=65535&e.low,l=0,h=0,p=0,d=0;return p+=(d+=s*f)>>>16,d&=65535,h+=(p+=i*f)>>>16,p&=65535,h+=(p+=s*c)>>>16,p&=65535,l+=(h+=o*f)>>>16,h&=65535,l+=(h+=i*c)>>>16,h&=65535,l+=(h+=s*u)>>>16,h&=65535,l+=r*f+o*c+i*u+s*a,l&=65535,t.fromBits(p<<16|d,l<<16|h,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?4294967296*(this.high>>>0)+(this.low>>>0):4294967296*this.high+(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),s=this,a="";;){var u=s.div(i),c=(s.sub(u.mul(i)).toInt()>>>0).toString(e);if((s=u).isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}},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(1<<24),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(K.prototype,"__isLong__",{value:!0}),Object.defineProperty(K.prototype,"_bsontype",{value:"Long"});var Y=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,z=/^(\+|-)?(Infinity|inf)$/i,Q=/^(\+|-)?NaN$/i,Z=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),X=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),tt=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),et=/^([-+])?(\d+)?$/;function nt(t){return!isNaN(parseInt(t,10))}function rt(t){var e=K.fromNumber(1e9),n=K.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 K(t.parts[r],0)),t.parts[r]=n.div(e).low,n=n.modulo(e);return{quotient:t,rem:n}}function ot(t,e){throw new E('"'.concat(t,'" is not a valid Decimal128 string - ').concat(e))}var it=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!N(e))throw new E("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new E("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(e){var n,r=!1,o=!1,i=!1,s=0,a=0,u=0,c=0,f=0,l=[0],h=0,p=0,d=0,y=0,g=0,v=0,b=new K(0,0),w=new K(0,0),_=0;if(e.length>=7e3)throw new E(e+" not a valid Decimal128 string");var I=e.match(Y),S=e.match(z),O=e.match(Q);if(!I&&!S&&!O||0===e.length)throw new E(e+" not a valid Decimal128 string");if(I){var A=I[2],T=I[4],N=I[5],R=I[6];T&&void 0===R&&ot(e,"missing exponent power"),T&&void 0===A&&ot(e,"missing exponent base"),void 0===T&&(N||R)&&ot(e,"missing e before exponent")}if("+"!==e[_]&&"-"!==e[_]||(r="-"===e[_++]),!nt(e[_])&&"."!==e[_]){if("i"===e[_]||"I"===e[_])return new t(m.from(r?X:tt));if("N"===e[_])return new t(m.from(Z))}for(;nt(e[_])||"."===e[_];)"."!==e[_]?(h<34&&("0"!==e[_]||i)&&(i||(f=a),i=!0,l[p++]=parseInt(e[_],10),h+=1),i&&(u+=1),o&&(c+=1),a+=1,_+=1):(o&&ot(e,"contains multiple periods"),o=!0,_+=1);if(o&&!a)throw new E(e+" not a valid Decimal128 string");if("e"===e[_]||"E"===e[_]){var x=e.substr(++_).match(et);if(!x||!x[2])return new t(m.from(Z));g=parseInt(x[0],10),_+=x[0].length}if(e[_])return new t(m.from(Z));if(d=0,h){if(y=h-1,1!==(s=u))for(;0===l[f+s-1];)s-=1}else d=0,y=0,l[0]=0,u=1,h=1,s=0;for(g<=c&&c-g>16384?g=-6176:g-=c;g>6111;){if((y+=1)-d>34){if(l.join("").match(/^0+$/)){g=6111;break}ot(e,"overflow")}g-=1}for(;g<-6176||h<u;){if(0===y&&s<h){g=-6176,s=0;break}if(h<u?u-=1:y-=1,g<6111)g+=1;else{if(l.join("").match(/^0+$/)){g=6111;break}ot(e,"overflow")}}if(y-d+1<s){var C=a;o&&(f+=1,C+=1),r&&(f+=1,C+=1);var P=parseInt(e[f+y+1],10),L=0;if(P>=5&&(L=1,5===P))for(L=l[y]%2==1?1:0,v=f+y+2;v<C;v++)if(parseInt(e[v],10)){L=1;break}if(L)for(var U=y;U>=0;U--)if(++l[U]>9&&(l[U]=0,0===U)){if(!(g<6111))return new t(m.from(r?X:tt));g+=1,l[U]=1}}if(b=K.fromNumber(0),w=K.fromNumber(0),0===s)b=K.fromNumber(0),w=K.fromNumber(0);else if(y-d<17){U=d;for(w=K.fromNumber(l[U++]),b=new K(0,0);U<=y;U++)w=(w=w.multiply(K.fromNumber(10))).add(K.fromNumber(l[U]))}else{U=d;for(b=K.fromNumber(l[U++]);U<=y-17;U++)b=(b=b.multiply(K.fromNumber(10))).add(K.fromNumber(l[U]));for(w=K.fromNumber(l[U++]);U<=y;U++)w=(w=w.multiply(K.fromNumber(10))).add(K.fromNumber(l[U]))}var D,j,k,M,B=function(t,e){if(!t&&!e)return{high:K.fromNumber(0),low:K.fromNumber(0)};var n=t.shiftRightUnsigned(32),r=new K(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new K(e.getLowBits(),0),s=n.multiply(o),a=n.multiply(i),u=r.multiply(o),c=r.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new K(a.getLowBits(),0).add(u).add(c.shiftRightUnsigned(32)),{high:s=s.add(a.shiftRightUnsigned(32)),low:c=a.shiftLeft(32).add(new K(c.getLowBits(),0))}}(b,K.fromString("100000000000000000"));B.low=B.low.add(w),D=B.low,j=w,k=D.high>>>0,M=j.high>>>0,(k<M||k===M&&D.low>>>0<j.low>>>0)&&(B.high=B.high.add(K.fromNumber(1))),n=g+6176;var q={low:K.fromNumber(0),high:K.fromNumber(0)};B.high.shiftRightUnsigned(49).and(K.fromNumber(1)).equals(K.fromNumber(1))?(q.high=q.high.or(K.fromNumber(3).shiftLeft(61)),q.high=q.high.or(K.fromNumber(n).and(K.fromNumber(16383).shiftLeft(47))),q.high=q.high.or(B.high.and(K.fromNumber(0x7fffffffffff)))):(q.high=q.high.or(K.fromNumber(16383&n).shiftLeft(49)),q.high=q.high.or(B.high.and(K.fromNumber(562949953421311)))),q.low=B.low,r&&(q.high=q.high.or(K.fromString("9223372036854775808")));var F=m.alloc(16);return _=0,F[_++]=255&q.low.low,F[_++]=q.low.low>>8&255,F[_++]=q.low.low>>16&255,F[_++]=q.low.low>>24&255,F[_++]=255&q.low.high,F[_++]=q.low.high>>8&255,F[_++]=q.low.high>>16&255,F[_++]=q.low.high>>24&255,F[_++]=255&q.high.low,F[_++]=q.high.low>>8&255,F[_++]=q.high.low>>16&255,F[_++]=q.high.low>>24&255,F[_++]=255&q.high.high,F[_++]=q.high.high>>8&255,F[_++]=q.high.high>>16&255,F[_++]=q.high.high>>24&255,new t(F)},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,s,a=0,u=!1,c={parts:[0,0,0,0]},f=[];a=0;var l=this.bytes,h=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,p=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,d=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,y=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24;a=0,{low:new K(h,p),high:new K(d,y)}.high.lessThan(K.ZERO)&&f.push("-");var g=y>>26&31;if(g>>3==3){if(30===g)return f.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 v=t-6176;if(c.parts[0]=(16383&y)+((15&o)<<14),c.parts[1]=d,c.parts[2]=p,c.parts[3]=h,0===c.parts[0]&&0===c.parts[1]&&0===c.parts[2]&&0===c.parts[3])u=!0;else for(s=3;s>=0;s--){var m=0,b=rt(c);if(c=b.quotient,m=b.rem.low)for(i=8;i>=0;i--)n[9*s+i]=m%10,m=Math.floor(m/10)}if(u)e=1,n[a]=0;else for(e=36;!n[a];)e-=1,a+=1;var w=e-1+v;if(w>=34||w<=-7||v>0){if(e>34)return f.push("".concat(0)),v>0?f.push("E+".concat(v)):v<0&&f.push("E".concat(v)),f.join("");f.push("".concat(n[a++])),(e-=1)&&f.push(".");for(r=0;r<e;r++)f.push("".concat(n[a++]));f.push("E"),w>0?f.push("+".concat(w)):f.push("".concat(w))}else if(v>=0)for(r=0;r<e;r++)f.push("".concat(n[a++]));else{var _=e+v;if(_>0)for(r=0;r<_;r++)f.push("".concat(n[a++]));else f.push("0");for(f.push(".");_++<0;)f.push("0");for(r=0;r<e-Math.max(_-1,0);r++)f.push("".concat(n[a++]))}return f.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(it.prototype,"_bsontype",{value:"Decimal128"});var st=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))}:(Number.isInteger(this.value)?(e=this.value.toFixed(1)).length>=13&&(e=this.value.toExponential(13).toUpperCase()):e=this.value.toString(),{$numberDouble:e});var e},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(st.prototype,"_bsontype",{value:"Double"});var at=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(at.prototype,"_bsontype",{value:"Int32"});var ut=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(ut.prototype,"_bsontype",{value:"MaxKey"});var ct=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(ct.prototype,"_bsontype",{value:"MinKey"});var ft=new RegExp("^[0-9a-fA-F]{24}$"),lt=null,ht=Symbol("id"),pt=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 E("Argument passed in must have an id that is of type string or Buffer");n="toHexString"in e&&"function"==typeof e.toHexString?m.from(e.toHexString(),"hex"):e.id}else n=e;if(null==n||"number"==typeof n)this[ht]=t.generate("number"==typeof n?n:void 0);else if(ArrayBuffer.isView(n)&&12===n.byteLength)this[ht]=n instanceof m?n:L(n);else{if("string"!=typeof n)throw new E("Argument passed in does not match the accepted types");if(12===n.length){var r=m.from(n);if(12!==r.byteLength)throw new E("Argument passed in must be a string of 12 bytes");this[ht]=r}else{if(24!==n.length||!ft.test(n))throw new E("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[ht]=m.from(n,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[ht]},set:function(e){this[ht]=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=m.alloc(12);return r.writeUInt32BE(e,0),null===lt&&(lt=A(5)),r[4]=lt[0],r[5]=lt[1],r[6]=lt[2],r[7]=lt[3],r[8]=lt[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[ht][11]===e[ht][11]&&this[ht].equals(e[ht]);if("string"==typeof e&&t.isValid(e)&&12===e.length&&N(this.id))return e===m.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 m.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=m.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 E("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(m.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(pt.prototype,"generate",{value:P((function(t){return pt.generate(t)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(pt.prototype,"getInc",{value:P((function(){return pt.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(pt.prototype,"get_inc",{value:P((function(){return pt.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(pt,"get_inc",{value:P((function(){return pt.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(pt.prototype,"_bsontype",{value:"ObjectID"});var dt=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 _("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new _("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 _("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 E("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(e)))},t}();Object.defineProperty(dt.prototype,"_bsontype",{value:"BSONRegExp"});var yt=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(yt.prototype,"_bsontype",{value:"Symbol"});var gt=function(t){function e(n,r){var o=this;return o instanceof e?(o=K.isLong(n)?t.call(this,n.low,n.high,!0)||this:C(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 w(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(K.fromInt(t,!0))},e.fromNumber=function(t){return new e(K.fromNumber(t,!0))},e.fromBits=function(t,n){return new e(t,n)},e.fromString=function(t,n){return new e(K.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=K.MAX_UNSIGNED_VALUE,e}(K);function vt(t){return C(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}var mt={$oid:pt,$binary:q,$uuid:q,$symbol:yt,$numberInt:at,$numberDecimal:it,$numberDouble:st,$numberLong:K,$minKey:ct,$maxKey:ut,$regex:dt,$regularExpression:dt,$timestamp:gt};function bt(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function wt(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],s=" -> "+r.slice(n+1,r.length-1).map((function(t){return"".concat(t," -> ")})).join(""),a=r[r.length-1],u=" ".repeat(o.length+i.length/2),c="-".repeat(s.length+(i.length+a.length)/2-1);throw new E("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(s).concat(a,"\n")+" ".concat(u,"\\").concat(c,"/"))}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 wt(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||x(t)){var f=t.getTime(),l=f>-1&&f<2534023188e5;return e.legacy?e.relaxed&&l?{$date:t.getTime()}:{$date:bt(t)}:e.relaxed&&l?{$date:bt(t)}:{$date:{$numberLong:t.getTime().toString()}}}if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Math.floor(t)===t){var h=t>=-0x8000000000000000&&t<=0x8000000000000000;if(t>=-2147483648&&t<=2147483647)return{$numberInt:t.toString()};if(h)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||R(t)){var p=t.flags;if(void 0===p){var d=t.toString().match(/[gimuy]*$/);d&&(p=d[0])}return new dt(t.source,p).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new _("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=wt(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(vt(t)){var s=t;if("function"!=typeof s.toExtendedJSON){var a=Et[t._bsontype];if(!a)throw new E("Unrecognized or invalid _bsontype: "+t._bsontype);s=a(s)}return"Code"===n&&s.scope?s=new W(s.code,wt(s.scope,e)):"DBRef"===n&&s.oid&&(s=new V(wt(s.collection,e),wt(s.oid,e),wt(s.db,e),wt(s.fields,e))),s.toExtendedJSON(e)}throw new _("_bsontype must be a string, but was: "+typeof n)}(t,e):t}var _t,Et={Binary:function(t){return new q(t.value(),t.sub_type)},Code:function(t){return new W(t.code,t.scope)},DBRef:function(t){return new V(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new it(t.bytes)},Double:function(t){return new st(t.value)},Int32:function(t){return new at(t.value)},Long:function(t){return K.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 ut},MinKey:function(){return new ct},ObjectID:function(t){return new pt(t)},ObjectId:function(t){return new pt(t)},BSONRegExp:function(t){return new dt(t.pattern,t.options)},Symbol:function(t){return new yt(t.value)},Timestamp:function(t){return gt.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 _("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(t)));return function t(e,n){if(void 0===n&&(n={}),"number"==typeof e){if(n.relaxed||n.legacy)return e;if(Math.floor(e)===e){if(e>=-2147483648&&e<=2147483647)return new at(e);if(e>=-0x8000000000000000&&e<=0x8000000000000000)return K.fromNumber(e)}return new st(e)}if(null==e||"object"!=typeof e)return e;if(e.$undefined)return null;for(var r=Object.keys(e).filter((function(t){return t.startsWith("$")&&null!=e[t]})),o=0;o<r.length;o++){var i=mt[r[o]];if(i)return i.fromExtendedJSON(e,n)}if(null!=e.$date){var s=e.$date,a=new Date;return n.legacy?"number"==typeof s?a.setTime(s):"string"==typeof s&&a.setTime(Date.parse(s)):"string"==typeof s?a.setTime(Date.parse(s)):K.isLong(s)?a.setTime(s.toNumber()):"number"==typeof s&&n.relaxed&&a.setTime(s),a}if(null!=e.$code){var u=Object.assign({},e);return e.$scope&&(u.$scope=t(e.$scope)),W.fromExtendedJSON(e)}if($(e)||e.$dbPointer){var c=e.$ref?e:e.$dbPointer;if(c instanceof V)return c;var f=Object.keys(c).filter((function(t){return t.startsWith("$")})),l=!0;if(f.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(l=!1)})),l)return V.fromExtendedJSON(c)}return e}(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=wt(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)}}(_t||(_t={}));var It=S();It.Map?It.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})}();K.fromNumber(M),K.fromNumber(B);new Set(["$db","$ref","$id","$clusterTime"]);var St=new Uint8Array(8);new DataView(St.buffer,St.byteOffset,St.byteLength);m.alloc(17825792)}).call(this,n(7))},function(t,e,n){"use strict";var r;n.r(e),n.d(e,"StorageType",(function(){return r})),n.d(e,"AbstractSDKRequest",(function(){return o})),n.d(e,"AbstractStorage",(function(){return i})),n.d(e,"formatUrl",(function(){return s})),function(t){t.local="local",t.none="none",t.session="session"}(r||(r={}));var o=function(){},i=function(){};function s(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";for(var i in n)""===o?!r&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.createSign=e.formatUrl=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var o=r(n(20)),i=r(n(23)),s=r(n(24)),a=n(6);function u(t){var e=i.default.stringify(t);return e=(e=(e=e.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.formatUrl=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";return Object.keys(n).forEach((function(t){""===o?!r&&(e+="?"):o+="&",o+=t+"="+encodeURIComponent(n[t])})),/^http(s)?:\/\//.test(e+=o)?e:""+t+e},e.createSign=function(t,e){var n=u(s.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+u(s.default.parse(JSON.stringify(t)));return n+"."+u(o.default(n,e))},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(n){e.push(n+"="+encodeURIComponent(t[n]))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var n=e||window.location.search,r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]"+t+"=([^&#]*)"));return e?e[1]:""},e.removeParam=function(t,e){var n=e.split("?")[0],r=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===t&&r.splice(i,1);n=n+"?"+r.join("&")}return n},e.createPromiseCallback=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},e.execCallback=function(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n},e.printWarn=function(t,e){console.warn("["+a.getSdkName()+"]["+t+"]:"+e)},e.printError=function(t,e){console.error({code:t,msg:"["+a.getSdkName()+"]["+t+"]:"+e})},e.printInfo=function(t,e){console.log("["+a.getSdkName()+"]["+t+"]:"+e)},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"["+a.getSdkName()+"]["+t+"]:"+e}))},e.printGroupLog=function(t){var e=t.title,n=t.subtitle,r=void 0===n?"":n,o=t.content,i=void 0===o?[]:o,s=t.printTrace,a=void 0!==s&&s,u=t.collapsed;void 0!==u&&u?console.groupCollapsed(e,r):console.group(e,r);for(var c=0,f=i;c<f.length;c++){var l=f[c],h=l.type,p=l.body;switch(h){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}a&&console.trace("stack trace:"),console.groupEnd()},e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86"+t}},function(t,e,n){var r;t.exports=(r=r||function(t,e){var n=Object.create||function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}}(),r={},o=r.lib={},i=o.Base={extend:function(t){var e=n(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=o.WordArray=i.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;e[r+i>>>2]|=s<<24-(r+i)%4*8}else for(i=0;i<o;i+=4)e[r+i>>>2]=n[i>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=i.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n,r=[],o=function(e){e=e;var n=987654321,r=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&r)<<16)+(e=18e3*(65535&e)+(e>>16)&r)&r;return o/=4294967296,(o+=.5)*(t.random()>.5?1:-1)}},i=0;i<e;i+=4){var a=o(4294967296*(n||t.random()));n=987654071*a(),r.push(4294967296*a()|0)}return new s.init(r,e)}}),a=r.enc={},u=a.Hex={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new s.init(n,e/2)}},c=a.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r++)n[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new s.init(n,e)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},l=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,a=o/(4*i),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*i,c=t.min(4*u,o);if(u){for(var f=0;f<u;f+=i)this._doProcessBlock(r,f);var l=r.splice(0,u);n.sigBytes-=c}return new s.init(l,c)},clone:function(){var t=i.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),h=(o.Hasher=l.extend({cfg:i.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,n){return new t.init(n).finalize(e)}},_createHmacHelper:function(t){return function(e,n){return new h.HMAC.init(t,n).finalize(e)}}}),r.algo={});return r}(Math),r)},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(n(8),e),o(n(17),e),e.OATUH_LOGINTYPE="constants"},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var o="https:";e.setProtocol=function(t){o=t},e.getProtocol=function(){return o},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},function(t,e){var n,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(t){r=s}}();var u,c=[],f=!1,l=-1;function h(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&p())}function p(){if(!f){var t=a(h);f=!0;for(var e=c.length;e;){for(u=c,c=[];++l<e;)u&&u[l].run();l=-1,e=c.length}u=null,f=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function y(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new d(t,e)),1!==c.length||f||a(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e){},function(t,e,n){(function(e){var n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/,o=/^\./,i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g,a=/^\[object .+?Constructor\]$/,u=/^(?:0|[1-9]\d*)$/,c="object"==typeof e&&e&&e.Object===Object&&e,f="object"==typeof self&&self&&self.Object===Object&&self,l=c||f||Function("return this")();var h,p=Array.prototype,d=Function.prototype,y=Object.prototype,g=l["__core-js_shared__"],v=(h=/[^.]+$/.exec(g&&g.keys&&g.keys.IE_PROTO||""))?"Symbol(src)_1."+h:"",m=d.toString,b=y.hasOwnProperty,w=y.toString,_=RegExp("^"+m.call(b).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),E=l.Symbol,I=p.splice,S=j(l,"Map"),O=j(Object,"create"),A=E?E.prototype:void 0,T=A?A.toString:void 0;function N(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function R(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function x(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function C(t,e,n){var r=t[e];b.call(t,e)&&F(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function P(t,e){for(var n=t.length;n--;)if(F(t[n][0],e))return n;return-1}function L(t){return!(!$(t)||(e=t,v&&v in e))&&(function(t){var e=$(t)?w.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?_:a).test(function(t){if(null!=t){try{return m.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function U(t,e,o,i){if(!$(t))return t;for(var s=-1,a=(e=function(t,e){if(W(t))return!1;var o=typeof t;if("number"==o||"symbol"==o||"boolean"==o||null==t||V(t))return!0;return r.test(t)||!n.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:function(t){return W(t)?t:M(t)}(e)).length,u=a-1,c=t;null!=c&&++s<a;){var f=B(e[s]),l=o;if(s!=u){var h=c[f];void 0===(l=i?i(h,f,c):void 0)&&(l=$(h)?h:k(e[s+1])?[]:{})}C(c,f,l),c=c[f]}return t}function D(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function j(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return L(n)?n:void 0}function k(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||u.test(t))&&t>-1&&t%1==0&&t<e}N.prototype.clear=function(){this.__data__=O?O(null):{}},N.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},N.prototype.get=function(t){var e=this.__data__;if(O){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return b.call(e,t)?e[t]:void 0},N.prototype.has=function(t){var e=this.__data__;return O?void 0!==e[t]:b.call(e,t)},N.prototype.set=function(t,e){return this.__data__[t]=O&&void 0===e?"__lodash_hash_undefined__":e,this},R.prototype.clear=function(){this.__data__=[]},R.prototype.delete=function(t){var e=this.__data__,n=P(e,t);return!(n<0)&&(n==e.length-1?e.pop():I.call(e,n,1),!0)},R.prototype.get=function(t){var e=this.__data__,n=P(e,t);return n<0?void 0:e[n][1]},R.prototype.has=function(t){return P(this.__data__,t)>-1},R.prototype.set=function(t,e){var n=this.__data__,r=P(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},x.prototype.clear=function(){this.__data__={hash:new N,map:new(S||R),string:new N}},x.prototype.delete=function(t){return D(this,t).delete(t)},x.prototype.get=function(t){return D(this,t).get(t)},x.prototype.has=function(t){return D(this,t).has(t)},x.prototype.set=function(t,e){return D(this,t).set(t,e),this};var M=q((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(V(t))return T?T.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return o.test(t)&&n.push(""),t.replace(i,(function(t,e,r,o){n.push(r?o.replace(s,"$1"):e||t)})),n}));function B(t){if("string"==typeof t||V(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function q(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(q.Cache||x),n}function F(t,e){return t===e||t!=t&&e!=e}q.Cache=x;var W=Array.isArray;function $(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function V(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==w.call(t)}t.exports=function(t,e,n){return null==t?t:U(t,e,n)}}).call(this,n(7))},function(t,e,n){(function(e){var n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/,o=/^\./,i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g,a=/^\[object .+?Constructor\]$/,u="object"==typeof e&&e&&e.Object===Object&&e,c="object"==typeof self&&self&&self.Object===Object&&self,f=u||c||Function("return this")();var l,h=Array.prototype,p=Function.prototype,d=Object.prototype,y=f["__core-js_shared__"],g=(l=/[^.]+$/.exec(y&&y.keys&&y.keys.IE_PROTO||""))?"Symbol(src)_1."+l:"",v=p.toString,m=d.hasOwnProperty,b=d.toString,w=RegExp("^"+v.call(m).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_=f.Symbol,E=h.splice,I=D(f,"Map"),S=D(Object,"create"),O=_?_.prototype:void 0,A=O?O.toString:void 0;function T(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function N(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function R(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function x(t,e){for(var n,r,o=t.length;o--;)if((n=t[o][0])===(r=e)||n!=n&&r!=r)return o;return-1}function C(t){return!(!F(t)||(e=t,g&&g in e))&&(function(t){var e=F(t)?b.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?w:a).test(function(t){if(null!=t){try{return v.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function P(t,e){t=function(t,e){return 1==e.length?t:function(t,e){for(var n=0,r=(e=j(e,t)?[e]:L(e)).length;null!=t&&n<r;)t=t[M(e[n++])];return n&&n==r?t:void 0}(t,function(t,e,n){var r=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var i=Array(o);++r<o;)i[r]=t[r+e];return i}(e,0,-1))}(t,e=j(e,t)?[e]:L(e));var n,r,o=M((r=(n=e)?n.length:0)?n[r-1]:void 0);return!(null!=t&&m.call(t,o))||delete t[o]}function L(t){return q(t)?t:k(t)}function U(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function D(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return C(n)?n:void 0}function j(t,e){if(q(t))return!1;var o=typeof t;return!("number"!=o&&"symbol"!=o&&"boolean"!=o&&null!=t&&!W(t))||(r.test(t)||!n.test(t)||null!=e&&t in Object(e))}T.prototype.clear=function(){this.__data__=S?S(null):{}},T.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},T.prototype.get=function(t){var e=this.__data__;if(S){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return m.call(e,t)?e[t]:void 0},T.prototype.has=function(t){var e=this.__data__;return S?void 0!==e[t]:m.call(e,t)},T.prototype.set=function(t,e){return this.__data__[t]=S&&void 0===e?"__lodash_hash_undefined__":e,this},N.prototype.clear=function(){this.__data__=[]},N.prototype.delete=function(t){var e=this.__data__,n=x(e,t);return!(n<0)&&(n==e.length-1?e.pop():E.call(e,n,1),!0)},N.prototype.get=function(t){var e=this.__data__,n=x(e,t);return n<0?void 0:e[n][1]},N.prototype.has=function(t){return x(this.__data__,t)>-1},N.prototype.set=function(t,e){var n=this.__data__,r=x(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},R.prototype.clear=function(){this.__data__={hash:new T,map:new(I||N),string:new T}},R.prototype.delete=function(t){return U(this,t).delete(t)},R.prototype.get=function(t){return U(this,t).get(t)},R.prototype.has=function(t){return U(this,t).has(t)},R.prototype.set=function(t,e){return U(this,t).set(t,e),this};var k=B((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(W(t))return A?A.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return o.test(t)&&n.push(""),t.replace(i,(function(t,e,r,o){n.push(r?o.replace(s,"$1"):e||t)})),n}));function M(t){if("string"==typeof t||W(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function B(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(B.Cache||R),n}B.Cache=R;var q=Array.isArray;function F(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function W(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==b.call(t)}t.exports=function(t,e){return null==t||P(t,e)}}).call(this,n(7))},function(t,e,n){(function(t,n){var r="[object Arguments]",o="[object Function]",i="[object GeneratorFunction]",s="[object Map]",a="[object Set]",u=/\w*$/,c=/^\[object .+?Constructor\]$/,f=/^(?:0|[1-9]\d*)$/,l={};l[r]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object DataView]"]=l["[object Boolean]"]=l["[object Date]"]=l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l[s]=l["[object Number]"]=l["[object Object]"]=l["[object RegExp]"]=l[a]=l["[object String]"]=l["[object Symbol]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l["[object Error]"]=l[o]=l["[object WeakMap]"]=!1;var h="object"==typeof t&&t&&t.Object===Object&&t,p="object"==typeof self&&self&&self.Object===Object&&self,d=h||p||Function("return this")(),y=e&&!e.nodeType&&e,g=y&&"object"==typeof n&&n&&!n.nodeType&&n,v=g&&g.exports===y;function m(t,e){return t.set(e[0],e[1]),t}function b(t,e){return t.add(e),t}function w(t,e,n,r){var o=-1,i=t?t.length:0;for(r&&i&&(n=t[++o]);++o<i;)n=e(n,t[o],o,t);return n}function _(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function E(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function I(t,e){return function(n){return t(e(n))}}function S(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}var O,A=Array.prototype,T=Function.prototype,N=Object.prototype,R=d["__core-js_shared__"],x=(O=/[^.]+$/.exec(R&&R.keys&&R.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"",C=T.toString,P=N.hasOwnProperty,L=N.toString,U=RegExp("^"+C.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),D=v?d.Buffer:void 0,j=d.Symbol,k=d.Uint8Array,M=I(Object.getPrototypeOf,Object),B=Object.create,q=N.propertyIsEnumerable,F=A.splice,W=Object.getOwnPropertySymbols,$=D?D.isBuffer:void 0,V=I(Object.keys,Object),H=gt(d,"DataView"),G=gt(d,"Map"),J=gt(d,"Promise"),K=gt(d,"Set"),Y=gt(d,"WeakMap"),z=gt(Object,"create"),Q=_t(H),Z=_t(G),X=_t(J),tt=_t(K),et=_t(Y),nt=j?j.prototype:void 0,rt=nt?nt.valueOf:void 0;function ot(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function it(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function st(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function at(t){this.__data__=new it(t)}function ut(t,e){var n=It(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&St(t)}(t)&&P.call(t,"callee")&&(!q.call(t,"callee")||L.call(t)==r)}(t)?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],o=n.length,i=!!o;for(var s in t)!e&&!P.call(t,s)||i&&("length"==s||bt(s,o))||n.push(s);return n}function ct(t,e,n){var r=t[e];P.call(t,e)&&Et(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function ft(t,e){for(var n=t.length;n--;)if(Et(t[n][0],e))return n;return-1}function lt(t,e,n,c,f,h,p){var d;if(c&&(d=h?c(t,f,h,p):c(t)),void 0!==d)return d;if(!Tt(t))return t;var y=It(t);if(y){if(d=function(t){var e=t.length,n=t.constructor(e);e&&"string"==typeof t[0]&&P.call(t,"index")&&(n.index=t.index,n.input=t.input);return n}(t),!e)return function(t,e){var n=-1,r=t.length;e||(e=Array(r));for(;++n<r;)e[n]=t[n];return e}(t,d)}else{var g=mt(t),v=g==o||g==i;if(Ot(t))return function(t,e){if(e)return t.slice();var n=new t.constructor(t.length);return t.copy(n),n}(t,e);if("[object Object]"==g||g==r||v&&!h){if(_(t))return h?t:{};if(d=function(t){return"function"!=typeof t.constructor||wt(t)?{}:(e=M(t),Tt(e)?B(e):{});var e}(v?{}:t),!e)return function(t,e){return dt(t,vt(t),e)}(t,function(t,e){return t&&dt(e,Nt(e),t)}(d,t))}else{if(!l[g])return h?t:{};d=function(t,e,n,r){var o=t.constructor;switch(e){case"[object ArrayBuffer]":return pt(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var n=e?pt(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t,e){var n=e?pt(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}(t,r);case s:return function(t,e,n){return w(e?n(E(t),!0):E(t),m,new t.constructor)}(t,r,n);case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,u.exec(t));return e.lastIndex=t.lastIndex,e}(t);case a:return function(t,e,n){return w(e?n(S(t),!0):S(t),b,new t.constructor)}(t,r,n);case"[object Symbol]":return i=t,rt?Object(rt.call(i)):{}}var i}(t,g,lt,e)}}p||(p=new at);var I=p.get(t);if(I)return I;if(p.set(t,d),!y)var O=n?function(t){return function(t,e,n){var r=e(t);return It(t)?r:function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}(r,n(t))}(t,Nt,vt)}(t):Nt(t);return function(t,e){for(var n=-1,r=t?t.length:0;++n<r&&!1!==e(t[n],n,t););}(O||t,(function(r,o){O&&(r=t[o=r]),ct(d,o,lt(r,e,n,c,o,t,p))})),d}function ht(t){return!(!Tt(t)||(e=t,x&&x in e))&&(At(t)||_(t)?U:c).test(_t(t));var e}function pt(t){var e=new t.constructor(t.byteLength);return new k(e).set(new k(t)),e}function dt(t,e,n,r){n||(n={});for(var o=-1,i=e.length;++o<i;){var s=e[o],a=r?r(n[s],t[s],s,n,t):void 0;ct(n,s,void 0===a?t[s]:a)}return n}function yt(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function gt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return ht(n)?n:void 0}ot.prototype.clear=function(){this.__data__=z?z(null):{}},ot.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},ot.prototype.get=function(t){var e=this.__data__;if(z){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return P.call(e,t)?e[t]:void 0},ot.prototype.has=function(t){var e=this.__data__;return z?void 0!==e[t]:P.call(e,t)},ot.prototype.set=function(t,e){return this.__data__[t]=z&&void 0===e?"__lodash_hash_undefined__":e,this},it.prototype.clear=function(){this.__data__=[]},it.prototype.delete=function(t){var e=this.__data__,n=ft(e,t);return!(n<0)&&(n==e.length-1?e.pop():F.call(e,n,1),!0)},it.prototype.get=function(t){var e=this.__data__,n=ft(e,t);return n<0?void 0:e[n][1]},it.prototype.has=function(t){return ft(this.__data__,t)>-1},it.prototype.set=function(t,e){var n=this.__data__,r=ft(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},st.prototype.clear=function(){this.__data__={hash:new ot,map:new(G||it),string:new ot}},st.prototype.delete=function(t){return yt(this,t).delete(t)},st.prototype.get=function(t){return yt(this,t).get(t)},st.prototype.has=function(t){return yt(this,t).has(t)},st.prototype.set=function(t,e){return yt(this,t).set(t,e),this},at.prototype.clear=function(){this.__data__=new it},at.prototype.delete=function(t){return this.__data__.delete(t)},at.prototype.get=function(t){return this.__data__.get(t)},at.prototype.has=function(t){return this.__data__.has(t)},at.prototype.set=function(t,e){var n=this.__data__;if(n instanceof it){var r=n.__data__;if(!G||r.length<199)return r.push([t,e]),this;n=this.__data__=new st(r)}return n.set(t,e),this};var vt=W?I(W,Object):function(){return[]},mt=function(t){return L.call(t)};function bt(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||f.test(t))&&t>-1&&t%1==0&&t<e}function wt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||N)}function _t(t){if(null!=t){try{return C.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Et(t,e){return t===e||t!=t&&e!=e}(H&&"[object DataView]"!=mt(new H(new ArrayBuffer(1)))||G&&mt(new G)!=s||J&&"[object Promise]"!=mt(J.resolve())||K&&mt(new K)!=a||Y&&"[object WeakMap]"!=mt(new Y))&&(mt=function(t){var e=L.call(t),n="[object Object]"==e?t.constructor:void 0,r=n?_t(n):void 0;if(r)switch(r){case Q:return"[object DataView]";case Z:return s;case X:return"[object Promise]";case tt:return a;case et:return"[object WeakMap]"}return e});var It=Array.isArray;function St(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}(t.length)&&!At(t)}var Ot=$||function(){return!1};function At(t){var e=Tt(t)?L.call(t):"";return e==o||e==i}function Tt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Nt(t){return St(t)?ut(t):function(t){if(!wt(t))return V(t);var e=[];for(var n in Object(t))P.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}n.exports=function(t){return lt(t,!0,!0)}}).call(this,n(7),n(32)(t))},function(t,e,n){n(15),t.exports=n(16)},function(t,e,n){var r=function(t){"use strict";var e=Object.prototype,n=e.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",a=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function c(t,e,n,o){var i=e&&e.prototype instanceof h?e:h,s=Object.create(i.prototype),a=new O(o||[]);return r(s,"_invoke",{value:_(t,n,a)}),s}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function h(){}function p(){}function d(){}var y={};u(y,i,(function(){return this}));var g=Object.getPrototypeOf,v=g&&g(g(A([])));v&&v!==e&&n.call(v,i)&&(y=v);var m=d.prototype=h.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var o;r(this,"_invoke",{value:function(r,i){function s(){return new e((function(o,s){!function r(o,i,s,a){var u=f(t[o],t,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,s,a)}),(function(t){r("throw",t,s,a)})):e.resolve(l).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,a)}))}a(u.arg)}(r,i,o,s)}))}return o=o?o.then(s,s):s()}})}function _(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return T()}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var a=E(s,n);if(a){if(a===l)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=f(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function E(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=f(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,l;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function A(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return p.prototype=d,r(m,"constructor",{value:d,configurable:!0}),r(d,"constructor",{value:p,configurable:!0}),p.displayName=u(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,u(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),u(w.prototype,s,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new w(c(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},b(m),u(m,a,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=A,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return s.type="throw",s.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var a=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(a&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;S(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:A(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=r(n(38)),i=n(36),s=n(30),a=n(31),u=n(37),c=n(33),f=n(35),l=r(n(34)).default.version;o.default.registerVersion(l);try{i.registerAuth(o.default),s.registerFunctions(o.default),a.registerStorage(o.default),f.registerDatabase(o.default),u.registerRealtime(o.default),c.registerAnalytics(o.default)}catch(t){}try{window.cloudbase=o.default}catch(t){}e.default=o.default,t.exports=o.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var s,a=i(n(19)),u=n(4);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(s=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t){for(var e=0,n=u.isArray(t)?t:[t];e<n.length;e++){var r=n[e],o=r.isMatch,i=r.genAdapter,s=r.runtime;if(o())return{adapter:i(),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:a.genAdapter(),runtime:s.WEB}}},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=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)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return(i=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}).apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=n(3),c=n(4),f=n(8),l=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return o(e,t),e.prototype.get=function(t){return this.request(i(i({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(i(i({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,o=t.method,s=t.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",r),c.append("file",n),this.request(i(i({},t),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,n,r,o;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,u=t.headers,l=void 0===u?{}:u,h=t.data,p=t.responseType,d=t.withCredentials,y=t.body,g=t.onUploadProgress,v=c.formatUrl(f.getProtocol(),a,"get"===r?h:{}),m=new XMLHttpRequest;m.open(r,v),p&&(m.responseType=p),Object.keys(l).forEach((function(t){m.setRequestHeader(t,l[t])})),g&&m.upload.addEventListener("progress",g),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o})),t.header=n,t.statusCode=m.status;try{t.data="blob"===p?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===p?m.response:m.responseText}clearTimeout(i),o(t)}},e&&n.timeout&&(i=setTimeout((function(){console.warn(n.timeoutMsg),m.abort()}),n.timeout)),s=c.isFormData(h)?h:"application/x-www-form-urlencoded"===l["content-type"]?c.toQueryString(h):y||(h?JSON.stringify(h):void 0),d&&(m.withCredentials=!0),m.send(s)}))},e}(u.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},function(t,e,n){var r;t.exports=(r=n(5),n(21),n(22),r.HmacSHA256)},function(t,e,n){var r;t.exports=(r=n(5),function(t){var e=r,n=e.lib,o=n.WordArray,i=n.Hasher,s=e.algo,a=[],u=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)e(r)&&(o<8&&(a[o]=n(t.pow(r,.5))),u[o]=n(t.pow(r,1/3)),o++),r++}();var c=[],f=s.SHA256=i.extend({_doReset:function(){this._hash=new o.init(a.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],a=n[4],f=n[5],l=n[6],h=n[7],p=0;p<64;p++){if(p<16)c[p]=0|t[e+p];else{var d=c[p-15],y=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=c[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;c[p]=y+c[p-7]+v+c[p-16]}var m=r&o^r&i^o&i,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),w=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&l)+u[p]+c[p];h=l,l=f,f=a,a=s+w|0,s=i,i=o,o=r,r=w+(b+m)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+f|0,n[6]=n[6]+l|0,n[7]=n[7]+h|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,o=8*e.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=t.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=i._createHelper(f),e.HmacSHA256=i._createHmacHelper(f)}(Math),r.SHA256)},function(t,e,n){var r,o,i,s;t.exports=(r=n(5),i=(o=r).lib.Base,s=o.enc.Utf8,void(o.algo.HMAC=i.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=s.parse(e));var n=t.blockSize,r=4*n;e.sigBytes>r&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),i=this._iKey=e.clone(),a=o.words,u=i.words,c=0;c<n;c++)a[c]^=1549556828,u[c]^=909522486;o.sigBytes=i.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,n=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(n))}})))},function(t,e,n){var r,o,i;t.exports=(i=n(5),o=(r=i).lib.WordArray,r.enc.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp();for(var o=[],i=0;i<n;i+=3)for(var s=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a<n;a++)o.push(r.charAt(s>>>6*(3-a)&63));var u=r.charAt(64);if(u)for(;o.length%4;)o.push(u);return o.join("")},parse:function(t){var e=t.length,n=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var i=0;i<n.length;i++)r[n.charCodeAt(i)]=i}var s=n.charAt(64);if(s){var a=t.indexOf(s);-1!==a&&(e=a)}return function(t,e,n){for(var r=[],i=0,s=0;s<e;s++)if(s%4){var a=n[t.charCodeAt(s-1)]<<s%4*2,u=n[t.charCodeAt(s)]>>>6-s%4*2;r[i>>>2]|=(a|u)<<24-i%4*8,i++}return o.create(r,i)}(t,e,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)},function(t,e,n){var r;t.exports=(r=n(5),r.enc.Utf8)},function(t,e,n){"use strict";(function(t){var r,o=this&&this.__extends||(r=function(t,e){return(r=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)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=n(3),u=n(4),c=n(6),f=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return o(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(a.AbstractStorage);var l=function(){function e(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,o=t.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:(u.printWarn(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(e.root));case"none":return new f(e.root);default:return e.localStorage?e.localStorage:(u.printWarn(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(e.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"["+c.getSdkName()+"]["+c.ERRORS.OPERATION_FAIL+"]setStore failed",info:t}))}}else u.printWarn(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(t,e,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,n){var r;if("async"!==this.mode){try{if(void 0!==t&&(null===(r=t.env)||void 0===r?void 0:r.tcb_token))return t.env.tcb_token;if(!this.storage)return""}catch(t){return""}n=n||"localCachev1";var o=this.storage.getItem(e);return o&&o.indexOf(n)>=0?JSON.parse(o).content:""}u.printWarn(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,n){var r;return i(this,void 0,void 0,(function(){var o;return s(this,(function(i){switch(i.label){case 0:try{if(void 0!==t&&(null===(r=t.env)||void 0===r?void 0:r.tcb_token))return[2,t.env.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return n=n||"localCachev1",[4,this.storage.getItem(e)];case 1:return(o=i.sent())&&o.indexOf(n)>=0?[2,JSON.parse(o).content]:[2,""]}}))}))},e.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):u.printWarn(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},e}();e.CloudbaseCache=l}).call(this,n(9))},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=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)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__spreadArrays||function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=n(4);var a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var u=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return o(e,t),e}(a);e.IErrorEvent=u;var c=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(s.isInstanceOf(t,u))return console.error(t.error),this;var n=s.isString(t)?new a(t,e||{}):t,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,c=this.listeners[r]?i(this.listeners[r]):[];o<c.length;o++){c[o].call(this,n)}}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=c;var f=new c;e.addEventListener=function(t,e){f.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),f.fire(t,e)},e.removeEventListener=function(t,e){f.off(t,e)}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(28),e)},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=n(4),s=n(6),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function f(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]\\s*\\(.*\\)$"),f=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]"),l=s.findIndex((function(t){return u.test(t)}));if(-1!==l){var h=s.filter((function(t,e){return e>l}));h.unshift(s[l].replace(f,n+"."+r).replace(c,o)),(i=new Error).stack=(a?"@debugger":"Error")+"\n"+h.join("\n")}return i}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,a=t.customInfo,l=void 0===a?{}:a,h=t.title,p=t.messages,d=void 0===p?[]:p;return function(t,e,a){if(s.IS_DEBUG_MODE){var p=l.className||t.constructor.name,y=l.methodName||e,g=a.value,v=function(t){var e="",n=t.stack.split("\n"),r=n.findIndex((function(t){return u.test(t)}));if(-1!==r){var o=c.exec(n[r+1]||"");e=o?o[0]:""}return e}(new Error);a.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=f({err:new Error,className:p,methodName:y,sourceLink:v});try{return g.apply(this,t)}catch(t){var r=t,o=t.message,s=t.error,a=t.error_description,u={title:h||p+"."+y+" failed",content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(n?(n.code=c.code,n.msg=c.msg):(t.code=c.code,t.message=c.msg),r=n||t,u.content=d.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(u.subtitle=a,n?(n.code=s,n.msg=a):(t.code=s,t.message=a),r=n||t,u.content=d.map((function(t){return{type:"info",body:t}}))),i.printGroupLog(u),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r(this,void 0,void 0,(function(){var e,n,r,s,a,u,c,l;return o(this,(function(o){switch(o.label){case 0:e=f({err:new Error,className:p,methodName:y,sourceLink:v}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,g.apply(this,t)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,a=n.error,u=n.error_description,c={title:h||p+"."+y+" failed",content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),c.subtitle=l,l.code&&(e?(e.code=l.code,e.message=l.msg):(n.code=l.code,n.message=l.msg),r=e||n,c.content=d.map((function(t){return{type:"info",body:t}})))),a&&u&&(c.subtitle=u,e?(e.code=a,e.msg=u):(n.code=a,n.message=u),r=e||n,c.content=d.map((function(t){return{type:"info",body:t}}))),i.printGroupLog(c),r;case 4:return[2]}}))}))}}}}},function(t,e,n){"use strict";function r(t){this.message=t}n.r(e),n.d(e,"InvalidTokenError",(function(){return s})),r.prototype=new Error,r.prototype.name="InvalidCharacterError";var o="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,s=0,a="";o=e.charAt(s++);~o&&(n=i%4?64*n+o:o,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return a};function i(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(o(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return o(e)}}function s(t){this.message=t}s.prototype=new Error,s.prototype.name="InvalidTokenError",e.default=function(t,e){if("string"!=typeof t)throw new s("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(i(t.split(".")[n]))}catch(t){throw new s("Invalid token specified: "+t.message)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"registerFunctions",(function(){return d}));var r=n(0),o=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},i=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},u=r.constants.getSdkName,c=r.constants.ERRORS,f=r.constants.COMMUNITY_SITE_URL,l=r.utils.execCallback,h=r.helpers.catchErrorsDecorator,p={name:"functions",entity:{callFunction:(new(function(){function t(){}return t.prototype.callFunction=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s,f,h,p,d,y,g,v;return a(this,(function(a){switch(a.label){case 0:if(n=t.name,r=t.data,o=t.query,i=t.parse,s=t.search,!n)throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[functions.callFunction] invalid function name"}));try{f=r?JSON.stringify(r):""}catch(t){throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[functions.callFunction] invalid data"}))}h="functions.invokeFunction",p={inQuery:o,parse:i,search:s,function_name:n,request_data:f},d=this.request,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,d.send(h,p)];case 2:if((y=a.sent()).code)return[2,l(e,null,y)];if(g=y.data.response_data,i)return[2,l(e,null,{result:g,requestId:y.requestId})];try{return g=JSON.parse(y.data.response_data),[2,l(e,null,{result:g,requestId:y.requestId})]}catch(t){l(e,new Error("["+u()+"]["+c.INVALID_PARAMS+"][functions.callFunction] response data must be json"))}return[3,4];case 3:return v=a.sent(),l(e,v),[3,4];case 4:return[2]}}))}))},o([h({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"callFunction",null),t}())).callFunction}};try{cloudbase.registerComponent(p)}catch(t){}function d(t){try{t.registerComponent(p)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"registerStorage",(function(){return w}));var r,o=n(0),i=function(){return(i=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}).apply(this,arguments)},s=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},a=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},u=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},c=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}};!function(t){t.put="put",t.post="post"}(r||(r={}));var f=o.constants.getSdkName,l=o.constants.ERRORS,h=o.constants.COMMUNITY_SITE_URL,p=o.utils.isArray,d=o.utils.isString,y=o.utils.isPalinObject,g=o.utils.execCallback,v=o.helpers.catchErrorsDecorator,m=new(function(){function t(){}return t.prototype.uploadFile=function(t,e){return u(this,void 0,void 0,(function(){var n,o,s,a,u,h,p,y,v,m,b,w,_,E,I,S,O,A,T,N,R,x,C,P,L;return c(this,(function(c){switch(c.label){case 0:if(n=t.cloudPath,o=t.filePath,s=t.onUploadProgress,a=t.method,u=void 0===a?"put":a,h=t.headers,p=void 0===h?{}:h,!d(n)||!o)throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.uploadFile] invalid params"}));return y={put:r.put,post:r.post}[u.toLocaleLowerCase()]||r.put,"storage.getUploadMetadata",v=this.request,m={path:n,method:y},y===r.put&&(m.headers=p),[4,v.send("storage.getUploadMetadata",m)];case 1:return b=c.sent(),w=b.data,_=w.url,E=w.authorization,I=w.token,S=w.fileId,O=w.cosFileId,A=w.download_url,T=b.requestId,R=i(i({},N={url:_,file:o,name:n,onUploadProgress:s}),{method:r.put,headers:i(i({},p),{authorization:E,"x-cos-meta-fileid":O,"x-cos-security-token":I})}),x=i(i({},N),{method:r.post,data:{key:n,signature:E,"x-cos-meta-fileid":O,success_action_status:"201","x-cos-security-token":I}}),(L={})[r.put]={params:R,isSuccess:function(t){return t>=200&&t<300}},L[r.post]={params:x,isSuccess:function(t){return 201===t}},C=L,[4,v.upload(C[y].params)];case 2:return P=c.sent(),C[y].isSuccess(P.statusCode)?[2,g(e,null,{fileID:S,download_url:A,requestId:T})]:[2,g(e,new Error("["+f()+"]["+l.OPERATION_FAIL+"][storage]:"+P.data))]}}))}))},t.prototype.getUploadMetadata=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s;return c(this,(function(a){switch(a.label){case 0:if(n=t.cloudPath,!d(n))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getUploadMetadata] invalid cloudPath"}));r=this.request,o="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.send(o,{path:n})];case 2:return i=a.sent(),[2,g(e,null,i)];case 3:return s=a.sent(),[2,g(e,s)];case 4:return[2]}}))}))},t.prototype.deleteFile=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(!(n=t.fileList)||!p(n)||0===n.length)throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.deleteFile] fileList must not be empty"}));for(r=0,o=n;r<o.length;r++)if(!(i=o[r])||!d(i))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.deleteFile] fileID must be string"}));return"storage.batchDeleteFile",[4,this.request.send("storage.batchDeleteFile",{fileid_list:n})];case 1:return(s=u.sent()).code?[2,g(e,null,s)]:(a={fileList:s.data.delete_list,requestId:s.requestId},[2,g(e,null,a)])}}))}))},t.prototype.getTempFileURL=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(!(n=t.fileList)||!p(n)||0===n.length)throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getTempFileURL] fileList must not be empty"}));for(r=[],o=0,i=n;o<i.length;o++)if(s=i[o],y(s)){if(!Object.prototype.hasOwnProperty.call(s,"fileID")||!Object.prototype.hasOwnProperty.call(s,"maxAge"))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getTempFileURL] file info must include fileID and maxAge"}));r.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!d(s))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getTempFileURL] invalid fileList"}));r.push({fileid:s})}return"storage.batchGetDownloadUrl",[4,this.request.send("storage.batchGetDownloadUrl",{file_list:r})];case 1:return(a=u.sent()).code?[2,g(e,null,a)]:[2,g(e,null,{fileList:a.data.download_list,requestId:a.requestId})]}}))}))},t.prototype.downloadFile=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(n=t.fileID,!d(n))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getTempFileURL] fileID must be string"}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}]})];case 1:return r=u.sent(),"SUCCESS"!==(o=r.fileList[0]).code?[2,g(e,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return a=u.sent(),[2,g(e,null,a)]}}))}))},s([v({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"uploadFile",null),s([v({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"getUploadMetadata",null),s([v({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"deleteFile",null),s([v({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"getTempFileURL",null),s([v({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"downloadFile",null),t}()),b={name:"storage",entity:{uploadFile:m.uploadFile,deleteFile:m.deleteFile,getTempFileURL:m.getTempFileURL,downloadFile:m.downloadFile,getUploadMetadata:m.getUploadMetadata}};try{cloudbase.registerComponent(b)}catch(t){}function w(t){try{t.registerComponent(b)}catch(t){console.warn(t)}}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){"use strict";n.r(e),n.d(e,"registerAnalytics",(function(){return p}));var r=n(0),o=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},i=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},u=r.constants.ERRORS,c=r.constants.COMMUNITY_SITE_URL,f=r.helpers.catchErrorsDecorator,l=["mall"];var h={name:"analytics",entity:{analytics:(new(function(){function t(){}return t.prototype.analytics=function(t){return s(this,void 0,void 0,(function(){var e,n,r;return a(this,(function(o){if(!function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))return!1;var e=t.report_data,n=t.report_type;return!1!==l.includes(n)&&("Object"===Object.prototype.toString.call(e).slice(8,-1)&&(!(void 0!==e.action_time&&!Number.isInteger(e.action_time))&&"string"==typeof e.action_type))}(t))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat("analytics",".analytics] invalid report data")}));return"analytics.report",e=void 0===t.report_data.action_time?Math.floor(Date.now()/1e3):t.report_data.action_time,n={analytics_scene:t.report_type,analytics_data:Object.assign({},t.report_data,{action_time:e})},r={requestData:n},this.request.send("analytics.report",r),[2]}))}))},o([f({customInfo:{className:"Cloudbase",methodName:"analytics"},title:"上报调用失败",messages:["请确认以下各项:"," 1 - 调用 analytics() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(c)]}),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],t.prototype,"analytics",null),t}())).analytics}};try{cloudbase.registerComponent(h)}catch(t){}function p(t){try{t.registerComponent(h)}catch(t){console.warn(t)}}},function(t){t.exports=JSON.parse('{"version":"2.5.5-alpha.0"}')},function(t,e,n){"use strict";n.r(e),n.d(e,"registerDatabase",(function(){return we}));var r,o,i={};n.r(i),n.d(i,"Point",(function(){return ct})),n.d(i,"LineString",(function(){return K})),n.d(i,"Polygon",(function(){return z})),n.d(i,"MultiPoint",(function(){return Z})),n.d(i,"MultiLineString",(function(){return tt})),n.d(i,"MultiPolygon",(function(){return nt})),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a="Number",u="Object",c="Array",f="GeoPoint",l="GeoLineString",h="GeoPolygon",p="GeoMultiPoint",d="GeoMultiLineString",y="GeoMultiPolygon",g="Date",v="ServerDate",m="BsonDate",b=["desc","asc"],w=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(s||(s={}));var _;(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte";!function(t){t.WHERE="WHERE",t.DOC="DOC"}(_||(_={}));var E,I=(E=function(t,e){return(E=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)},function(t,e){function n(){this.constructor=t}E(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),S=[],O={},A=function(t){function e(e,n){if(n!==O)throw new TypeError("InternalSymbol cannot be constructed with new operator");return t.call(this,e)||this}return I(e,t),e.for=function(t){for(var n=0,r=S.length;n<r;n++)if(S[n].target===t)return S[n].instance;var o=new e(t,O);return S.push({target:t,instance:o}),o},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})})),T=A,N=T.for("UNSET_FIELD_NAME"),R=T.for("UPDATE_COMMAND"),x=T.for("QUERY_COMMAND"),C=T.for("LOGIC_COMMAND"),P=T.for("GEO_POINT"),L=T.for("SYMBOL_GEO_LINE_STRING"),U=T.for("SYMBOL_GEO_POLYGON"),D=T.for("SYMBOL_GEO_MULTI_POINT"),j=T.for("SYMBOL_GEO_MULTI_LINE_STRING"),k=T.for("SYMBOL_GEO_MULTI_POLYGON"),M=T.for("SERVER_DATE"),B=T.for("REGEXP"),q=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},F=function(t){return"object"===q(t)},W=function(t){return"number"===q(t)},$=function(t){return Array.isArray(t)},V=function(t){return"date"===q(t)},H=function(t){return"regexp"===q(t)},G=function(t){return t&&t._internalType instanceof A},J=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.")},K=function(){function t(t){if(!$(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 ct))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||!$(t.coordinates))return!1;try{for(var r=J(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!W(i[0])||!W(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 L},enumerable:!0,configurable:!0}),t}(),Y=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.")},z=function(){function t(t){if(!$(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 K))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]");if(!K.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||!$(t.coordinates))return!1;try{for(var i=Y(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var u=(r=void 0,Y(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!W(f[0])||!W(f[1]))return!1}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.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 k},enumerable:!0,configurable:!0}),t}(),Q=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.")},Z=function(){function t(t){if(!$(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 ct))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||!$(t.coordinates))return!1;try{for(var r=Q(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!W(i[0])||!W(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 D},enumerable:!0,configurable:!0}),t}(),X=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.")},tt=function(){function t(t){if(!$(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 K))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||!$(t.coordinates))return!1;try{for(var i=X(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var u=(r=void 0,X(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!W(f[0])||!W(f[1]))return!1}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),t}(),et=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.")},nt=function(){function t(t){var e,n;if(!$(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=et(t),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof z))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,s;if("MultiPolygon"!==t.type||!$(t.coordinates))return!1;try{for(var a=et(t.coordinates),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var f=(r=void 0,et(c)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,et(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!W(y[0])||!W(y[1]))return!1}}catch(t){i={error:t}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return U},enumerable:!0,configurable:!0}),t}(),rt=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 M},enumerable:!0,configurable:!0}),t.prototype.parse=function(){return{$date:{offset:this.offset}}},t}();function ot(t){return new rt(t)}var it,st=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},at=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 ct(i.coordinates[0],i.coordinates[1]);break;case l:o=new K(i.coordinates.map((function(t){return new ct(t[0],t[1])})));break;case h:o=new z(i.coordinates.map((function(t){return new K(t.map((function(t){var e=st(t,2),n=e[0],r=e[1];return new ct(n,r)})))})));break;case p:o=new Z(i.coordinates.map((function(t){return new ct(t[0],t[1])})));break;case d:o=new tt(i.coordinates.map((function(t){return new K(t.map((function(t){var e=st(t,2),n=e[0],r=e[1];return new ct(n,r)})))})));break;case y:o=new nt(i.coordinates.map((function(t){return new z(t.map((function(t){return new K(t.map((function(t){var e=st(t,2),n=e[0],r=e[1];return new ct(n,r)})))})))})));break;case g:o=new Date(1e3*i.$timestamp);break;case u:case c:o=t.formatField(i);break;case v: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===g)return m;if(e===u){if(t instanceof ct)return f;if(t instanceof Date)return g;if(t instanceof rt)return v;t.$timestamp?e=g:t.$date?e=v:ct.validate(t)?e=f:K.validate(t)?e=l:z.validate(t)?e=h:Z.validate(t)?e=p:tt.validate(t)?e=d:nt.validate(t)&&(e=y)}return e},t.generateDocId=function(){for(var t="ABCDEFabcdef0123456789",e="",n=0;n<24;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},t}(),ut=function(){function t(){}return t.isGeopoint=function(t,e){if(at.whichType(e)!==a)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===b.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}(),ct=function(){function t(t,e){ut.isGeopoint("longitude",t),ut.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&&$(t.coordinates)&&ut.isGeopoint("longitude",t.coordinates[0])&&ut.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return P},enumerable:!0,configurable:!0}),t}(),ft=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"}(it||(it={}));var lt=function(){function t(t,e,n){this._internalType=R,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||N}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function ht(t){return t&&t instanceof lt&&t._internalType===R}var pt;!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(pt||(pt={}));var dt=function(){function t(t,e,n){if(this._internalType=C,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||N,this.fieldName!==N)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++){(yt(i=e[r])||bt(i))&&(e[r]=i._setFieldName(this.fieldName))}}else{var i;(yt(i=e)||bt(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(pt.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(pt.OR,r,this.fieldName)},t}();function yt(t){return t&&t instanceof dt&&t._internalType===C}var gt,vt=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])})(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"}(gt||(gt={}));var mt=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 vt(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case gt.IN:case gt.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(gt.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(gt.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(gt.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(gt.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(gt.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(gt.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(gt.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(gt.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof ct))throw new TypeError('"geometry" must be of type Point. Received type '+typeof t.geometry);if(void 0!==t.maxDistance&&!W(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof t.maxDistance);if(void 0!==t.minDistance&&!W(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof t.minDistance);var n=new e(gt.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof nt||t.geometry instanceof z))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof t.geometry);var n=new e(gt.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof ct||t.geometry instanceof K||t.geometry instanceof z||t.geometry instanceof Z||t.geometry instanceof tt||t.geometry instanceof nt))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof t.geometry);var n=new e(gt.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(dt);function bt(t){return t&&t instanceof mt&&t._internalType===x}function wt(t){return bt(t)}var _t={};for(var Et in gt)_t[Et]="$"+Et;for(var Et in pt)_t[Et]="$"+Et;for(var Et in it)_t[Et]="$"+Et;function It(t){return _t[t]||"$"+t}_t[gt.NEQ]="$ne",_t[it.REMOVE]="$unset",_t[it.SHIFT]="$pop",_t[it.UNSHIFT]="$push";var St=function(){return(St=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}).apply(this,arguments)},Ot=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},At=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ot(arguments[e]));return t};function Tt(t){return function t(e,n){if(!G(e)){if(V(e))return{$date:+e};if(H(e))return{$regex:e.source,$options:e.flags};if($(e))return e.map((function(e){if(n.indexOf(e)>-1)throw new Error("Cannot convert circular structure to JSON");return t(e,At(n,[e]))}));if(F(e)){var r=St({},e);for(var o in r){if(n.indexOf(r[o])>-1)throw new Error("Cannot convert circular structure to JSON");r[o]=t(r[o],At(n,[r[o]]))}return r}return e}switch(e._internalType){case P:return e.toJSON();case M:case B:return e.parse();default:return e.toJSON?e.toJSON():e}}(t,[t])}var Nt=function(){return(Nt=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}).apply(this,arguments)},Rt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},xt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Rt(arguments[e]));return t};function Ct(t,e,n,r){var o=Nt({},t);for(var i in t)if(!/^\$/.test(i)){var s=t[i];if(s&&F(s)&&!e(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Ct(s,e,xt(n,[i]),xt(r,[s]));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o[i+"."+c]=a[c],delete o[i][c]);u||delete o[i]}}return o}function Pt(t){return Ct(t,Ut,[],[t])}function Lt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?$(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 "+q(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+q(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]}function Ut(t){return G(t)||V(t)||H(t)}function Dt(t){return Tt(t)}var jt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return ht(t)?this.encodeUpdateCommand(t):"object"===q(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===N)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case it.PUSH:case it.PULL:case it.PULL_ALL:case it.POP:case it.SHIFT:case it.UNSHIFT:case it.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=It(t.operator);switch(t.operator){case it.REMOVE:return(e={})[i]=((n={})[t.fieldName]="",n),e;default:return(r={})[i]=((o={})[t.fieldName]=t.operands[0],o),r}},t.prototype.encodeArrayUpdateCommand=function(t){var e,n,r,o,i,s,a,u,c,f,l=It(t.operator);switch(t.operator){case it.PUSH:var h=void 0;return h=$(t.operands)?{$each:t.operands.map(Dt)}:t.operands,(e={})[l]=((n={})[t.fieldName]=h,n),e;case it.UNSHIFT:h={$each:t.operands.map(Dt),$position:0};return(r={})[l]=((o={})[t.fieldName]=h,o),r;case it.POP:return(i={})[l]=((s={})[t.fieldName]=1,s),i;case it.SHIFT:return(a={})[l]=((u={})[t.fieldName]=-1,u),a;default:return(c={})[l]=((f={})[t.fieldName]=Dt(t.operands),f),c}},t.prototype.encodeUpdateObject=function(t){var e=Pt(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(ht(r)){e[n]=r._setFieldName(n),Lt(e,this.encodeUpdateCommand(e[n]),n)}else{e[n]=r=Dt(r);var o=new lt(it.SET,[r],n);Lt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),kt={};function Mt(t){if(!ve.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return kt[e]||(kt[e]=new ve.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new ve.reqClass(t.config)}}})),kt[e]}var Bt=function(){return(Bt=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}).apply(this,arguments)},qt=function(){function t(t,e,n,r){var o=this;void 0===r&&(r={}),this.watch=function(t){return Mt(o._db).watch(Bt(Bt({},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 ve.reqClass(this._db.config),this.projection=r}return t.prototype.create=function(t,e){e=e||ft();var n={collectionName:this._coll,data:Tt(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||ft(),!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 lt?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:_.DOC,data:Tt(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||ft(),!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:_.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||ft();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:_.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||ft();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:_.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=at.formatResDocumentData(e.data.list);t(0,{data:n,requestId:e.requestId,total:e.TotalCount,limit:e.Limit,offset:e.Offset})}})).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}(),Ft=function(){function t(){}return t.encode=function(t){return(new Wt).encodeQuery(t)},t}(),Wt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return Ut(t)?yt(t)?this.encodeLogicCommand(t):bt(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,s,a,u=this;switch(t.operator){case pt.NOR:case pt.AND:case pt.OR:var c=It(t.operator),f=t.operands.map((function(e){return u.encodeQuery(e,t.fieldName)}));return(e={})[c]=f,e;case pt.NOT:c=It(t.operator);var l=t.operands[0];if(H(l))return(n={})[t.fieldName]=((r={})[c]=this.encodeRegExp(l),r),n;f=this.encodeQuery(l)[t.fieldName];return(o={})[t.fieldName]=((i={})[c]=f,i),o;default:c=It(t.operator);if(1===t.operands.length){var h=this.encodeQuery(t.operands[0]);return(s={})[c]=h,s}f=t.operands.map(this.encodeQuery.bind(this));return(a={})[c]=f,a}},t.prototype.encodeQueryCommand=function(t){return wt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,s,a,u,c;if(t.fieldName===N)throw new Error("Cannot encode a comparison command with unset field name");var f=It(t.operator);switch(t.operator){case gt.EQ:case gt.NEQ:case gt.LT:case gt.LTE:case gt.GT:case gt.GTE:case gt.ELEM_MATCH:case gt.EXISTS:case gt.SIZE:case gt.MOD:return(e={})[t.fieldName]=((n={})[f]=Dt(t.operands[0]),n),e;case gt.IN:case gt.NIN:case gt.ALL:return(r={})[t.fieldName]=((o={})[f]=Dt(t.operands),o),r;case gt.GEO_NEAR:var l=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case gt.GEO_WITHIN:l=t.operands[0];return(s={})[t.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case gt.GEO_INTERSECTS:l=t.operands[0];return(a={})[t.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(u={})[t.fieldName]=((c={})[f]=Dt(t.operands[0]),c),u}},t.prototype.encodeQueryObject=function(t){var e=Pt(t);for(var n in e){var r=e[n];if(yt(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else if(wt(r)){e[n]=r._setFieldName(n);o=this.encodeComparisonCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else Ut(r)&&(e[n]=Dt(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?$(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 "+q(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+q(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),$t=function(){return($t=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}).apply(this,arguments)},Vt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return Mt(i._db).watch($t($t({},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 ve.reqClass(this._db.config)}return t.prototype.get=function(t){t=t||ft();var e=[];this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)}));var n={collectionName:this._coll,queryType:_.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:at.formatResDocumentData(e.data.list),requestId:e.requestId};e.TotalCount&&(n.total=e.TotalCount),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||ft();var e={collectionName:this._coll,queryType:_.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,Ft.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){ut.isFieldPath(e),ut.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){ut.isInteger("limit",e);var n=$t({},this._queryOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){ut.isInteger("offset",e);var n=$t({},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||ft(),!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:_.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=$t({},this._queryOptions);return r.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.remove=function(t){t=t||ft(),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:Ft.encode(this._fieldFilters),queryType:_.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}(),Ht=n(2),Gt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},Jt=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},Kt=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=new ve.reqClass(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return Gt(this,void 0,void 0,(function(){var t;return Jt(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(Ht.a.parse)}]:[2,t]}}))}))},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=Ft.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new ct(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",Ft.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}(),Yt=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])})(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)}}(),zt=function(t){function e(e,n){return t.call(this,e,n)||this}return Yt(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 qt(this._db,this._coll,t)},e.prototype.add=function(t,e){return new qt(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new Kt(this._db,this._coll)},e}(Vt),Qt={eq:function(t){return new mt(gt.EQ,[t])},neq:function(t){return new mt(gt.NEQ,[t])},lt:function(t){return new mt(gt.LT,[t])},lte:function(t){return new mt(gt.LTE,[t])},gt:function(t){return new mt(gt.GT,[t])},gte:function(t){return new mt(gt.GTE,[t])},in:function(t){return new mt(gt.IN,t)},nin:function(t){return new mt(gt.NIN,t)},all:function(t){return new mt(gt.ALL,t)},elemMatch:function(t){return new mt(gt.ELEM_MATCH,[t])},exists:function(t){return new mt(gt.EXISTS,[t])},size:function(t){return new mt(gt.SIZE,[t])},mod:function(t){return new mt(gt.MOD,[t])},geoNear:function(t){return new mt(gt.GEO_NEAR,[t])},geoWithin:function(t){return new mt(gt.GEO_WITHIN,[t])},geoIntersects:function(t){return new mt(gt.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new dt(pt.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new dt(pt.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new dt(pt.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new dt(pt.NOT,n)},set:function(t){return new lt(it.SET,[t])},remove:function(){return new lt(it.REMOVE,[])},inc:function(t){return new lt(it.INC,[t])},mul:function(t){return new lt(it.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=$(e[0])?e[0]:Array.from(e);return new lt(it.PUSH,t)},pull:function(t){return new lt(it.PULL,t)},pullAll:function(t){return new lt(it.PULL_ALL,t)},pop:function(){return new lt(it.POP,[])},shift:function(){return new lt(it.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new lt(it.UNSHIFT,n)},addToSet:function(t){return new lt(it.ADD_TO_SET,t)},rename:function(t){return new lt(it.RENAME,[t])},bit:function(t){return new lt(it.BIT,[t])},max:function(t){return new lt(it.MAX,[t])},min:function(t){return new lt(it.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===q(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new Kt},abs:function(t){return new Zt("abs",t)},add:function(t){return new Zt("add",t)},ceil:function(t){return new Zt("ceil",t)},divide:function(t){return new Zt("divide",t)},exp:function(t){return new Zt("exp",t)},floor:function(t){return new Zt("floor",t)},ln:function(t){return new Zt("ln",t)},log:function(t){return new Zt("log",t)},log10:function(t){return new Zt("log10",t)},mod:function(t){return new Zt("mod",t)},multiply:function(t){return new Zt("multiply",t)},pow:function(t){return new Zt("pow",t)},sqrt:function(t){return new Zt("sqrt",t)},subtract:function(t){return new Zt("subtract",t)},trunc:function(t){return new Zt("trunc",t)},arrayElemAt:function(t){return new Zt("arrayElemAt",t)},arrayToObject:function(t){return new Zt("arrayToObject",t)},concatArrays:function(t){return new Zt("concatArrays",t)},filter:function(t){return new Zt("filter",t)},in:function(t){return new Zt("in",t)},indexOfArray:function(t){return new Zt("indexOfArray",t)},isArray:function(t){return new Zt("isArray",t)},map:function(t){return new Zt("map",t)},range:function(t){return new Zt("range",t)},reduce:function(t){return new Zt("reduce",t)},reverseArray:function(t){return new Zt("reverseArray",t)},size:function(t){return new Zt("size",t)},slice:function(t){return new Zt("slice",t)},zip:function(t){return new Zt("zip",t)},and:function(t){return new Zt("and",t)},not:function(t){return new Zt("not",t)},or:function(t){return new Zt("or",t)},cmp:function(t){return new Zt("cmp",t)},eq:function(t){return new Zt("eq",t)},gt:function(t){return new Zt("gt",t)},gte:function(t){return new Zt("gte",t)},lt:function(t){return new Zt("lt",t)},lte:function(t){return new Zt("lte",t)},neq:function(t){return new Zt("ne",t)},cond:function(t){return new Zt("cond",t)},ifNull:function(t){return new Zt("ifNull",t)},switch:function(t){return new Zt("switch",t)},dateFromParts:function(t){return new Zt("dateFromParts",t)},dateFromString:function(t){return new Zt("dateFromString",t)},dayOfMonth:function(t){return new Zt("dayOfMonth",t)},dayOfWeek:function(t){return new Zt("dayOfWeek",t)},dayOfYear:function(t){return new Zt("dayOfYear",t)},isoDayOfWeek:function(t){return new Zt("isoDayOfWeek",t)},isoWeek:function(t){return new Zt("isoWeek",t)},isoWeekYear:function(t){return new Zt("isoWeekYear",t)},millisecond:function(t){return new Zt("millisecond",t)},minute:function(t){return new Zt("minute",t)},month:function(t){return new Zt("month",t)},second:function(t){return new Zt("second",t)},hour:function(t){return new Zt("hour",t)},week:function(t){return new Zt("week",t)},year:function(t){return new Zt("year",t)},literal:function(t){return new Zt("literal",t)},mergeObjects:function(t){return new Zt("mergeObjects",t)},objectToArray:function(t){return new Zt("objectToArray",t)},allElementsTrue:function(t){return new Zt("allElementsTrue",t)},anyElementTrue:function(t){return new Zt("anyElementTrue",t)},setDifference:function(t){return new Zt("setDifference",t)},setEquals:function(t){return new Zt("setEquals",t)},setIntersection:function(t){return new Zt("setIntersection",t)},setIsSubset:function(t){return new Zt("setIsSubset",t)},setUnion:function(t){return new Zt("setUnion",t)},concat:function(t){return new Zt("concat",t)},dateToString:function(t){return new Zt("dateToString",t)},indexOfBytes:function(t){return new Zt("indexOfBytes",t)},indexOfCP:function(t){return new Zt("indexOfCP",t)},split:function(t){return new Zt("split",t)},strLenBytes:function(t){return new Zt("strLenBytes",t)},strLenCP:function(t){return new Zt("strLenCP",t)},strcasecmp:function(t){return new Zt("strcasecmp",t)},substr:function(t){return new Zt("substr",t)},substrBytes:function(t){return new Zt("substrBytes",t)},substrCP:function(t){return new Zt("substrCP",t)},toLower:function(t){return new Zt("toLower",t)},toUpper:function(t){return new Zt("toUpper",t)},meta:function(t){return new Zt("meta",t)},addToSet:function(t){return new Zt("addToSet",t)},avg:function(t){return new Zt("avg",t)},first:function(t){return new Zt("first",t)},last:function(t){return new Zt("last",t)},max:function(t){return new Zt("max",t)},min:function(t){return new Zt("min",t)},push:function(t){return new Zt("push",t)},stdDevPop:function(t){return new Zt("stdDevPop",t)},stdDevSamp:function(t){return new Zt("stdDevSamp",t)},sum:function(t){return new Zt("sum",t)},let:function(t){return new Zt("let",t)}},project:{slice:function(t){return new Xt("slice",t)},elemMatch:function(t){return new Xt("elemMatch",t)}}},Zt=function(t,e){this["$"+t]=e},Xt=function(t,e){this["$"+t]=e},te=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 B},enumerable:!0,configurable:!0}),t}();function ee(t){return new te(t)}var ne={code:"INSERT_DOC_FAIL",message:"insert document failed"},re={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},oe=function(){return(oe=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}).apply(this,arguments)},ie=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},se=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},ae="database.updateDocInTransaction",ue=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 ie(this,void 0,void 0,(function(){var e,n,r,o;return se(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:Ht.a.stringify(Tt(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=Ht.a.parse(n.inserted),1==(o=Ht.a.parse(n.ok))&&1==r)return[2,oe(oe({},n),{ok:o,inserted:r})];throw new Error(ne.message)}}))}))},t.prototype.get=function(){return ie(this,void 0,void 0,(function(){var t,e;return se(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?at.formatField(Ht.a.parse(e.data)):Ht.a.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return ie(this,void 0,void 0,(function(){var e,n;return se(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Ht.a.stringify(Tt(t),{relaxed:!1}),upsert:!0},[4,this._request.send(ae,e)];case 1:if((n=r.sent()).code)throw n;return[2,oe(oe({},n),{updated:Ht.a.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},t.prototype.update=function(t){return ie(this,void 0,void 0,(function(){var e,n;return se(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Ht.a.stringify(jt.encode(t),{relaxed:!1})},[4,this._request.send(ae,e)];case 1:if((n=r.sent()).code)throw n;return[2,oe(oe({},n),{updated:Ht.a.parse(n.updated)})]}}))}))},t.prototype.delete=function(){return ie(this,void 0,void 0,(function(){var t,e;return se(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,oe(oe({},e),{deleted:Ht.a.parse(e.deleted)})]}}))}))},t}(),ce=function(t,e){this._coll=e,this._transaction=t},fe=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])})(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)}}(),le=function(t){function e(e,n){return t.call(this,e,n)||this}return fe(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 ue(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new ue(this._transaction,this._coll,e).create(t)},e}(ce),he=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},pe=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},de=function(){function t(t){this._db=t,this._request=new ve.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return he(this,void 0,void 0,(function(){var t;return pe(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 le(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return he(this,void 0,void 0,(function(){var t,e;return pe(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 he(this,void 0,void 0,(function(){var e,n;return pe(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 ye(){return he(this,void 0,void 0,(function(){var t;return pe(this,(function(e){switch(e.label){case 0:return[4,(t=new de(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function ge(t,e){return void 0===e&&(e=3),he(this,void 0,void 0,(function(){var n,r,o,i,s=this;return pe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new de(this)).init()];case 1:return a.sent(),[4,t(n)];case 2:if(r=a.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return a.sent(),[2,r];case 4:if(o=a.sent(),!1===n.inited)throw o;return i=function(t){return he(s,void 0,void 0,(function(){return pe(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:return e.sent(),[3,4];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:a.sent(),a.label=6;case 6:return o&&o.code===re.code?[4,ge.bind(this)(t,--e)]:[3,8];case 7:return[2,a.sent()];case 8:return[4,i(o)];case 9:return a.sent(),[3,10];case 10:return[2]}}))}))}var ve=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=ot,this.command=Qt,this.RegExp=ee,this.startTransaction=ye,this.runTransaction=ge,this.logicCommand=dt,this.updateCommand=lt,this.queryCommand=mt}return t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new zt(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return new t.reqClass(this.config).send("database.addCollection",n)},t}(),me=function(){return(me=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}).apply(this,arguments)};var be={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,r=e.runtime;return ve.reqClass=this.request.constructor,ve.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},ve.runtime=r,this.wsClientClass&&(ve.wsClass=n.wsClass,ve.wsClientClass=this.wsClientClass),ve.ws||(ve.ws=null),new ve(me(me(me({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(be)}catch(t){}function we(t){try{t.registerComponent(be)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"LoginState",(function(){return $})),n.d(e,"Auth",(function(){return V})),n.d(e,"registerAuth",(function(){return G}));var r,o,i=n(0);function s(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}!function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(r||(r={})),function(t){t.UNREACHABLE="unreachable",t.LOCAL="local",t.CANCELLED="cancelled",t.UNKNOWN="unknown",t.INVALID_ARGUMENT="invalid_argument",t.DEADLINE_EXCEEDED="deadline_exceeded",t.NOT_FOUND="not_found",t.ALREADY_EXISTS="already_exists",t.PERMISSION_DENIED="permission_denied",t.UNAUTHENTICATED="unauthenticated",t.RESOURCE_EXHAUSTED="resource_exhausted",t.FAILED_PRECONDITION="failed_precondition",t.ABORTED="aborted",t.OUT_OF_RANGE="out_of_range",t.UNIMPLEMENTED="unimplemented",t.INTERNAL="internal",t.UNAVAILABLE="unavailable",t.DATA_LOSS="data_loss",t.CAPTCHA_REQUIRED="captcha_required",t.CAPTCHA_INVALID="captcha_invalid",t.INVALID_PASSWORD="invalid_password",t.INVALID_STATUS="invalid_status",t.USER_PENDING="user_pending",t.USER_BLOCKED="user_blocked",t.INVALID_VERIFICATION_CODE="invalid_verification_code",t.TWO_FACTOR_REQUIRED="two_factor_required",t.INVALID_TWO_FACTOR="invalid_two_factor",t.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",t.UNDER_REVIEW="under_review",t.INVALID_REQUEST="invalid_request",t.UNAUTHORIZED_CLIENT="unauthorized_client",t.ACCESS_DENIED="access_denied",t.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",t.INVALID_SCOPE="invalid_scope",t.INVALID_GRANT="invalid_grant",t.SERVER_ERROR="server_error",t.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",t.INTERACTION_REQUIRED="interaction_required",t.LOGIN_REQUIRED="login_required",t.ACCOUNT_SELECTION_REQUIRED="account_selection_required",t.CONSENT_REQUIRED="consent_required",t.INVALID_REQUEST_URI="invalid_request_uri",t.INVALID_REQUEST_OBJECT="invalid_request_object",t.REQUEST_NOT_SUPPORTED="request_not_supported",t.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",t.REGISTRATION_NOT_SUPPORTED="registration_not_supported"}(o||(o={}));var a=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},u=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},c=function(){function t(){this.fnPromiseMap=new Map}return t.prototype.run=function(t,e){return a(this,void 0,void 0,(function(){var n,r=this;return u(this,(function(o){switch(o.label){case 0:return[4,n=this.fnPromiseMap.get(t)];case 1:return o.sent()||(n=new Promise((function(n,o){a(r,void 0,void 0,(function(){var r,i,s;return u(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return a.sent(),r=e(),i=n,[4,r];case 2:return i.apply(void 0,[a.sent()]),[3,5];case 3:return s=a.sent(),o(s),[3,5];case 4:return this.fnPromiseMap.delete(t),[7];case 5:return[2]}}))}))})),this.fnPromiseMap.set(t,n)),[2,n]}}))}))},t.prototype.runIdlePromise=function(){return Promise.resolve()},t}(),f=function(){return(f=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}).apply(this,arguments)},l=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},h=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},p=function(t,e){return l(this,void 0,void 0,(function(){var n,r,i,s,a;return h(this,(function(u){switch(u.label){case 0:n=null,r=null,u.label=1;case 1:return u.trys.push([1,4,,5]),(i=Object.assign({},e)).method||(i.method="GET"),i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body)),[4,fetch(t,i)];case 2:return[4,u.sent().json()];case 3:return(null==(s=u.sent())?void 0:s.error)?(r=s).error_uri=new URL(t).pathname:n=s,[3,5];case 4:return a=u.sent(),r={error:o.UNREACHABLE,error_description:a.message,error_uri:new URL(t).pathname},[3,5];case 5:if(r)throw r;return[2,n]}}))}))};var d=new(function(){function t(){}return t.prototype.getItem=function(t){return l(this,void 0,void 0,(function(){return h(this,(function(e){return[2,window.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return l(this,void 0,void 0,(function(){return h(this,(function(e){return window.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return l(this,void 0,void 0,(function(){return h(this,(function(n){return window.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return window.localStorage.getItem(t)},t.prototype.removeItemSync=function(t){window.localStorage.removeItem(t)},t.prototype.setItemSync=function(t,e){window.localStorage.setItem(t,e)},t}());function y(t){var e=!0;return(null==t?void 0:t.expires_at)&&(null==t?void 0:t.access_token)&&(e=t.expires_at<new Date),e}var g,v,m,b=function(){function t(t){this.credentials=null,this.singlePromise=new c,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage}return t.prototype.getStorageCredentialsSync=function(){var t=null,e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t},t.prototype.setCredentials=function(t){return l(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return(null==t?void 0:t.expires_in)?(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30)),this.storage?(e=JSON.stringify(t),[4,this.storage.setItem(this.tokenSectionName,e)]):[3,2]):[3,3];case 1:n.sent(),n.label=2;case 2:return this.credentials=t,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:n.sent(),n.label=5;case 5:this.credentials=null,n.label=6;case 6:return[2]}}))}))},t.prototype.getCredentials=function(){return l(this,void 0,void 0,(function(){var t=this;return h(this,(function(e){return[2,this.singlePromise.run("getCredentials",(function(){return l(t,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return y(this.credentials)?(t=this,[4,this.getStorageCredentials()]):[3,2];case 1:t.credentials=e.sent(),e.label=2;case 2:return[2,this.credentials]}}))}))}))]}))}))},t.prototype.getStorageCredentials=function(){return l(this,void 0,void 0,(function(){var t=this;return h(this,(function(e){return[2,this.singlePromise.run("_getStorageCredentials",(function(){return l(t,void 0,void 0,(function(){var t,e;return h(this,(function(n){switch(n.label){case 0:return t=null,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),t=null,[3,5];case 5:return[2,t]}}))}))}))]}))}))},t}(),w=function(){function t(e){this.singlePromise=new c,this.apiOrigin=e.apiOrigin,this.clientId=e.clientId,this.retry=this.formatRetry(e.retry,t.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=p,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||d,this.localCredentials=new b({tokenSectionName:"credentials_"+e.clientId,storage:this.storage}),this.clientSecret=e.clientSecret,this.refreshTokenFunc=e.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=e.anonymousSignInFunc}return t.prototype.setCredentials=function(t){return this.localCredentials.setCredentials(t)},t.prototype.getAccessToken=function(){return l(this,void 0,void 0,(function(){var t,e;return h(this,(function(n){switch(n.label){case 0:return[4,this.getCredentials()];case 1:return(null==(t=n.sent())?void 0:t.access_token)?[2,Promise.resolve(t.access_token)]:(e={error:o.UNAUTHENTICATED},[2,Promise.reject(e)])}}))}))},t.prototype.request=function(e,n){return l(this,void 0,void 0,(function(){var r,i,a,u,c,l,p;return h(this,(function(h){switch(h.label){case 0:return n||(n={}),r=this.formatRetry(n.retry,this.retry),n.headers=n.headers||{},this.headers&&(n.headers=f(f({},this.headers),n.headers)),n.headers["x-request-id"]||(n.headers["x-request-id"]=s()),n.headers["x-device-id"]?[3,2]:[4,this.getDeviceId()];case 1:i=h.sent(),n.headers["x-device-id"]=i,h.label=2;case 2:return(null==n?void 0:n.withCredentials)?[4,this.getCredentials()]:[3,4];case 3:return(a=h.sent())&&(this.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token="+a.access_token):n.headers.Authorization=a.token_type+" "+a.access_token),[3,5];case 4:this.clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id="+this.clientId),h.label=5;case 5:e.startsWith("/")&&(e=this.apiOrigin+e),u=null,c=r+1,l=0,h.label=6;case 6:if(!(l<c))return[3,15];h.label=7;case 7:return h.trys.push([7,9,,12]),[4,this.baseRequest(e,n)];case 8:return u=h.sent(),[3,15];case 9:return p=h.sent(),n.withCredentials&&p&&p.error===o.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,11];case 10:return h.sent(),[2,Promise.reject(p)];case 11:return l!==r&&p&&"unreachable"===p.error?[3,12]:[2,Promise.reject(p)];case 12:return[4,this.sleep(t.retryInterval)];case 13:h.sent(),h.label=14;case 14:return l++,[3,6];case 15:return[2,u]}}))}))},t.prototype.getCredentials=function(){return l(this,void 0,void 0,(function(){var t,e,n;return h(this,(function(r){switch(r.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return y(t=r.sent())?t&&"anonymous"===t.scope?this.anonymousSignInFunc?[4,this.anonymousSignInFunc(t)]:[3,5]:[3,8]:[3,10];case 2:return e=r.sent(),(n=e)?[3,4]:[4,this.localCredentials.getCredentials()];case 3:n=r.sent(),r.label=4;case 4:return t=n,[3,7];case 5:return[4,this.anonymousSignIn(t)];case 6:t=r.sent(),r.label=7;case 7:return[3,10];case 8:return[4,this.refreshToken(t)];case 9:t=r.sent(),r.label=10;case 10:return[2,t]}}))}))},t.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},t.prototype.getCredentialsAsync=function(){return this.localCredentials.getCredentials()},t.prototype.getScope=function(){return l(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=e.sent())?[2,t.scope]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},t.prototype.getGroups=function(){return l(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=e.sent())?[2,t.groups]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},t.prototype.checkRetry=function(e){var n=null;if(("number"!=typeof e||e<t.minRetry||e>t.maxRetry)&&(n={error:o.UNREACHABLE,error_description:"wrong options param: retry"}),n)throw n;return e},t.prototype.formatRetry=function(t,e){return void 0===t?e:this.checkRetry(t)},t.prototype.sleep=function(t){return l(this,void 0,void 0,(function(){return h(this,(function(e){return[2,new Promise((function(e){setTimeout((function(){e()}),t)}))]}))}))},t.prototype.refreshToken=function(t){return l(this,void 0,void 0,(function(){var e=this;return h(this,(function(n){return[2,this.singlePromise.run("_refreshToken",(function(){return l(e,void 0,void 0,(function(){var e,n;return h(this,(function(r){switch(r.label){case 0:if(!t||!t.refresh_token)return[2,this.unAuthenticatedError("no refresh token found in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.refreshTokenFunc(t.refresh_token)];case 2:return e=r.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return r.sent(),[2,e];case 4:return(n=r.sent()).error!==o.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},t.prototype.anonymousSignIn=function(t){return l(this,void 0,void 0,(function(){var e=this;return h(this,(function(n){return[2,this.singlePromise.run("_anonymous",(function(){return l(e,void 0,void 0,(function(){var e,n;return h(this,(function(r){switch(r.label){case 0:if(!t||"anonymous"!==t.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.request("/auth/v1/signin/anonymously",{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret}})];case 2:return e=r.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return r.sent(),[2,e];case 4:return(n=r.sent()).error!==o.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},t.prototype.defaultRefreshTokenFunc=function(t){return void 0===t||""===t?this.unAuthenticatedError("refresh token not found"):this.request("/auth/v1/token",{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}})},t.prototype.getDeviceId=function(){return l(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem("device_id")];case 1:return"string"==typeof(t=e.sent())&&t.length>=16&&t.length<=48?[3,3]:(t=s(),[4,this.storage.setItem("device_id",t)]);case 2:e.sent(),e.label=3;case 3:return this.deviceID=t,[2,t]}}))}))},t.prototype.unAuthenticatedError=function(t){var e={error:o.UNAUTHENTICATED,error_description:t};return Promise.reject(e)},t.defaultRetry=2,t.minRetry=0,t.maxRetry=5,t.retryInterval=1e3,t}();!function(t){t.AUTH_SIGN_IN_URL="/auth/v1/signin",t.AUTH_SIGN_IN_ANONYMOUSLY_URL="/auth/v1/signin/anonymously",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v1/signin/with/provider",t.AUTH_SIGN_UP_URL="/auth/v1/signup",t.AUTH_TOKEN_URL="/auth/v1/token",t.AUTH_REVOKE_URL="/auth/v1/revoke",t.PROVIDER_BIND_URL="/auth/v1/user/provider/bind",t.PROVIDER_TOKEN_URL="/auth/v1/provider/token",t.PROVIDER_URI_URL="/auth/v1/provider/uri",t.USER_ME_URL="/auth/v1/user/me",t.USER_QUERY_URL="/auth/v1/user/query",t.USER_PRIFILE_URL="/auth/v1/user/profile",t.USER_TRANS_BY_PROVIDER_URL="/auth/v1/user/trans/by/provider",t.VERIFICATION_URL="/auth/v1/verification",t.VERIFY_URL="/auth/v1/verification/verify",t.PROVIDER_LIST="/auth/v1/user/provider",t.PROVIDER_UNBIND_URL="/auth/v1/user/provider",t.CHECK_PWD_URL="/auth/v1/user/sudo",t.SUDO_URL="/auth/v1/user/sudo",t.BIND_CONTACT_URL="/auth/v1/user/contact",t.AUTH_SET_PASSWORD="/auth/v1/user/password",t.AUTH_RESET_PASSWORD="/auth/v1/reset",t.AUTH_GET_DEVICE_CODE="/auth/v1/device/code",t.CHECK_USERNAME="/auth/v1/checkUsername",t.CHECK_IF_USER_EXIST="/auth/v1/checkIfUserExist"}(g||(g={})),function(t){t.REGISTER="REGISTER",t.SIGN_IN="SIGN_IN",t.PASSWORD_RESET="PASSWORD_RESET",t.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",t.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(v||(v={})),function(t){t.INVALID_ARGUMENT="invalid_argument",t.DEADLINE_EXCEEDED="deadline_exceeded",t.NOT_FOUND="not_found",t.ALREADY_EXISTS="already_exists",t.PERMISSION_DENIED="permission_denied",t.ABORTED="aborted",t.OUT_OF_RANGE="out_of_range",t.UNIMPLEMENTED="unimplemented",t.INTERNAL="internal",t.UNAVAILABLE="unavailable",t.DATA_LOSS="data_loss",t.CAPTCHA_REQUIRED="captcha_required",t.CAPTCHA_INVALID="captcha_invalid",t.INVALID_PASSWORD="invalid_password",t.PASSWORD_NOT_SET="password_not_set",t.INVALID_STATUS="invalid_status",t.USER_PENDING="user_pending",t.USER_BLOCKED="user_blocked"}(m||(m={}));var _=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},E=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},I=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=d),this.config=t,this.tokenSectionName="captcha_"+t.clientId}return t.prototype.request=function(t,e){return _(this,void 0,void 0,(function(){var n,r,o,i;return E(this,(function(s){switch(s.label){case 0:return e||(e={}),e.method||(e.method="GET"),n=e.method+":"+t,r=t,e.withCaptcha?[4,this.appendCaptchaTokenToURL(t,n,!1)]:[3,2];case 1:r=s.sent(),s.label=2;case 2:return s.trys.push([2,4,,7]),[4,this.config.request(r,e)];case 3:return o=s.sent(),[3,7];case 4:return"captcha_required"!==(i=s.sent()).error&&"captcha_invalid"!==i.error?[3,6]:[4,this.appendCaptchaTokenToURL(t,n,"captcha_invalid"===i.error)];case 5:return t=s.sent(),[2,this.config.request(t,e)];case 6:return[2,Promise.reject(i)];case 7:return[2,o]}}))}))},t.prototype.getDefaultOpenURIWithCallback=function(){if(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap")){var t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((function(){document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback},t.prototype.defaultOpenURIWithCallback=function(t){return _(this,void 0,void 0,(function(){var e,n;return E(this,(function(r){return e=document.getElementById("captcha_panel_wrap"),n=document.createElement("iframe"),e.innerHTML="",n.setAttribute("src",t),n.setAttribute("id","review-panel-iframe"),n.style.cssText="min-width:355px;display:block;height:355px;margin:0 auto;background-color: rgb(255, 255, 255);border: none;",e.appendChild(n),e.style.display="block",[2,new Promise((function(t,r){n.onload=function(){try{var o=window.location,i=n.contentWindow.location;if(i.host+i.pathname===o.host+o.pathname){e.style.display="none";var s=new URLSearchParams(i.search),a=s.get("captcha_token");return a?t({captcha_token:a,expires_in:Number(s.get("expires_in"))}):r({error:s.get("error"),error_description:s.get("error_description")})}e.style.display="block"}catch(t){e.style.display="block"}}}))]}))}))},t.prototype.getCaptchaToken=function(t,e){return _(this,void 0,void 0,(function(){var n,r,o,i,s;return E(this,(function(a){switch(a.label){case 0:return t?[3,2]:[4,this.findCaptchaToken()];case 1:if(n=a.sent())return[2,n];a.label=2;case 2:return r=window.location.origin+window.location.pathname+"?__captcha=on",[4,this.config.request("/auth/v1/captcha/init",{method:"POST",body:{client_id:this.config.clientId,redirect_uri:r,state:e},withCredentials:!1})];case 3:return(o=a.sent()).captcha_token?(i={captcha_token:o.captcha_token,expires_in:o.expires_in},this.saveCaptchaToken(i),[2,o.captcha_token]):[4,this.config.openURIWithCallback(o.url)];case 4:return s=a.sent(),this.saveCaptchaToken(s),[2,s.captcha_token]}}))}))},t.prototype.appendCaptchaTokenToURL=function(t,e,n){return _(this,void 0,void 0,(function(){var r;return E(this,(function(o){switch(o.label){case 0:return[4,this.getCaptchaToken(n,e)];case 1:return r=o.sent(),t.indexOf("?")>0?t+="&captcha_token="+r:t+="?captcha_token="+r,[2,t]}}))}))},t.prototype.saveCaptchaToken=function(t){return _(this,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:return t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10)),e=JSON.stringify(t),[4,this.config.storage.setItem(this.tokenSectionName,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.findCaptchaToken=function(){return _(this,void 0,void 0,(function(){var t,e;return E(this,(function(n){switch(n.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(t=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?[2,null]:[2,e.captcha_token];case 3:return n.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),[2,null];case 5:return[2,null]}}))}))},t}(),S=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},O=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},A=function(){function t(t){var e=t.request,n=t.credentialsClient;if(!n){var r={apiOrigin:t.apiOrigin,clientId:t.clientId,storage:t.storage};n=new w(r)}if(!e){var o=n.request.bind(n),i=new I({clientId:t.clientId,request:o,storage:t.storage});e=i.request.bind(i)}this.config={apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:n,storage:t.storage||d}}return t.parseParamsToSearch=function(t){return Object.keys(t).forEach((function(e){t[e]||delete t[e]})),new URLSearchParams(t).toString()},t.prototype.signIn=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.request(g.AUTH_SIGN_IN_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.request(g.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signUp=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.request(g.AUTH_SIGN_UP_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signOut=function(){return S(this,void 0,void 0,(function(){var t,e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.credentialsClient.getAccessToken()];case 1:return t=n.sent(),[4,this.config.request(g.AUTH_REVOKE_URL,{method:"POST",body:{token:t}})];case 2:return e=n.sent(),[4,this.config.credentialsClient.setCredentials()];case 3:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.getVerification=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return e=!1,"CUR_USER"!==t.target?[3,1]:(e=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:n.sent()&&(e=!0),n.label=3;case 3:return[2,this.config.request(g.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:!0,withCredentials:e})]}}))}))},t.prototype.verify=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.VERIFY_URL,{method:"POST",body:t})]}))}))},t.prototype.genProviderRedirectUri=function(t){return S(this,void 0,void 0,(function(){var e,n;return O(this,(function(r){return e=g.PROVIDER_URI_URL+"?client_id="+this.config.clientId+"&provider_id="+t.provider_id+"&redirect_uri="+encodeURIComponent(t.provider_redirect_uri)+"&state="+t.state,(n=t.other_params)&&"string"==typeof n.sign_out_uri&&n.sign_out_uri.length>0&&(e+="&other_params[sign_out_uri]="+n.sign_out_uri),[2,this.config.request(e,{method:"GET"})]}))}))},t.prototype.grantProviderToken=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.patchProviderToken=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]}))}))},t.prototype.signInWithProvider=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.request(g.AUTH_SIGN_IN_WITH_PROVIDER_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.bindWithProvider=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.getUserProfile=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.getUserInfo()]}))}))},t.prototype.getUserInfo=function(){return S(this,void 0,void 0,(function(){var t;return O(this,(function(e){switch(e.label){case 0:return[4,this.config.request(g.USER_ME_URL,{method:"GET",withCredentials:!0})];case 1:return(t=e.sent()).sub&&(t.uid=t.sub),[2,t]}}))}))},t.prototype.deleteMe=function(e){return S(this,void 0,void 0,(function(){var n;return O(this,(function(r){return n=g.USER_ME_URL+"?"+t.parseParamsToSearch(e),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.hasLoginState=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},t.prototype.getLoginState=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.config.credentialsClient.getCredentialsAsync()]}))}))},t.prototype.transByProvider=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.grantToken=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.AUTH_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.getProviders=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.config.request(g.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},t.prototype.unbindProvider=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_UNBIND_URL+"/"+t.provider_id,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.checkPassword=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.CHECK_PWD_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.bindPhone=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.BIND_CONTACT_URL,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.bindEmail=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.BIND_CONTACT_URL,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.setPassword=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.AUTH_SET_PASSWORD,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.updatePasswordByOld=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.sudo({password:t.old_password})];case 1:return e=n.sent(),[2,this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})]}}))}))},t.prototype.sudo=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.SUDO_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.getCurUserVerification=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return t.target="CUR_USER",[2,this.config.request(g.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]}))}))},t.prototype.changeBindedProvider=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_LIST+"/"+t.provider_id+"/trans",{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})]}))}))},t.prototype.setUserProfile=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.queryUserProfile=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){return e=new URLSearchParams(t),[2,this.config.request(g.USER_QUERY_URL+"?"+e.toString(),{method:"GET",withCredentials:!0})]}))}))},t.prototype.setCustomSignFunc=function(t){this.getCustomSignTicketFn=t},t.prototype.signInWithCustomTicket=function(){return S(this,void 0,void 0,(function(){var t;return O(this,(function(e){switch(e.label){case 0:return[4,this.getCustomSignTicketFn()];case 1:return t=e.sent(),[2,this.signInWithProvider({provider_id:"custom",provider_token:t})]}}))}))},t.prototype.resetPassword=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.AUTH_RESET_PASSWORD,{method:"POST",body:t})]}))}))},t.prototype.deviceAuthorize=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.checkUsername=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]}))}))},t.prototype.checkIfUserExist=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){return e=new URLSearchParams(t),[2,this.config.request(g.CHECK_IF_USER_EXIST+"?"+e.toString(),{method:"GET"})]}))}))},t.prototype.loginScope=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.config.credentialsClient.getScope()]}))}))},t.prototype.loginGroups=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.config.credentialsClient.getGroups()]}))}))},t}(),T=(n(10),function(){return(T=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}).apply(this,arguments)}),N=function(t){var e=t.apiOrigin,n=t.clientId,r=t.storage,o=t.request,i=t.anonymousSignInFunc;this.oauth2client=new w({apiOrigin:e,clientId:n,storage:r,baseRequest:o,anonymousSignInFunc:i}),this.authApi=new A(T(T({credentialsClient:this.oauth2client},t),{request:o?this.oauth2client.request.bind(this.oauth2client):void 0}))},R=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}).apply(this,arguments)},x=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},C=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},P=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},L=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},U=i.utils.printWarn,D=i.utils.throwError,j=i.constants.ERRORS,k=i.constants.COMMUNITY_SITE_URL,M=i.helpers.catchErrorsDecorator,B=i.events.CloudbaseEventEmitter,q="loginStateChanged",F=new B,W=function(){function t(t){var e=t.cache,n=t.oauthInstance;this.cache=e,this.oauthInstance=n,this.setUserInfo()}return t.prototype.checkLocalInfo=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return P(this,void 0,void 0,(function(){var t,e,n,r;return L(this,(function(o){switch(o.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=o.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),n=this,[4,this.getLocalUserInfoAsync("email")];case 3:return n.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),r=this,[4,this.getLocalUserInfoAsync("username")];case 4:return r.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}}))}))},t.prototype.update=function(t){return P(this,void 0,void 0,(function(){var e;return L(this,(function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(R({},t))];case 1:return e=n.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&D(j.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(){return P(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo()];case 1:return t=e.sent(),this.setLocalUserInfo(t),[2,t]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;return this.cache.getStore(e)[t]},t.prototype.getLocalUserInfoAsync=function(t){return P(this,void 0,void 0,(function(){var e;return L(this,(function(n){switch(n.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,n.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,n=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username"].forEach((function(e){t[e]=n[e]}))},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},x([M({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"update",null),x([M({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[String,String]),C("design:returntype",void 0)],t.prototype,"updatePassword",null),x([M({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",void 0)],t.prototype,"updateUsername",null),x([M({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"refresh",null),t}(),$=function(){function t(t){var e=t.envId,n=t.cache,r=t.oauthInstance;e||D(j.INVALID_PARAMS,"envId is not defined"),this.cache=n,this.oauthInstance=r,this.user=new W({cache:this.cache,oauthInstance:r})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}}))}))},t}(),V=function(){function t(t){this.config=t,this.cache=t.cache,this.oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.bindPhone(t)]}))}))},t.prototype.unbindProvider=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},t.prototype.bindEmail=function(t){return this.oauthInstance.authApi.bindEmail(t)},t.prototype.verify=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.getVerification(t)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}U(j.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return P(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return[4,this.getLoginState()];case 1:return(t=e.sent())?[4,t.user.checkLocalInfoAsync()]:[3,3];case 2:return e.sent(),[2,t.user||null];case 3:return[2,null]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signIn=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signUp=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signUp(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setPassword=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&D(j.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,e.sent().exist]}}))}))},t.prototype.signOut=function(){return P(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut()];case 1:return e.sent(),[4,this.cache.removeStoreAsync(t)];case 2:return e.sent(),F.fire(q),[2]}}))}))},t.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new $({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;U(j.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.getLoginState()];case 1:return t.sent()?[2,new $({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.getUserInfo()]}))}))},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}}))}))},t.prototype.grantProviderToken=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.grantToken=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return P(this,void 0,void 0,(function(){var e,n=this;return L(this,(function(r){switch(r.label){case 0:return F.on(q,(function(){return P(n,void 0,void 0,(function(){var e;return L(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=r.sent(),t.call(this,e),[2]}}))}))},t.prototype.createLoginState=function(){return P(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return[4,(t=new $({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return e.sent(),[4,t.user.refresh()];case 2:return e.sent(),F.fire(q),[2,t]}}))}))},x([M({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),x([M({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"unbindProvider",null),x([M({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",void 0)],t.prototype,"bindEmail",null),x([M({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"verify",null),x([M({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"getVerification",null),x([M({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"getCurrentUser",null),x([M({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"signInAnonymously",null),x([M({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),x([M({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"signUp",null),x([M({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),x([M({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"signOut",null),x([M({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"getLoginState",null),x([M({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"getUserInfo",null),x([M({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"bindWithProvider",null),t}(),H={name:"auth",namespace:"auth",entity:function(t){if(void 0===t&&(t={region:"",persistence:"local"}),this.authInstance)return U(j.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var e=this.platform,n=e.adapter,r=e.runtime,o=t.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=this.config,s=i.env,a=i.persistence,u=i.debug,c=i.clientId,f=i.storage,l=new N({clientId:c,apiOrigin:this.request.getBaseEndPoint(),storage:(null==t?void 0:t.storage)||f,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc});return this.oauthInstance=l,this.authInstance=new V({env:s,region:t.region,persistence:a,debug:u,cache:this.cache,runtime:r,_fromApp:this,oauthInstance:l}),this.authInstance}};try{cloudbase.registerComponent(H)}catch(t){}function G(t){try{t.registerComponent(H)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"registerRealtime",(function(){return q}));var r=n(11),o=n.n(r),i=n(12),s=n.n(i),a=n(13),u=n.n(a);function c(t){return void 0===t&&(t=""),(t?t+"_":"")+ +new Date+"_"+Math.random()}var f,l,h=function(t){this.close=t.close,this.onChange=t.onChange,this.onError=t.onError,t.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return t.virtualClient}})},p=function(t){var e,n,r=t.id,o=t.docChanges,i=t.docs,s=t.msgType,a=t.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return e||(e=JSON.parse(JSON.stringify(o))),e},enumerable:!0},docs:{get:function(){return n||(n=JSON.parse(JSON.stringify(i))),n},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})},d=(f=function(t,e){return(f=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)},function(t,e){function n(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),y=function(t){function e(e){var n=t.call(this,"Watch Error "+JSON.stringify(e.msgData)+" (requestid: "+e.requestId+")")||this;return n.isRealtimeErrorMessageError=!0,n.payload=e,n}return d(e,t),e}(Error),g=function(t){return null==t?void 0:t.isRealtimeErrorMessageError},v=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="timeout",e.payload=null,e.generic=!0,e}return d(e,t),e}(Error),m=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="cancelled",e.payload=null,e.generic=!0,e}return d(e,t),e}(Error),b=function(t){function e(e){var n=t.call(this,e.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: "+this.errCode+" "+(w[this.errCode]||"")+" | errMsg: "+this.errMsg},set:function(t){this.errMsg=t}}}),n.errCode=e.errCode||"UNKNOWN_ERROR",n.errMsg=e.errMsg,n}return d(e,t),Object.defineProperty(e.prototype,"message",{get:function(){return"errCode: "+this.errCode+" | errMsg: "+this.errMsg},set:function(t){this.errMsg=t},enumerable:!1,configurable:!0}),e}(Error),w={UNKNOWN_ERROR:"UNKNOWN_ERROR",SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG:"SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG",SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA:"SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED",SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL",SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR:"SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR"},_=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},E=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},I=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},S=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};!function(t){t.LOGGINGIN="LOGGINGIN",t.INITING="INITING",t.REBUILDING="REBUILDING",t.ACTIVE="ACTIVE",t.ERRORED="ERRORED",t.CLOSING="CLOSING",t.CLOSED="CLOSED",t.PAUSED="PAUSED",t.RESUMING="RESUMING"}(l||(l={}));var O=function(){function t(t){var e=this;this.watchStatus=l.INITING,this.wsLogin=function(t,n){return E(e,void 0,void 0,(function(){var e;return I(this,(function(r){switch(r.label){case 0:return this.watchStatus=l.LOGGINGIN,[4,this.login(t,n)];case 1:return e=r.sent(),this.envId||(this.envId=e.envId),[2,e]}}))}))},this.initWatch=function(t){return E(e,void 0,void 0,(function(){var e,n=this;return I(this,(function(r){switch(r.label){case 0:if(null!==this.initWatchPromise&&void 0!==this.initWatchPromise)return[2,this.initWatchPromise];this.initWatchPromise=new Promise((function(e,r){E(n,void 0,void 0,(function(){var n,o,i,s,a,u,f,h,d,y;return I(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):[4,this.wsLogin(this.envId,t)];case 1:return n=g.sent().envId,this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):(this.watchStatus=l.INITING,o={watchId:this.watchId,requestId:c(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(i=g.sent(),s=i.msgData,a=s.events,u=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:u-1,currentDocs:[]},a.length>0){for(f=0,h=a;f<h.length;f++)h[f].ID=u;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=u,d=new p({id:u,docChanges:[],docs:[],type:"init"}),this.listener.onChange(d),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=l.ACTIVE,this.availableRetries.INIT_WATCH=2,e(),[3,4];case 3:return y=g.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:e,reject:r}),[3,4];case 4:return[2]}}))}))})),e=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return r.sent(),e=!0,[3,4];case 3:return this.initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch "+(e?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(t){return E(e,void 0,void 0,(function(){var e,n=this;return I(this,(function(r){switch(r.label){case 0:if(null!==this.rebuildWatchPromise&&void 0!==this.rebuildWatchPromise)return[2,this.rebuildWatchPromise];this.rebuildWatchPromise=new Promise((function(e,r){E(n,void 0,void 0,(function(){var n,o,i,s;return I(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):[4,this.wsLogin(this.envId,t)];case 1:if(n=a.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):(this.watchStatus=l.REBUILDING,o={watchId:this.watchId,requestId:c(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return i=a.sent(),this.handleServerEvents(i),this.watchStatus=l.ACTIVE,this.availableRetries.REBUILD_WATCH=2,e(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:e,reject:r}),[3,4];case 4:return[2]}}))}))})),e=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return r.sent(),e=!0,[3,4];case 3:return this.rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch "+(e?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(t,n){return E(e,void 0,void 0,(function(){var e,r,o,i=this;return I(this,(function(s){return e="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new b({errCode:e?w.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:w.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:t})),n.reject(t)},o=function(t){i.useRetryTicket(n.operationName)?e?(i.initWatchPromise=void 0,n.resolve(i.initWatch(t))):(i.rebuildWatchPromise=void 0,n.resolve(i.rebuildWatch(t))):r()},this.handleCommonError(t,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){E(i,void 0,void 0,(function(){var t,e=this;return I(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),t=function(){return E(e,void 0,void 0,(function(){return I(this,(function(t){switch(t.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return t.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,t()];case 1:return r.sent(),[3,7];case 2:return[4,_(100)];case 3:return r.sent(),this.watchStatus!==l.PAUSED?[3,4]:(n.reject(new m(n.operationName+" cancelled due to pause after unknownError")),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,t()];case 5:return r.sent(),[3,7];case 6:o(!1),r.label=7;case 7:return[3,9];case 8:return r.sent(),o(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return E(e,void 0,void 0,(function(){var t,e,n;return I(this,(function(r){switch(r.label){case 0:if(t=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==l.ACTIVE)return this.watchStatus=l.CLOSED,this.onWatchClose(this,t),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=l.CLOSING,e={watchId:this.watchId,requestId:c(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:e})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=l.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,t),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){e.clearACKSchedule(),e.ackTimeoutId=setTimeout((function(){e.waitExpectedTimeoutId?e.scheduleSendACK():e.sendACK()}),1e4)},this.clearACKSchedule=function(){e.ackTimeoutId&&clearTimeout(e.ackTimeoutId)},this.sendACK=function(){return E(e,void 0,void 0,(function(){var t,e,n;return I(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==l.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(t={watchId:this.watchId,requestId:c(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:t})]):(console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"),[2]);case 1:return r.sent(),this.scheduleSendACK(),[3,3];case 2:if(e=r.sent(),g(e))switch((n=e.payload).msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return this.rebuildWatch(),[2];case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":return this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:n.msgData.code})),[2]}return this.availableRetries.CHECK_LAST&&this.availableRetries.CHECK_LAST>0?(this.availableRetries.CHECK_LAST-=1,this.scheduleSendACK()):this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:e})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(t,e){if(g(t)){switch(t.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void e.onSignError(t);case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":default:return void e.onNotRetryableError(t)}}else{if(function(t){return"timeout"===t.type}(t))return void e.onTimeoutError(t);if(function(t){return"cancelled"===t.type}(t))return void e.onCancelledError(t)}e.onUnknownError(t)},this.watchId="watchid_"+ +new Date+"_"+Math.random(),this.envId=t.envId,this.collectionName=t.collectionName,this.query=t.query,this.limit=t.limit,this.orderBy=t.orderBy,this.send=t.send,this.login=t.login,this.isWSConnected=t.isWSConnected,this.onceWSConnected=t.onceWSConnected,this.getWaitExpectedTimeoutLength=t.getWaitExpectedTimeoutLength,this.onWatchStart=t.onWatchStart,this.onWatchClose=t.onWatchClose,this.debug=t.debug,this.availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new h({close:function(){e.closeWatch()},onChange:t.onChange,onError:t.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return t.prototype.onMessage=function(t){var e=this;switch(this.watchStatus){case l.PAUSED:if("ERROR"!==t.msgType)return;break;case l.LOGGINGIN:case l.INITING:case l.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while "+this.watchStatus);case l.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case l.ERRORED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has ended with error")}if(this.sessionInfo)switch(this.scheduleSendACK(),t.msgType){case"NEXT_EVENT":console.warn("nextevent "+t.msgData.currEvent+" ignored",t),this.handleServerEvents(t);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<t.msgData.currEvent&&(this.sessionInfo.expectEventId=t.msgData.currEvent,this.clearWaitExpectedEvent(),this.waitExpectedTimeoutId=setTimeout((function(){e.rebuildWatch()}),this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength "+this.getWaitExpectedTimeoutLength()));break;case"ERROR":this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:t.msgData.code+" - "+t.msgData.message}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg "+t.msgType+": ",t)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},t.prototype.closeWithError=function(t){var e;this.watchStatus=l.ERRORED,this.clearACKSchedule(),this.listener.onError(t),this.onWatchClose(this,(null===(e=this.sessionInfo)||void 0===e?void 0:e.queryID)||""),console.log("[realtime] client closed ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},t.prototype.pause=function(){this.watchStatus=l.PAUSED,console.log("[realtime] client paused ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},t.prototype.resume=function(){return E(this,void 0,void 0,(function(){var t;return I(this,(function(e){switch(e.label){case 0:this.watchStatus=l.RESUMING,console.log("[realtime] client resuming with "+(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH")+" ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return e.sent(),console.log("[realtime] client successfully resumed ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),[3,4];case 3:return t=e.sent(),console.error("[realtime] client resume failed ("+this.collectionName+" "+this.query+") ("+this.watchId+")",t),[3,4];case 4:return[2]}}))}))},t.prototype.useRetryTicket=function(t){return!!(this.availableRetries[t]&&this.availableRetries[t]>0)&&(this.availableRetries[t]-=1,console.log("[realtime] "+t+" use a retry ticket, now only "+this.availableRetries[t]+" retry left"),!0)},t.prototype.handleServerEvents=function(t){return E(this,void 0,void 0,(function(){var e;return I(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(t)];case 1:return n.sent(),this.postHandleServerEventsValidityCheck(t),[3,3];case 2:throw e=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",e),e;case 3:return[2]}}))}))},t.prototype.handleServerEventsInternel=function(t){return E(this,void 0,void 0,(function(){var e,n,r,i,a,c,f,l,h,d,y,g;return I(this,(function(v){switch(v.label){case 0:if(e=t.requestId,n=t.msgData.events,r=t.msgType,!n.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=n.map(A)}catch(t){return this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:t})),[2]}c=S(i.currentDocs),f=!1,l=function(n,l){var d,y,g,v,m,_,E,O,A,T,N,R;return I(this,(function(I){switch(I.label){case 0:return d=a[n],i.currentEventId>=d.id?(!a[n-1]||d.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur "+i.currentEventId+" but got "+d.id):console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId "+e+")"),[2,"continue"]):[3,1];case 1:if(i.currentEventId!==d.id-1)return[3,2];switch(d.dataType){case"update":if(!d.doc)switch(d.queueType){case"update":case"dequeue":if(y=c.find((function(t){return t._id===d.docId}))){if(g=u()(y),d.updatedFields&&Object.keys(d.updatedFields).forEach((function(t){o()(g,t,d.updatedFields[t])})),d.removedFields)for(v=0,m=d.removedFields;v<m.length;v++)_=m[v],s()(g,_);d.doc=g}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw O=new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '+t.requestId+")"}),h.closeWithError(O),O}break;case"replace":if(!d.doc)throw O=new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '+t.requestId+")"}),h.closeWithError(O),O;break;case"remove":(E=c.find((function(t){return t._id===d.docId})))?d.doc=E:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!d.doc)switch(d.queueType){case"dequeue":(E=c.find((function(t){return t._id===d.docId})))?d.doc=E:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw O=new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '+t.requestId+")"}),h.closeWithError(O),O}}switch(d.queueType){case"init":f?c.push(d.doc):(f=!0,c=[d.doc]);break;case"enqueue":c.push(d.doc);break;case"dequeue":(A=c.findIndex((function(t){return t._id===d.docId})))>-1?c.splice(A,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":(A=c.findIndex((function(t){return t._id===d.docId})))>-1?c[A]=d.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===l-1||a[n+1]&&a[n+1].id!==d.id)&&(T=S(c),N=a.slice(0,n+1).filter((function(t){return t.id===d.id})),h.sessionInfo.currentEventId=d.id,h.sessionInfo.currentDocs=c,R=new p({id:d.id,docChanges:N,docs:T,msgType:r}),h.listener.onChange(R)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur "+h.sessionInfo.currentEventId+" but got "+d.id),[4,h.rebuildWatch()];case 3:return I.sent(),[2,{value:void 0}];case 4:return[2]}}))},h=this,d=0,y=a.length,v.label=1;case 1:return d<y?[5,l(d,y)]:[3,4];case 2:if("object"==typeof(g=v.sent()))return[2,g.value];v.label=3;case 3:return d++,[3,1];case 4:return[2]}}))}))},t.prototype.postHandleServerEventsValidityCheck=function(t){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<t.msgData.currEvent&&console.warn("[realtime listener] internal non-fatal error: client eventId does not match with server event id after server event handling")):console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur")},t.prototype.clearWaitExpectedEvent=function(){this.waitExpectedTimeoutId&&(clearTimeout(this.waitExpectedTimeoutId),this.waitExpectedTimeoutId=void 0)},t}();function A(t){var e={id:t.ID,dataType:t.DataType,queueType:t.QueueType,docId:t.DocID,doc:t.Doc&&"{}"!==t.Doc?JSON.parse(t.Doc):void 0};return"update"===t.DataType&&(t.UpdatedFields&&(e.updatedFields=JSON.parse(t.UpdatedFields)),(t.removedFields||t.RemovedFields)&&(e.removedFields=JSON.parse(t.removedFields))),e}var T,N={1e3:{code:1e3,name:"Normal Closure",description:"Normal closure; the connection successfully completed whatever purpose for which it was created."},1001:{code:1001,name:"Going Away",description:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{code:1002,name:"Protocol Error",description:"The endpoint is terminating the connection due to a protocol error."},1003:{code:1003,name:"Unsupported Data",description:"The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)."},1005:{code:1005,name:"No Status Received",description:"Indicates that no status code was provided even though one was expected."},1006:{code:1006,name:"Abnormal Closure",description:"Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{code:1007,name:"Invalid frame payload data",description:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{code:1008,name:"Policy Violation",description:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{code:1009,name:"Message too big",description:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{code:1010,name:"Missing Extension",description:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{code:1011,name:"Internal Error",description:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{code:1012,name:"Service Restart",description:"The server is terminating the connection because it is restarting."},1013:{code:1013,name:"Try Again Later",description:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{code:1014,name:"Bad Gateway",description:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{code:1015,name:"TLS Handshake",description:"Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},3e3:{code:3e3,name:"Reconnect WebSocket",description:"The client is terminating the connection because it wants to reconnect"},3001:{code:3001,name:"No Realtime Listeners",description:"The client is terminating the connection because no more realtime listeners exist"},3002:{code:3002,name:"Heartbeat Ping Error",description:"The client is terminating the connection due to its failure in sending heartbeat messages"},3003:{code:3003,name:"Heartbeat Pong Timeout Error",description:"The client is terminating the connection because no heartbeat response is received from the server"},3050:{code:3050,name:"Server Close",description:"The client is terminating the connection because no heartbeat response is received from the server"}};!function(t){t[t.NormalClosure=1e3]="NormalClosure",t[t.GoingAway=1001]="GoingAway",t[t.ProtocolError=1002]="ProtocolError",t[t.UnsupportedData=1003]="UnsupportedData",t[t.NoStatusReceived=1005]="NoStatusReceived",t[t.AbnormalClosure=1006]="AbnormalClosure",t[t.InvalidFramePayloadData=1007]="InvalidFramePayloadData",t[t.PolicyViolation=1008]="PolicyViolation",t[t.MessageTooBig=1009]="MessageTooBig",t[t.MissingExtension=1010]="MissingExtension",t[t.InternalError=1011]="InternalError",t[t.ServiceRestart=1012]="ServiceRestart",t[t.TryAgainLater=1013]="TryAgainLater",t[t.BadGateway=1014]="BadGateway",t[t.TLSHandshake=1015]="TLSHandshake",t[t.ReconnectWebSocket=3e3]="ReconnectWebSocket",t[t.NoRealtimeListeners=3001]="NoRealtimeListeners",t[t.HeartbeatPingError=3002]="HeartbeatPingError",t[t.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",t[t.NoAuthentication=3050]="NoAuthentication"}(T||(T={}));var R=function(t,e){var n=N[t],r=n?n.name+", code "+t+", reason "+(e||n.description):"code "+t;return new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},x=null,C="web";function P(){return C}var L=function(){return(L=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}).apply(this,arguments)},U=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},D=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},j=1,k=function(){function t(t){var e=this;this.virtualWSClient=new Set,this.queryIdClientMap=new Map,this.watchIdClientMap=new Map,this.pingFailed=0,this.pongMissed=0,this.logins=new Map,this.wsReadySubsribers=[],this.wsResponseWait=new Map,this.rttObserved=[],this.send=function(t){return U(e,void 0,void 0,(function(){var e=this;return D(this,(function(n){return[2,new Promise((function(n,r){U(e,void 0,void 0,(function(){var e,o,i,s,a,u,c,f,l=this;return D(this,(function(h){switch(h.label){case 0:o=!1,i=!1,s=function(t){o=!0,e&&clearTimeout(e),n(t)},a=function(t){i=!0,e&&clearTimeout(e),r(t)},t.timeout&&(e=setTimeout((function(){U(l,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return o&&i?[3,2]:[4,_(0)];case 1:t.sent(),o&&i||a(new v("wsclient.send timedout")),t.label=2;case 2:return[2]}}))}))}),t.timeout)),h.label=1;case 1:return h.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:h.sent(),h.label=3;case 3:if(!this.ws)return a(new Error("invalid state: ws connection not exists, can not send message")),[2];if(this.ws.readyState!==j)return a(new Error("ws readyState invalid: "+this.ws.readyState+", can not send message")),[2];t.waitResponse&&(u={resolve:s,reject:a,skipOnMessage:t.skipOnMessage},this.wsResponseWait.set(t.msg.requestId,u)),h.label=4;case 4:return h.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(t.msg))];case 5:return h.sent(),t.waitResponse||s(void 0),[3,7];case 6:return(c=h.sent())&&(a(c),t.waitResponse&&this.wsResponseWait.delete(t.msg.requestId)),[3,7];case 7:return[3,9];case 8:return f=h.sent(),a(f),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(t){e.virtualWSClient.forEach((function(e){e.closeWithError(t)}))},this.pauseClients=function(t){(t||e.virtualWSClient).forEach((function(t){t.pause()}))},this.resumeClients=function(t){(t||e.virtualWSClient).forEach((function(t){t.resume()}))},this.initWebSocketConnection=function(t,n){return void 0===n&&(n=e.maxReconnect),U(e,void 0,void 0,(function(){var e=this;return D(this,(function(r){switch(r.label){case 0:if(t&&this.reconnectState)return[2];if(t&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];t&&this.pauseClients(),this.close(T.ReconnectWebSocket),this.wsInitPromise=new Promise((function(r,o){U(e,void 0,void 0,(function(){var e,i,s=this;return D(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return e=a.sent(),[4,new Promise((function(t){var n=e.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=x;s.ws=r?new r(n):new WebSocket(n),t(void 0)}))];case 2:return a.sent(),this.ws.connect?[4,this.ws.connect()]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return a.sent(),r(),t&&(this.resumeClients(),this.reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),n>0?(this.wsInitPromise=void 0,[4,_(this.reconnectInterval)]):[3,9];case 7:a.sent(),t&&(this.reconnectState=!1),a.label=8;case 8:return r(this.initWebSocketConnection(t,n-1)),[3,10];case 9:o(i),t&&this.closeAllClients(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:i})),a.label=10;case 10:return[3,11];case 11:return[2]}}))}))})),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this.wsInitPromise];case 2:return r.sent(),this.wsReadySubsribers.forEach((function(t){return(0,t.resolve)()})),[3,5];case 3:return r.sent(),this.wsReadySubsribers.forEach((function(t){return(0,t.reject)()})),[3,5];case 4:return this.wsInitPromise=void 0,this.wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(t,n){if(!e.ws)throw new Error("can not initWebSocketEvent, ws not exists");var r=!1;e.ws.onopen=function(e){console.warn("[realtime] ws event: open",e),r=!0,t()},e.ws.onerror=function(t){e.logins=new Map,r?(console.error("[realtime] ws event: error",t),e.clearHeartbeat(),e.virtualWSClient.forEach((function(e){return e.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:t}))}))):(console.error("[realtime] ws open failed with ws event: error",t),n(t))},e.ws.onclose=function(t){switch(console.warn("[realtime] ws event: close",t),e.logins=new Map,e.clearHeartbeat(),t.code){case T.ReconnectWebSocket:case T.NoRealtimeListeners:break;case T.HeartbeatPingError:case T.HeartbeatPongTimeoutError:case T.NormalClosure:case T.AbnormalClosure:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients(R(t.code));break;case T.NoAuthentication:e.closeAllClients(R(t.code,t.reason));break;default:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients(R(t.code))}},e.ws.onmessage=function(t){var n,r=t.data;e.heartbeat();try{n=JSON.parse(r)}catch(t){throw new Error("[realtime] onMessage parse res.data error: "+t)}if("ERROR"===n.msgType){var o=null;e.virtualWSClient.forEach((function(t){t.watchId===n.watchId&&(o=t)})),o&&o.listener.onError(n)}var i=e.wsResponseWait.get(n.requestId);if(i){try{"ERROR"===n.msgType?i.reject(new y(n)):i.resolve(n)}catch(t){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",t)}finally{e.wsResponseWait.delete(n.requestId)}if(i.skipOnMessage)return}if("PONG"!==n.msgType){var s=n.watchId&&e.watchIdClientMap.get(n.watchId);if(s)s.onMessage(n);else switch(console.error("[realtime] no realtime listener found responsible for watchId "+n.watchId+": ",n),n.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(s=e.queryIdClientMap.get(n.msgData.queryID))&&s.onMessage(n);break;default:for(var a=0,u=Array.from(e.watchIdClientMap.entries());a<u.length;a++){u[a][1].onMessage(n);break}}}else if(e.lastPingSendTS){var c=Date.now()-e.lastPingSendTS;if(c>1e4)return void console.warn("[realtime] untrusted rtt observed: "+c);e.rttObserved.length>=3&&e.rttObserved.splice(0,e.rttObserved.length-3+1),e.rttObserved.push(c)}},e.heartbeat()}))},this.isWSConnected=function(){return Boolean(e.ws&&e.ws.readyState===j)},this.onceWSConnected=function(){return U(e,void 0,void 0,(function(){var t=this;return D(this,(function(e){return this.isWSConnected()?[2]:null!==this.wsInitPromise&&void 0!==this.wsInitPromise?[2,this.wsInitPromise]:[2,new Promise((function(e,n){t.wsReadySubsribers.push({resolve:e,reject:n})}))]}))}))},this.webLogin=function(t,n){return U(e,void 0,void 0,(function(){var e,r,o,i,s,a,u,f,l=this;return D(this,(function(h){switch(h.label){case 0:if(!n)if(t){if(e=this.logins.get(t)){if(e.loggedIn&&e.loginResult)return[2,e.loginResult];if(null!==e.loggingInPromise&&void 0!==e.loggingInPromise)return[2,e.loggingInPromise]}}else if(null!==(null==(r=this.logins.get(""))?void 0:r.loggingInPromise)&&void 0!==(null==r?void 0:r.loggingInPromise))return[2,r.loggingInPromise];o=new Promise((function(t,e){U(l,void 0,void 0,(function(){var n,r,o,i,s;return D(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return n=a.sent(),r={envId:n.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:c(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:P(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(i=a.sent()).msgData.code?e(new Error(i.msgData.code+" "+i.msgData.message)):t({envId:n.envId}),[3,4];case 3:return s=a.sent(),e(s),[3,4];case 4:return[2]}}))}))})),i=t&&this.logins.get(t),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this.logins.set(t||"",i)),h.label=1;case 1:return h.trys.push([1,3,,4]),[4,o];case 2:if(a=h.sent(),(u=t&&this.logins.get(t))&&u===i&&u.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(u){if(u.loggedIn&&u.loginResult)return[2,u.loginResult];if(null!==u.loggingInPromise&&void 0!==u.loggingInPromise)return[2,u.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw f=h.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,f;case 4:return[2]}}))}))},this.getWsSign=function(){return U(e,void 0,void 0,(function(){var t,e,n,r,o,i,s;return D(this,(function(a){switch(a.label){case 0:return this.wsSign&&this.wsSign.expiredTs>Date.now()?[2,this.wsSign]:(t=Date.now()+6e4,[4,this.context.appConfig.request.send("auth.wsWebSign",{runtime:P()})]);case 1:if((e=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: "+e.code);if(e.data)return n=e.data,r=n.signStr,o=n.wsUrl,i=n.secretVersion,s=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:i,envId:s,expiredTs:t}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return e.rttObserved.length?e.rttObserved.reduce((function(t,e){return t+e}))/e.rttObserved.length*1.5:5e3},this.ping=function(){return U(e,void 0,void 0,(function(){var t;return D(this,(function(e){switch(e.label){case 0:return t={watchId:void 0,requestId:c(),msgType:"PING",msgData:null},[4,this.send({msg:t})];case 1:return e.sent(),[2]}}))}))},this.onWatchStart=function(t,n){e.queryIdClientMap.set(n,t)},this.onWatchClose=function(t,n){n&&e.queryIdClientMap.delete(n),e.watchIdClientMap.delete(t.watchId),e.virtualWSClient.delete(t),e.virtualWSClient.size||e.close(T.NoRealtimeListeners)},this.maxReconnect=t.maxReconnect||5,this.reconnectInterval=t.reconnectInterval||1e4,this.context=t.context}return t.prototype.clearHeartbeat=function(){this.pingTimeoutId&&clearTimeout(this.pingTimeoutId),this.pongTimeoutId&&clearTimeout(this.pongTimeoutId)},t.prototype.close=function(t){this.clearHeartbeat(),this.ws&&(this.ws.close(t,N[t].name),this.ws=void 0)},t.prototype.watch=function(t){this.ws||void 0!==this.wsInitPromise&&null!==this.wsInitPromise||this.initWebSocketConnection(!1);var e=new O(L(L({},t),{send:this.send,login:this.webLogin,isWSConnected:this.isWSConnected,onceWSConnected:this.onceWSConnected,getWaitExpectedTimeoutLength:this.getWaitExpectedTimeoutLength,onWatchStart:this.onWatchStart,onWatchClose:this.onWatchClose,debug:!0}));return this.virtualWSClient.add(e),this.watchIdClientMap.set(e.watchId,e),e.listener},t.prototype.heartbeat=function(t){var e=this;this.clearHeartbeat(),this.pingTimeoutId=setTimeout((function(){U(e,void 0,void 0,(function(){var t=this;return D(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),this.ws&&this.ws.readyState===j?(this.lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return e.sent(),this.pingFailed=0,this.pongTimeoutId=setTimeout((function(){console.error("pong timed out"),t.pongMissed<2?(t.pongMissed+=1,t.heartbeat(!0)):t.initWebSocketConnection(!0)}),this.context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return e.sent(),this.pingFailed<2?(this.pingFailed+=1,this.heartbeat()):this.close(T.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),t?0:this.context.appConfig.realtimePingInterval)},t}(),M={target:"database",entity:function(){var t,e=this.platform,n=e.adapter,r=e.runtime;t=n.wsClass,x=t,function(t){C=t}(r)}},B={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=k}};try{cloudbase.registerComponent(B),cloudbase.registerHook(M)}catch(t){}function q(t){try{t.registerComponent(B),t.registerHook(M)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"getBaseEndPoint",(function(){return O.b})),n.d(e,"cloudbase",(function(){return Q}));var r,o=n(0),i=n(3),s=(r=function(t,e){return(r=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)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),a=function(){return(a=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}).apply(this,arguments)},u=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},c=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}};var f=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return s(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(n,r){var o=t.url,s=t.data,a=t.headers,u=wx.request({url:Object(i.formatUrl)("https:",o),data:s,timeout:e._timeout,method:"POST",header:a,success:function(t){n(t)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&(e._timeout&&-1!==e._restrictedMethods.indexOf("post")&&"request:fail timeout"===t.errMsg)){console.warn(e._timeoutMsg);try{u.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,n=this;return new Promise((function(r){return u(e,void 0,void 0,(function(){var e,o,i,s,u,f;return c(this,(function(c){return e=t.url,o=t.file,i=t.data,s=t.headers,u=t.onUploadProgress,f=wx.uploadFile({url:e,filePath:o,name:"file",formData:a({},i),header:s,timeout:this._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&i.success_action_status&&(e.statusCode=parseInt(i.success_action_status,10)),r(e)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg)){console.warn(n._timeoutMsg);try{f.abort()}catch(t){}}}}),u&&f.onProgressUpdate((function(t){u(t)})),[2]}))}))}))},e.prototype.download=function(t){var e=this,n=this;return new Promise((function(r,o){var s=t.url,a=t.headers,u=wx.downloadFile({url:Object(i.formatUrl)("https:",s),header:a,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?r({statusCode:200,tempFilePath:t.tempFilePath}):r(t)},fail:function(t){o(t)},complete:function(t){if(t&&t.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg)){console.warn(n._timeoutMsg);try{u.abort()}catch(t){}}}})}))},e}(i.AbstractSDKRequest),l={setItem:function(t,e){wx.setStorageSync(t,e)},getItem:function(t){return wx.getStorageSync(t)},removeItem:function(t){wx.removeStorageSync(t)},clear:function(){wx.clearStorageSync()}},h=function(t,e){void 0===e&&(e={});var n=wx.connectSocket(a({url:t},e));return{set onopen(t){n.onOpen(t)},set onmessage(t){n.onMessage(t)},set onclose(t){n.onClose(t)},set onerror(t){n.onError(t)},send:function(t){return n.send({data:t})},close:function(t,e){return n.close({code:t,reason:e})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};var p={genAdapter:function(){return{root:{},reqClass:f,wsClass:h,localStorage:l,primaryStorage:i.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0},runtime:"wx_mp"},d=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r},y=o.constants.ERRORS,g={};function v(t,e){var n=e.name,r=e.namespace,o=e.entity,i=e.injectEvents,s=e.IIFE,a=void 0!==s&&s;if(g[n]||r&&t[r])throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"Duplicate component "+n}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:y.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(t)}if(g[n]=e,r?t.prototype[r]=o:function t(e,n){if(!(n instanceof Object))return n;switch(n.constructor){case Date:return new Date(n.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return n}for(var r=Object.keys(n),o=0,i=r;o<i.length;o++){var s=i[o];Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=t(e[s],n[s]))}return e}(t.prototype,o),i){var u=i.bus,c=i.events;if(!u||!c||0===c.length)return;var f=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[n]?t.prototype.events[n].events=d(t.prototype.events[n].events,c):t.prototype.events[n]={bus:u,events:c},t.prototype.fire=function(t,e){f(t,e);for(var n=0,r=Object.keys(this.events);n<r.length;n++){var o=r[n],i=this.events[o],s=i.bus;if(i.events.includes(t)){s.fire(t,e);break}}}}}var m={},b=function(){return(b=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}).apply(this,arguments)},w=o.cache.CloudbaseCache,_={},E={};function I(t){var e=t.env,n=t.platformInfo,r={userInfoKey:"user_info_"+e};_[e]=_[e]||new w(b(b({},t),{keys:r,platformInfo:n})),E[e]=E[e]||new w(b(b({},t),{keys:r,platformInfo:n,persistence:"local"}))}function S(t){return E[t]}var O=n(1),A=function(){return(A=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}).apply(this,arguments)},T=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},N=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},R=o.constants.ERRORS,x=o.utils.genSeqId,C=o.utils.isFormData,P=o.utils.formatUrl,L=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function U(t,e,n){var r=t[e];t[e]=function(e){var o={},i={};n.forEach((function(n){var r=n.call(t,e),s=r.data,a=r.headers;Object.assign(o,s),Object.assign(i,a)}));var s=e.data;return s&&(C(s)?Object.keys(o).forEach((function(t){s.append(t,o[t])})):e.data=A(A({},s),o)),e.headers=A(A({},e.headers||{}),i),r.call(t,e)}}function D(){var t=x();return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+Object(O.e)(),"x-seqid":t}}}var j=function(){function t(t){this.throwWhenRequestFail=!1,this.config=t;var e={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post","put"]};this.reqClass=new m.adapter.reqClass(e),this.throwWhenRequestFail=t.throw||!1,this.localCache=S(this.config.env),U(this.reqClass,"post",[D]),U(this.reqClass,"upload",[D]),U(this.reqClass,"download",[D])}return t.prototype.post=function(t){return T(this,void 0,void 0,(function(){return N(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.upload=function(t){return T(this,void 0,void 0,(function(){return N(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.upload(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return T(this,void 0,void 0,(function(){return N(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.download(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(){return Object(O.b)()},t.prototype.getOauthAccessTokenV2=function(t){return T(this,void 0,void 0,(function(){var e,n;return N(this,(function(r){switch(r.label){case 0:return[4,t.getAccessToken()];case 1:return e=r.sent(),[4,t.getCredentials()];case 2:return n=r.sent(),[2,{accessToken:e,accessTokenExpire:new Date(n.expires_at).getTime()}]}}))}))},t.prototype.request=function(t,e,n){var r;return T(this,void 0,void 0,(function(){var o,i,s,a,u,c,f,l,h,p,d,y,g,v,m,b,w,_,E,I;return N(this,(function(S){switch(S.label){case 0:if(o="x-tcb-trace_"+this.config.env,i="application/x-www-form-urlencoded",s=A({action:t,dataVersion:O.a,env:this.config.env},e),-1!==L.indexOf(t))return[3,2];if(!(a=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return u=a.oauthInstance,c=u.oauth2client,f=s,[4,this.getOauthAccessTokenV2(c)];case 1:f.access_token=S.sent().accessToken,S.label=2;case 2:return"storage.uploadFile"===t?(l=new FormData,Object.keys(l).forEach((function(t){Object.prototype.hasOwnProperty.call(l,t)&&void 0!==l[t]&&l.append(t,s[t])})),i="multipart/form-data"):(i="application/json;charset=UTF-8",l={},Object.keys(s).forEach((function(t){void 0!==s[t]&&(l[t]=s[t])}))),h={headers:{"content-type":i}},(null==n?void 0:n.onUploadProgress)&&(h.onUploadProgress=n.onUploadProgress),this.config.region&&(h.headers["X-TCB-Region"]=this.config.region),(p=this.localCache.getStore(o))&&(h.headers["X-TCB-Trace"]=p),d=e.parse,y=e.inQuery,g=e.search,v={env:this.config.env},d&&(v.parse=!0),y&&(v=A(A({},y),v)),m=Object(O.c)(),b=m.BASE_URL,w=m.PROTOCOL,_=P(w,b,v),g&&(_+=g),[4,this.post(A({url:_,data:l},h))];case 3:if(E=S.sent(),(I=null===(r=E.header)||void 0===r?void 0:r["x-tcb-trace"])&&this.localCache.setStore(o,I),200!==Number(E.status)&&200!==Number(E.statusCode)||!E.data)throw new Error("network request error");return[2,E]}}))}))},t.prototype.send=function(t,e){return void 0===e&&(e={}),T(this,void 0,void 0,(function(){var n;return N(this,(function(r){switch(r.label){case 0:return[4,this.request(t,e,{onUploadProgress:e.onUploadProgress})];case 1:if((n=r.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:R.OPERATION_FAIL,msg:"["+n.data.code+"] "+n.data.message}));return[2,n.data]}}))}))},t}(),k={};var M=function(){return(M=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}).apply(this,arguments)},B=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},q=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},F=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},W=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},$=o.adapters.useAdapters,V=o.adapters.useDefaultAdapter,H=o.constants.ERRORS,G=o.constants.COMMUNITY_SITE_URL,J=o.utils.printWarn,K=o.helpers.catchErrorsDecorator,Y={timeout:15e3,persistence:"local"},z={},Q=new(function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return m},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this.cloudbaseConfig.env,_[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return S(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this.cloudbaseConfig.env,k[t];var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){if(!e.env)throw new Error(JSON.stringify({code:H.INVALID_PARAMS,msg:"env must not be specified"}));m.adapter||this.useDefaultAdapter();var n={timeout:e.timeout||5e3,timeoutMsg:"["+Object(O.d)()+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+e.timeout/1e3+"s"};this.requestClient=new m.adapter.reqClass(n),this.cloudbaseConfig=M(M({},Y),e),this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var r=this.cloudbaseConfig,o=r.env,i=r.persistence,s=r.debug,a=r.timeout,u=r.oauthClient;I({env:o,persistence:i,debug:s,platformInfo:this.platform}),Object(O.g)(o,e.region||"");var c=new t(this.cloudbaseConfig);return function(t){k[t.env]=new j(A(A({},t),{throw:!0}))}({env:o,region:e.region||"",timeout:a,oauthClient:u,_fromApp:c}),c.requestClient=this.requestClient,c},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=n,I({env:this.cloudbaseConfig.env,persistence:e,debug:n,platformInfo:this.platform})},t.prototype.registerExtension=function(t){z[t.name]=t},t.prototype.invokeExtension=function(t,e){return F(this,void 0,void 0,(function(){var n;return W(this,(function(r){switch(r.label){case 0:if(!(n=z[t]))throw new Error(JSON.stringify({code:H.INVALID_PARAMS,msg:"extension:"+t+" must be registered before invoke"}));return[4,n.invoke(e,this)];case 1:return[2,r.sent()]}}))}))},t.prototype.useAdapters=function(t){var e=$(t)||{},n=e.adapter,r=e.runtime;n&&(m.adapter=n),r&&(m.runtime=r)},t.prototype.registerHook=function(e){!function(t,e){var n=e.entity,r=e.target;if(Object.prototype.hasOwnProperty.call(t,r))throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"target:"+r+" is not exist"}));var o=t.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"target:"+r+" is not a function which is the only type supports hook"}));t.prototype[r]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.call.apply(n,d([this],t)),o.call.apply(o,d([this],t))}}(t,e)},t.prototype.registerComponent=function(e){v(t,e)},t.prototype.registerVersion=function(t){Object(O.i)(t)},t.prototype.registerSdkName=function(t){Object(O.h)(t)},t.prototype.registerEndPoint=function(t,e){Object(O.f)(t,e)},t.prototype.useDefaultAdapter=function(){var t=V(),e=t.adapter,n=t.runtime;m.adapter=e,m.runtime=n},t.prototype.formatTimeout=function(t){switch(!0){case t>6e5:return J(H.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),6e5;case t<100:return J(H.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},B([K({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+G]}),q("design:type",Function),q("design:paramtypes",[Object]),q("design:returntype",t)],t.prototype,"init",null),B([K({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+G]}),q("design:type",Function),q("design:paramtypes",[String,Object]),q("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}());Q.useAdapters(p);e.default=Q}])}));
17
+ var b=function(t,e){return(b=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)};function w(t,e){function n(){this.constructor=t}b(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var _=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return w(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),e}(Error),E=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return w(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),e}(TypeError);function I(t){return t&&t.Math==Math&&t}function S(){return I("object"==typeof globalThis&&globalThis)||I("object"==typeof window&&window)||I("object"==typeof self&&self)||I("object"==typeof t&&t)||Function("return this")()}var O=function(t){var e,n="object"==typeof(e=S()).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=m.alloc(t),o=0;o<t;++o)r[o]=Math.floor(256*Math.random());return r},A=function(){if("undefined"!=typeof window){var e=window.crypto||window.msCrypto;if(e&&e.getRandomValues)return function(t){return e.getRandomValues(m.alloc(t))}}return void 0!==t&&t.crypto&&t.crypto.getRandomValues?function(e){return t.crypto.getRandomValues(m.alloc(e))}:O}();function T(t){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(t))}function N(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function R(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function x(t){return C(t)&&"[object Date]"===Object.prototype.toString.call(t)}function C(t){return"object"==typeof t&&null!==t}function P(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 L(t){if(ArrayBuffer.isView(t))return m.from(t.buffer,t.byteOffset,t.byteLength);if(T(t))return m.from(t);throw new E("Must use either Buffer or TypedArray")}var U=/^(?:[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,D=function(t){return"string"==typeof t&&U.test(t)},j=function(t){if(!D(t))throw new E('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 m.from(e,"hex")},k=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")},M=(Math.pow(2,63),Math.pow(2,63),Math.pow(2,53)),B=-Math.pow(2,53),q=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 E("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=m.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=m.from(e,"binary"):Array.isArray(e)?this.buffer=m.from(e):this.buffer=L(e),this.position=this.buffer.byteLength)}return t.prototype.put=function(e){if("string"==typeof e&&1!==e.length)throw new E("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new E("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 E("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=m.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=m.alloc(this.buffer.length+t.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n}ArrayBuffer.isView(t)?(this.buffer.set(L(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 F(this.buffer.slice(0,this.position));throw new _('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=m.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=m.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,r=j(e.$uuid)),!r)throw new E("Unexpected Binary Extended JSON format ".concat(JSON.stringify(e)));return 4===o?new F(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(q.prototype,"_bsontype",{value:"Binary"});var F=function(t){function e(n){var r,o,i=this;if(null==n)r=e.generate();else if(n instanceof e)r=m.from(n.buffer),o=n.__id;else if(ArrayBuffer.isView(n)&&16===n.byteLength)r=L(n);else{if("string"!=typeof n)throw new E("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=j(n)}return(i=t.call(this,r,4)||this).__id=o,i}return w(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.buffer},set:function(t){this.buffer=t,e.cacheHexString&&(this.__id=k(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=k(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 q(this.id,q.SUBTYPE_UUID)},e.generate=function(){var t=A(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,m.from(t)},e.isValid=function(t){return!!t&&(t instanceof e||("string"==typeof t?D(t):!!N(t)&&(16===t.length&&(64==(240&t[6])&&128==(128&t[8])))))},e.createFromHexString=function(t){return new e(j(t))},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},e}(q),W=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}();function $(t){return C(t)&&null!=t.$id&&"string"==typeof t.$ref&&(null==t.$db||"string"==typeof t.$db)}Object.defineProperty(W.prototype,"_bsontype",{value:"Code"});var V=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(V.prototype,"_bsontype",{value:"DBRef"});var H=void 0;try{H=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(t){}var G={},J={},K=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=J[e])?o:(r=t.fromBits(e,(0|e)<0?-1:0,!0),i&&(J[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(o=G[e])?o:(r=t.fromBits(e,e<0?-1:0,!1),i&&(G[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>=0x10000000000000000)return t.MAX_UNSIGNED_VALUE}else{if(e<=-0x8000000000000000)return t.MIN_VALUE;if(e+1>=0x8000000000000000)return t.MAX_VALUE}return e<0?t.fromNumber(-e,n).neg():t.fromBits(e%4294967296|0,e/4294967296|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)),s=t.ZERO,a=0;a<e.length;a+=8){var u=Math.min(8,e.length-a),c=parseInt(e.substring(a,a+u),r);if(u<8){var f=t.fromNumber(Math.pow(r,u));s=s.mul(f).add(t.fromNumber(c))}else s=(s=s.mul(i)).add(t.fromNumber(c))}return s.unsigned=n,s},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 C(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,s=e.high>>>16,a=65535&e.high,u=e.low>>>16,c=0,f=0,l=0,h=0;return l+=(h+=i+(65535&e.low))>>>16,h&=65535,f+=(l+=o+u)>>>16,l&=65535,c+=(f+=r+a)>>>16,f&=65535,c+=n+s,c&=65535,t.fromBits(l<<16|h,c<<16|f,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(H){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;var n=(this.unsigned?H.div_u:H.div_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,H.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 s=Math.ceil(Math.log(r)/Math.LN2),a=s<=48?1:Math.pow(2,s-48),u=t.fromNumber(r),c=u.mul(e);c.isNegative()||c.gt(o);)r-=a,c=(u=t.fromNumber(r,this.unsigned)).mul(e);u.isZero()&&(u=t.ONE),i=i.add(u),o=o.sub(c)}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&&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 0==(1&this.low)},t.prototype.isNegative=function(){return!this.unsigned&&this.high<0},t.prototype.isOdd=function(){return 1==(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)),H){var n=(this.unsigned?H.rem_u:H.rem_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,H.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)),H){var n=H.mul(this.low,this.high,e.low,e.high);return t.fromBits(n,H.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,s=65535&this.low,a=e.high>>>16,u=65535&e.high,c=e.low>>>16,f=65535&e.low,l=0,h=0,p=0,d=0;return p+=(d+=s*f)>>>16,d&=65535,h+=(p+=i*f)>>>16,p&=65535,h+=(p+=s*c)>>>16,p&=65535,l+=(h+=o*f)>>>16,h&=65535,l+=(h+=i*c)>>>16,h&=65535,l+=(h+=s*u)>>>16,h&=65535,l+=r*f+o*c+i*u+s*a,l&=65535,t.fromBits(p<<16|d,l<<16|h,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?4294967296*(this.high>>>0)+(this.low>>>0):4294967296*this.high+(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),s=this,a="";;){var u=s.div(i),c=(s.sub(u.mul(i)).toInt()>>>0).toString(e);if((s=u).isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}},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(1<<24),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(K.prototype,"__isLong__",{value:!0}),Object.defineProperty(K.prototype,"_bsontype",{value:"Long"});var Y=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,z=/^(\+|-)?(Infinity|inf)$/i,Q=/^(\+|-)?NaN$/i,Z=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),X=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),tt=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),et=/^([-+])?(\d+)?$/;function nt(t){return!isNaN(parseInt(t,10))}function rt(t){var e=K.fromNumber(1e9),n=K.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 K(t.parts[r],0)),t.parts[r]=n.div(e).low,n=n.modulo(e);return{quotient:t,rem:n}}function ot(t,e){throw new E('"'.concat(t,'" is not a valid Decimal128 string - ').concat(e))}var it=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!N(e))throw new E("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new E("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(e){var n,r=!1,o=!1,i=!1,s=0,a=0,u=0,c=0,f=0,l=[0],h=0,p=0,d=0,y=0,g=0,v=0,b=new K(0,0),w=new K(0,0),_=0;if(e.length>=7e3)throw new E(e+" not a valid Decimal128 string");var I=e.match(Y),S=e.match(z),O=e.match(Q);if(!I&&!S&&!O||0===e.length)throw new E(e+" not a valid Decimal128 string");if(I){var A=I[2],T=I[4],N=I[5],R=I[6];T&&void 0===R&&ot(e,"missing exponent power"),T&&void 0===A&&ot(e,"missing exponent base"),void 0===T&&(N||R)&&ot(e,"missing e before exponent")}if("+"!==e[_]&&"-"!==e[_]||(r="-"===e[_++]),!nt(e[_])&&"."!==e[_]){if("i"===e[_]||"I"===e[_])return new t(m.from(r?X:tt));if("N"===e[_])return new t(m.from(Z))}for(;nt(e[_])||"."===e[_];)"."!==e[_]?(h<34&&("0"!==e[_]||i)&&(i||(f=a),i=!0,l[p++]=parseInt(e[_],10),h+=1),i&&(u+=1),o&&(c+=1),a+=1,_+=1):(o&&ot(e,"contains multiple periods"),o=!0,_+=1);if(o&&!a)throw new E(e+" not a valid Decimal128 string");if("e"===e[_]||"E"===e[_]){var x=e.substr(++_).match(et);if(!x||!x[2])return new t(m.from(Z));g=parseInt(x[0],10),_+=x[0].length}if(e[_])return new t(m.from(Z));if(d=0,h){if(y=h-1,1!==(s=u))for(;0===l[f+s-1];)s-=1}else d=0,y=0,l[0]=0,u=1,h=1,s=0;for(g<=c&&c-g>16384?g=-6176:g-=c;g>6111;){if((y+=1)-d>34){if(l.join("").match(/^0+$/)){g=6111;break}ot(e,"overflow")}g-=1}for(;g<-6176||h<u;){if(0===y&&s<h){g=-6176,s=0;break}if(h<u?u-=1:y-=1,g<6111)g+=1;else{if(l.join("").match(/^0+$/)){g=6111;break}ot(e,"overflow")}}if(y-d+1<s){var C=a;o&&(f+=1,C+=1),r&&(f+=1,C+=1);var P=parseInt(e[f+y+1],10),L=0;if(P>=5&&(L=1,5===P))for(L=l[y]%2==1?1:0,v=f+y+2;v<C;v++)if(parseInt(e[v],10)){L=1;break}if(L)for(var U=y;U>=0;U--)if(++l[U]>9&&(l[U]=0,0===U)){if(!(g<6111))return new t(m.from(r?X:tt));g+=1,l[U]=1}}if(b=K.fromNumber(0),w=K.fromNumber(0),0===s)b=K.fromNumber(0),w=K.fromNumber(0);else if(y-d<17){U=d;for(w=K.fromNumber(l[U++]),b=new K(0,0);U<=y;U++)w=(w=w.multiply(K.fromNumber(10))).add(K.fromNumber(l[U]))}else{U=d;for(b=K.fromNumber(l[U++]);U<=y-17;U++)b=(b=b.multiply(K.fromNumber(10))).add(K.fromNumber(l[U]));for(w=K.fromNumber(l[U++]);U<=y;U++)w=(w=w.multiply(K.fromNumber(10))).add(K.fromNumber(l[U]))}var D,j,k,M,B=function(t,e){if(!t&&!e)return{high:K.fromNumber(0),low:K.fromNumber(0)};var n=t.shiftRightUnsigned(32),r=new K(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new K(e.getLowBits(),0),s=n.multiply(o),a=n.multiply(i),u=r.multiply(o),c=r.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new K(a.getLowBits(),0).add(u).add(c.shiftRightUnsigned(32)),{high:s=s.add(a.shiftRightUnsigned(32)),low:c=a.shiftLeft(32).add(new K(c.getLowBits(),0))}}(b,K.fromString("100000000000000000"));B.low=B.low.add(w),D=B.low,j=w,k=D.high>>>0,M=j.high>>>0,(k<M||k===M&&D.low>>>0<j.low>>>0)&&(B.high=B.high.add(K.fromNumber(1))),n=g+6176;var q={low:K.fromNumber(0),high:K.fromNumber(0)};B.high.shiftRightUnsigned(49).and(K.fromNumber(1)).equals(K.fromNumber(1))?(q.high=q.high.or(K.fromNumber(3).shiftLeft(61)),q.high=q.high.or(K.fromNumber(n).and(K.fromNumber(16383).shiftLeft(47))),q.high=q.high.or(B.high.and(K.fromNumber(0x7fffffffffff)))):(q.high=q.high.or(K.fromNumber(16383&n).shiftLeft(49)),q.high=q.high.or(B.high.and(K.fromNumber(562949953421311)))),q.low=B.low,r&&(q.high=q.high.or(K.fromString("9223372036854775808")));var F=m.alloc(16);return _=0,F[_++]=255&q.low.low,F[_++]=q.low.low>>8&255,F[_++]=q.low.low>>16&255,F[_++]=q.low.low>>24&255,F[_++]=255&q.low.high,F[_++]=q.low.high>>8&255,F[_++]=q.low.high>>16&255,F[_++]=q.low.high>>24&255,F[_++]=255&q.high.low,F[_++]=q.high.low>>8&255,F[_++]=q.high.low>>16&255,F[_++]=q.high.low>>24&255,F[_++]=255&q.high.high,F[_++]=q.high.high>>8&255,F[_++]=q.high.high>>16&255,F[_++]=q.high.high>>24&255,new t(F)},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,s,a=0,u=!1,c={parts:[0,0,0,0]},f=[];a=0;var l=this.bytes,h=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,p=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,d=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,y=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24;a=0,{low:new K(h,p),high:new K(d,y)}.high.lessThan(K.ZERO)&&f.push("-");var g=y>>26&31;if(g>>3==3){if(30===g)return f.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 v=t-6176;if(c.parts[0]=(16383&y)+((15&o)<<14),c.parts[1]=d,c.parts[2]=p,c.parts[3]=h,0===c.parts[0]&&0===c.parts[1]&&0===c.parts[2]&&0===c.parts[3])u=!0;else for(s=3;s>=0;s--){var m=0,b=rt(c);if(c=b.quotient,m=b.rem.low)for(i=8;i>=0;i--)n[9*s+i]=m%10,m=Math.floor(m/10)}if(u)e=1,n[a]=0;else for(e=36;!n[a];)e-=1,a+=1;var w=e-1+v;if(w>=34||w<=-7||v>0){if(e>34)return f.push("".concat(0)),v>0?f.push("E+".concat(v)):v<0&&f.push("E".concat(v)),f.join("");f.push("".concat(n[a++])),(e-=1)&&f.push(".");for(r=0;r<e;r++)f.push("".concat(n[a++]));f.push("E"),w>0?f.push("+".concat(w)):f.push("".concat(w))}else if(v>=0)for(r=0;r<e;r++)f.push("".concat(n[a++]));else{var _=e+v;if(_>0)for(r=0;r<_;r++)f.push("".concat(n[a++]));else f.push("0");for(f.push(".");_++<0;)f.push("0");for(r=0;r<e-Math.max(_-1,0);r++)f.push("".concat(n[a++]))}return f.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(it.prototype,"_bsontype",{value:"Decimal128"});var st=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(st.prototype,"_bsontype",{value:"Double"});var at=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(at.prototype,"_bsontype",{value:"Int32"});var ut=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(ut.prototype,"_bsontype",{value:"MaxKey"});var ct=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(ct.prototype,"_bsontype",{value:"MinKey"});var ft=new RegExp("^[0-9a-fA-F]{24}$"),lt=null,ht=Symbol("id"),pt=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 E("Argument passed in must have an id that is of type string or Buffer");n="toHexString"in e&&"function"==typeof e.toHexString?m.from(e.toHexString(),"hex"):e.id}else n=e;if(null==n||"number"==typeof n)this[ht]=t.generate("number"==typeof n?n:void 0);else if(ArrayBuffer.isView(n)&&12===n.byteLength)this[ht]=n instanceof m?n:L(n);else{if("string"!=typeof n)throw new E("Argument passed in does not match the accepted types");if(12===n.length){var r=m.from(n);if(12!==r.byteLength)throw new E("Argument passed in must be a string of 12 bytes");this[ht]=r}else{if(24!==n.length||!ft.test(n))throw new E("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[ht]=m.from(n,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[ht]},set:function(e){this[ht]=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=m.alloc(12);return r.writeUInt32BE(e,0),null===lt&&(lt=A(5)),r[4]=lt[0],r[5]=lt[1],r[6]=lt[2],r[7]=lt[3],r[8]=lt[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[ht][11]===e[ht][11]&&this[ht].equals(e[ht]);if("string"==typeof e&&t.isValid(e)&&12===e.length&&N(this.id))return e===m.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 m.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=m.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 E("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(m.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(pt.prototype,"generate",{value:P((function(t){return pt.generate(t)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(pt.prototype,"getInc",{value:P((function(){return pt.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(pt.prototype,"get_inc",{value:P((function(){return pt.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(pt,"get_inc",{value:P((function(){return pt.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(pt.prototype,"_bsontype",{value:"ObjectID"});var dt=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 _("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new _("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 _("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 E("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(e)))},t}();Object.defineProperty(dt.prototype,"_bsontype",{value:"BSONRegExp"});var yt=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(yt.prototype,"_bsontype",{value:"Symbol"});var gt=function(t){function e(n,r){var o=this;return o instanceof e?(o=K.isLong(n)?t.call(this,n.low,n.high,!0)||this:C(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 w(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(K.fromInt(t,!0))},e.fromNumber=function(t){return new e(K.fromNumber(t,!0))},e.fromBits=function(t,n){return new e(t,n)},e.fromString=function(t,n){return new e(K.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=K.MAX_UNSIGNED_VALUE,e}(K);function vt(t){return C(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}var mt={$oid:pt,$binary:q,$uuid:q,$symbol:yt,$numberInt:at,$numberDecimal:it,$numberDouble:st,$numberLong:K,$minKey:ct,$maxKey:ut,$regex:dt,$regularExpression:dt,$timestamp:gt};function bt(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function wt(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],s=" -> "+r.slice(n+1,r.length-1).map((function(t){return"".concat(t," -> ")})).join(""),a=r[r.length-1],u=" ".repeat(o.length+i.length/2),c="-".repeat(s.length+(i.length+a.length)/2-1);throw new E("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(s).concat(a,"\n")+" ".concat(u,"\\").concat(c,"/"))}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 wt(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||x(t)){var f=t.getTime(),l=f>-1&&f<2534023188e5;return e.legacy?e.relaxed&&l?{$date:t.getTime()}:{$date:bt(t)}:e.relaxed&&l?{$date:bt(t)}:{$date:{$numberLong:t.getTime().toString()}}}if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Math.floor(t)===t){var h=t>=-0x8000000000000000&&t<=0x8000000000000000;if(t>=-2147483648&&t<=2147483647)return{$numberInt:t.toString()};if(h)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||R(t)){var p=t.flags;if(void 0===p){var d=t.toString().match(/[gimuy]*$/);d&&(p=d[0])}return new dt(t.source,p).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new _("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=wt(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(vt(t)){var s=t;if("function"!=typeof s.toExtendedJSON){var a=Et[t._bsontype];if(!a)throw new E("Unrecognized or invalid _bsontype: "+t._bsontype);s=a(s)}return"Code"===n&&s.scope?s=new W(s.code,wt(s.scope,e)):"DBRef"===n&&s.oid&&(s=new V(wt(s.collection,e),wt(s.oid,e),wt(s.db,e),wt(s.fields,e))),s.toExtendedJSON(e)}throw new _("_bsontype must be a string, but was: "+typeof n)}(t,e):t}var _t,Et={Binary:function(t){return new q(t.value(),t.sub_type)},Code:function(t){return new W(t.code,t.scope)},DBRef:function(t){return new V(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new it(t.bytes)},Double:function(t){return new st(t.value)},Int32:function(t){return new at(t.value)},Long:function(t){return K.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 ut},MinKey:function(){return new ct},ObjectID:function(t){return new pt(t)},ObjectId:function(t){return new pt(t)},BSONRegExp:function(t){return new dt(t.pattern,t.options)},Symbol:function(t){return new yt(t.value)},Timestamp:function(t){return gt.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 _("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(t)));return function t(e,n){if(void 0===n&&(n={}),"number"==typeof e){if(n.relaxed||n.legacy)return e;if(Math.floor(e)===e){if(e>=-2147483648&&e<=2147483647)return new at(e);if(e>=-0x8000000000000000&&e<=0x8000000000000000)return K.fromNumber(e)}return new st(e)}if(null==e||"object"!=typeof e)return e;if(e.$undefined)return null;for(var r=Object.keys(e).filter((function(t){return t.startsWith("$")&&null!=e[t]})),o=0;o<r.length;o++){var i=mt[r[o]];if(i)return i.fromExtendedJSON(e,n)}if(null!=e.$date){var s=e.$date,a=new Date;return n.legacy?"number"==typeof s?a.setTime(s):"string"==typeof s&&a.setTime(Date.parse(s)):"string"==typeof s?a.setTime(Date.parse(s)):K.isLong(s)?a.setTime(s.toNumber()):"number"==typeof s&&n.relaxed&&a.setTime(s),a}if(null!=e.$code){var u=Object.assign({},e);return e.$scope&&(u.$scope=t(e.$scope)),W.fromExtendedJSON(e)}if($(e)||e.$dbPointer){var c=e.$ref?e:e.$dbPointer;if(c instanceof V)return c;var f=Object.keys(c).filter((function(t){return t.startsWith("$")})),l=!0;if(f.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(l=!1)})),l)return V.fromExtendedJSON(c)}return e}(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=wt(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)}}(_t||(_t={}));var It=S();It.Map?It.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})}();K.fromNumber(M),K.fromNumber(B);new Set(["$db","$ref","$id","$clusterTime"]);var St=new Uint8Array(8);new DataView(St.buffer,St.byteOffset,St.byteLength);m.alloc(17825792)}).call(this,n(7))},function(t,e,n){"use strict";var r;n.r(e),n.d(e,"StorageType",(function(){return r})),n.d(e,"AbstractSDKRequest",(function(){return o})),n.d(e,"AbstractStorage",(function(){return i})),n.d(e,"formatUrl",(function(){return s})),function(t){t.local="local",t.none="none",t.session="session"}(r||(r={}));var o=function(){},i=function(){};function s(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";for(var i in n)""===o?!r&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.createSign=e.formatUrl=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var o=r(n(20)),i=r(n(23)),s=r(n(24)),a=n(6);function u(t){var e=i.default.stringify(t);return e=(e=(e=e.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.formatUrl=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";return Object.keys(n).forEach((function(t){""===o?!r&&(e+="?"):o+="&",o+=t+"="+encodeURIComponent(n[t])})),/^http(s)?:\/\//.test(e+=o)?e:""+t+e},e.createSign=function(t,e){var n=u(s.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+u(s.default.parse(JSON.stringify(t)));return n+"."+u(o.default(n,e))},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(n){e.push(n+"="+encodeURIComponent(t[n]))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var n=e||window.location.search,r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]"+t+"=([^&#]*)"));return e?e[1]:""},e.removeParam=function(t,e){var n=e.split("?")[0],r=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===t&&r.splice(i,1);n=n+"?"+r.join("&")}return n},e.createPromiseCallback=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},e.execCallback=function(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n},e.printWarn=function(t,e){console.warn("["+a.getSdkName()+"]["+t+"]:"+e)},e.printError=function(t,e){console.error({code:t,msg:"["+a.getSdkName()+"]["+t+"]:"+e})},e.printInfo=function(t,e){console.log("["+a.getSdkName()+"]["+t+"]:"+e)},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"["+a.getSdkName()+"]["+t+"]:"+e}))},e.printGroupLog=function(t){var e=t.title,n=t.subtitle,r=void 0===n?"":n,o=t.content,i=void 0===o?[]:o,s=t.printTrace,a=void 0!==s&&s,u=t.collapsed;void 0!==u&&u?console.groupCollapsed(e,r):console.group(e,r);for(var c=0,f=i;c<f.length;c++){var l=f[c],h=l.type,p=l.body;switch(h){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}a&&console.trace("stack trace:"),console.groupEnd()},e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86"+t}},function(t,e,n){var r;t.exports=(r=r||function(t,e){var n=Object.create||function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}}(),r={},o=r.lib={},i=o.Base={extend:function(t){var e=n(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=o.WordArray=i.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;e[r+i>>>2]|=s<<24-(r+i)%4*8}else for(i=0;i<o;i+=4)e[r+i>>>2]=n[i>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=i.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n,r=[],o=function(e){e=e;var n=987654321,r=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&r)<<16)+(e=18e3*(65535&e)+(e>>16)&r)&r;return o/=4294967296,(o+=.5)*(t.random()>.5?1:-1)}},i=0;i<e;i+=4){var a=o(4294967296*(n||t.random()));n=987654071*a(),r.push(4294967296*a()|0)}return new s.init(r,e)}}),a=r.enc={},u=a.Hex={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new s.init(n,e/2)}},c=a.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r++)n[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new s.init(n,e)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},l=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,a=o/(4*i),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*i,c=t.min(4*u,o);if(u){for(var f=0;f<u;f+=i)this._doProcessBlock(r,f);var l=r.splice(0,u);n.sigBytes-=c}return new s.init(l,c)},clone:function(){var t=i.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),h=(o.Hasher=l.extend({cfg:i.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,n){return new t.init(n).finalize(e)}},_createHmacHelper:function(t){return function(e,n){return new h.HMAC.init(t,n).finalize(e)}}}),r.algo={});return r}(Math),r)},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(n(8),e),o(n(17),e),e.OATUH_LOGINTYPE="constants"},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var o="https:";e.setProtocol=function(t){o=t},e.getProtocol=function(){return o},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},function(t,e){var n,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(t){r=s}}();var u,c=[],f=!1,l=-1;function h(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&p())}function p(){if(!f){var t=a(h);f=!0;for(var e=c.length;e;){for(u=c,c=[];++l<e;)u&&u[l].run();l=-1,e=c.length}u=null,f=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function y(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new d(t,e)),1!==c.length||f||a(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e){},function(t,e,n){(function(e){var n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/,o=/^\./,i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g,a=/^\[object .+?Constructor\]$/,u=/^(?:0|[1-9]\d*)$/,c="object"==typeof e&&e&&e.Object===Object&&e,f="object"==typeof self&&self&&self.Object===Object&&self,l=c||f||Function("return this")();var h,p=Array.prototype,d=Function.prototype,y=Object.prototype,g=l["__core-js_shared__"],v=(h=/[^.]+$/.exec(g&&g.keys&&g.keys.IE_PROTO||""))?"Symbol(src)_1."+h:"",m=d.toString,b=y.hasOwnProperty,w=y.toString,_=RegExp("^"+m.call(b).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),E=l.Symbol,I=p.splice,S=j(l,"Map"),O=j(Object,"create"),A=E?E.prototype:void 0,T=A?A.toString:void 0;function N(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function R(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function x(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function C(t,e,n){var r=t[e];b.call(t,e)&&F(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function P(t,e){for(var n=t.length;n--;)if(F(t[n][0],e))return n;return-1}function L(t){return!(!$(t)||(e=t,v&&v in e))&&(function(t){var e=$(t)?w.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?_:a).test(function(t){if(null!=t){try{return m.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function U(t,e,o,i){if(!$(t))return t;for(var s=-1,a=(e=function(t,e){if(W(t))return!1;var o=typeof t;if("number"==o||"symbol"==o||"boolean"==o||null==t||V(t))return!0;return r.test(t)||!n.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:function(t){return W(t)?t:M(t)}(e)).length,u=a-1,c=t;null!=c&&++s<a;){var f=B(e[s]),l=o;if(s!=u){var h=c[f];void 0===(l=i?i(h,f,c):void 0)&&(l=$(h)?h:k(e[s+1])?[]:{})}C(c,f,l),c=c[f]}return t}function D(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function j(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return L(n)?n:void 0}function k(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||u.test(t))&&t>-1&&t%1==0&&t<e}N.prototype.clear=function(){this.__data__=O?O(null):{}},N.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},N.prototype.get=function(t){var e=this.__data__;if(O){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return b.call(e,t)?e[t]:void 0},N.prototype.has=function(t){var e=this.__data__;return O?void 0!==e[t]:b.call(e,t)},N.prototype.set=function(t,e){return this.__data__[t]=O&&void 0===e?"__lodash_hash_undefined__":e,this},R.prototype.clear=function(){this.__data__=[]},R.prototype.delete=function(t){var e=this.__data__,n=P(e,t);return!(n<0)&&(n==e.length-1?e.pop():I.call(e,n,1),!0)},R.prototype.get=function(t){var e=this.__data__,n=P(e,t);return n<0?void 0:e[n][1]},R.prototype.has=function(t){return P(this.__data__,t)>-1},R.prototype.set=function(t,e){var n=this.__data__,r=P(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},x.prototype.clear=function(){this.__data__={hash:new N,map:new(S||R),string:new N}},x.prototype.delete=function(t){return D(this,t).delete(t)},x.prototype.get=function(t){return D(this,t).get(t)},x.prototype.has=function(t){return D(this,t).has(t)},x.prototype.set=function(t,e){return D(this,t).set(t,e),this};var M=q((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(V(t))return T?T.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return o.test(t)&&n.push(""),t.replace(i,(function(t,e,r,o){n.push(r?o.replace(s,"$1"):e||t)})),n}));function B(t){if("string"==typeof t||V(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function q(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(q.Cache||x),n}function F(t,e){return t===e||t!=t&&e!=e}q.Cache=x;var W=Array.isArray;function $(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function V(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==w.call(t)}t.exports=function(t,e,n){return null==t?t:U(t,e,n)}}).call(this,n(7))},function(t,e,n){(function(e){var n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/,o=/^\./,i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g,a=/^\[object .+?Constructor\]$/,u="object"==typeof e&&e&&e.Object===Object&&e,c="object"==typeof self&&self&&self.Object===Object&&self,f=u||c||Function("return this")();var l,h=Array.prototype,p=Function.prototype,d=Object.prototype,y=f["__core-js_shared__"],g=(l=/[^.]+$/.exec(y&&y.keys&&y.keys.IE_PROTO||""))?"Symbol(src)_1."+l:"",v=p.toString,m=d.hasOwnProperty,b=d.toString,w=RegExp("^"+v.call(m).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_=f.Symbol,E=h.splice,I=D(f,"Map"),S=D(Object,"create"),O=_?_.prototype:void 0,A=O?O.toString:void 0;function T(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function N(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function R(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function x(t,e){for(var n,r,o=t.length;o--;)if((n=t[o][0])===(r=e)||n!=n&&r!=r)return o;return-1}function C(t){return!(!F(t)||(e=t,g&&g in e))&&(function(t){var e=F(t)?b.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?w:a).test(function(t){if(null!=t){try{return v.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function P(t,e){t=function(t,e){return 1==e.length?t:function(t,e){for(var n=0,r=(e=j(e,t)?[e]:L(e)).length;null!=t&&n<r;)t=t[M(e[n++])];return n&&n==r?t:void 0}(t,function(t,e,n){var r=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var i=Array(o);++r<o;)i[r]=t[r+e];return i}(e,0,-1))}(t,e=j(e,t)?[e]:L(e));var n,r,o=M((r=(n=e)?n.length:0)?n[r-1]:void 0);return!(null!=t&&m.call(t,o))||delete t[o]}function L(t){return q(t)?t:k(t)}function U(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function D(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return C(n)?n:void 0}function j(t,e){if(q(t))return!1;var o=typeof t;return!("number"!=o&&"symbol"!=o&&"boolean"!=o&&null!=t&&!W(t))||(r.test(t)||!n.test(t)||null!=e&&t in Object(e))}T.prototype.clear=function(){this.__data__=S?S(null):{}},T.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},T.prototype.get=function(t){var e=this.__data__;if(S){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return m.call(e,t)?e[t]:void 0},T.prototype.has=function(t){var e=this.__data__;return S?void 0!==e[t]:m.call(e,t)},T.prototype.set=function(t,e){return this.__data__[t]=S&&void 0===e?"__lodash_hash_undefined__":e,this},N.prototype.clear=function(){this.__data__=[]},N.prototype.delete=function(t){var e=this.__data__,n=x(e,t);return!(n<0)&&(n==e.length-1?e.pop():E.call(e,n,1),!0)},N.prototype.get=function(t){var e=this.__data__,n=x(e,t);return n<0?void 0:e[n][1]},N.prototype.has=function(t){return x(this.__data__,t)>-1},N.prototype.set=function(t,e){var n=this.__data__,r=x(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},R.prototype.clear=function(){this.__data__={hash:new T,map:new(I||N),string:new T}},R.prototype.delete=function(t){return U(this,t).delete(t)},R.prototype.get=function(t){return U(this,t).get(t)},R.prototype.has=function(t){return U(this,t).has(t)},R.prototype.set=function(t,e){return U(this,t).set(t,e),this};var k=B((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(W(t))return A?A.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return o.test(t)&&n.push(""),t.replace(i,(function(t,e,r,o){n.push(r?o.replace(s,"$1"):e||t)})),n}));function M(t){if("string"==typeof t||W(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function B(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(B.Cache||R),n}B.Cache=R;var q=Array.isArray;function F(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function W(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==b.call(t)}t.exports=function(t,e){return null==t||P(t,e)}}).call(this,n(7))},function(t,e,n){(function(t,n){var r="[object Arguments]",o="[object Function]",i="[object GeneratorFunction]",s="[object Map]",a="[object Set]",u=/\w*$/,c=/^\[object .+?Constructor\]$/,f=/^(?:0|[1-9]\d*)$/,l={};l[r]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object DataView]"]=l["[object Boolean]"]=l["[object Date]"]=l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l[s]=l["[object Number]"]=l["[object Object]"]=l["[object RegExp]"]=l[a]=l["[object String]"]=l["[object Symbol]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l["[object Error]"]=l[o]=l["[object WeakMap]"]=!1;var h="object"==typeof t&&t&&t.Object===Object&&t,p="object"==typeof self&&self&&self.Object===Object&&self,d=h||p||Function("return this")(),y=e&&!e.nodeType&&e,g=y&&"object"==typeof n&&n&&!n.nodeType&&n,v=g&&g.exports===y;function m(t,e){return t.set(e[0],e[1]),t}function b(t,e){return t.add(e),t}function w(t,e,n,r){var o=-1,i=t?t.length:0;for(r&&i&&(n=t[++o]);++o<i;)n=e(n,t[o],o,t);return n}function _(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function E(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function I(t,e){return function(n){return t(e(n))}}function S(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}var O,A=Array.prototype,T=Function.prototype,N=Object.prototype,R=d["__core-js_shared__"],x=(O=/[^.]+$/.exec(R&&R.keys&&R.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"",C=T.toString,P=N.hasOwnProperty,L=N.toString,U=RegExp("^"+C.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),D=v?d.Buffer:void 0,j=d.Symbol,k=d.Uint8Array,M=I(Object.getPrototypeOf,Object),B=Object.create,q=N.propertyIsEnumerable,F=A.splice,W=Object.getOwnPropertySymbols,$=D?D.isBuffer:void 0,V=I(Object.keys,Object),H=gt(d,"DataView"),G=gt(d,"Map"),J=gt(d,"Promise"),K=gt(d,"Set"),Y=gt(d,"WeakMap"),z=gt(Object,"create"),Q=_t(H),Z=_t(G),X=_t(J),tt=_t(K),et=_t(Y),nt=j?j.prototype:void 0,rt=nt?nt.valueOf:void 0;function ot(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function it(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function st(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function at(t){this.__data__=new it(t)}function ut(t,e){var n=It(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&St(t)}(t)&&P.call(t,"callee")&&(!q.call(t,"callee")||L.call(t)==r)}(t)?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],o=n.length,i=!!o;for(var s in t)!e&&!P.call(t,s)||i&&("length"==s||bt(s,o))||n.push(s);return n}function ct(t,e,n){var r=t[e];P.call(t,e)&&Et(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function ft(t,e){for(var n=t.length;n--;)if(Et(t[n][0],e))return n;return-1}function lt(t,e,n,c,f,h,p){var d;if(c&&(d=h?c(t,f,h,p):c(t)),void 0!==d)return d;if(!Tt(t))return t;var y=It(t);if(y){if(d=function(t){var e=t.length,n=t.constructor(e);e&&"string"==typeof t[0]&&P.call(t,"index")&&(n.index=t.index,n.input=t.input);return n}(t),!e)return function(t,e){var n=-1,r=t.length;e||(e=Array(r));for(;++n<r;)e[n]=t[n];return e}(t,d)}else{var g=mt(t),v=g==o||g==i;if(Ot(t))return function(t,e){if(e)return t.slice();var n=new t.constructor(t.length);return t.copy(n),n}(t,e);if("[object Object]"==g||g==r||v&&!h){if(_(t))return h?t:{};if(d=function(t){return"function"!=typeof t.constructor||wt(t)?{}:(e=M(t),Tt(e)?B(e):{});var e}(v?{}:t),!e)return function(t,e){return dt(t,vt(t),e)}(t,function(t,e){return t&&dt(e,Nt(e),t)}(d,t))}else{if(!l[g])return h?t:{};d=function(t,e,n,r){var o=t.constructor;switch(e){case"[object ArrayBuffer]":return pt(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var n=e?pt(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t,e){var n=e?pt(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}(t,r);case s:return function(t,e,n){return w(e?n(E(t),!0):E(t),m,new t.constructor)}(t,r,n);case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,u.exec(t));return e.lastIndex=t.lastIndex,e}(t);case a:return function(t,e,n){return w(e?n(S(t),!0):S(t),b,new t.constructor)}(t,r,n);case"[object Symbol]":return i=t,rt?Object(rt.call(i)):{}}var i}(t,g,lt,e)}}p||(p=new at);var I=p.get(t);if(I)return I;if(p.set(t,d),!y)var O=n?function(t){return function(t,e,n){var r=e(t);return It(t)?r:function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}(r,n(t))}(t,Nt,vt)}(t):Nt(t);return function(t,e){for(var n=-1,r=t?t.length:0;++n<r&&!1!==e(t[n],n,t););}(O||t,(function(r,o){O&&(r=t[o=r]),ct(d,o,lt(r,e,n,c,o,t,p))})),d}function ht(t){return!(!Tt(t)||(e=t,x&&x in e))&&(At(t)||_(t)?U:c).test(_t(t));var e}function pt(t){var e=new t.constructor(t.byteLength);return new k(e).set(new k(t)),e}function dt(t,e,n,r){n||(n={});for(var o=-1,i=e.length;++o<i;){var s=e[o],a=r?r(n[s],t[s],s,n,t):void 0;ct(n,s,void 0===a?t[s]:a)}return n}function yt(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function gt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return ht(n)?n:void 0}ot.prototype.clear=function(){this.__data__=z?z(null):{}},ot.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},ot.prototype.get=function(t){var e=this.__data__;if(z){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return P.call(e,t)?e[t]:void 0},ot.prototype.has=function(t){var e=this.__data__;return z?void 0!==e[t]:P.call(e,t)},ot.prototype.set=function(t,e){return this.__data__[t]=z&&void 0===e?"__lodash_hash_undefined__":e,this},it.prototype.clear=function(){this.__data__=[]},it.prototype.delete=function(t){var e=this.__data__,n=ft(e,t);return!(n<0)&&(n==e.length-1?e.pop():F.call(e,n,1),!0)},it.prototype.get=function(t){var e=this.__data__,n=ft(e,t);return n<0?void 0:e[n][1]},it.prototype.has=function(t){return ft(this.__data__,t)>-1},it.prototype.set=function(t,e){var n=this.__data__,r=ft(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},st.prototype.clear=function(){this.__data__={hash:new ot,map:new(G||it),string:new ot}},st.prototype.delete=function(t){return yt(this,t).delete(t)},st.prototype.get=function(t){return yt(this,t).get(t)},st.prototype.has=function(t){return yt(this,t).has(t)},st.prototype.set=function(t,e){return yt(this,t).set(t,e),this},at.prototype.clear=function(){this.__data__=new it},at.prototype.delete=function(t){return this.__data__.delete(t)},at.prototype.get=function(t){return this.__data__.get(t)},at.prototype.has=function(t){return this.__data__.has(t)},at.prototype.set=function(t,e){var n=this.__data__;if(n instanceof it){var r=n.__data__;if(!G||r.length<199)return r.push([t,e]),this;n=this.__data__=new st(r)}return n.set(t,e),this};var vt=W?I(W,Object):function(){return[]},mt=function(t){return L.call(t)};function bt(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||f.test(t))&&t>-1&&t%1==0&&t<e}function wt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||N)}function _t(t){if(null!=t){try{return C.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Et(t,e){return t===e||t!=t&&e!=e}(H&&"[object DataView]"!=mt(new H(new ArrayBuffer(1)))||G&&mt(new G)!=s||J&&"[object Promise]"!=mt(J.resolve())||K&&mt(new K)!=a||Y&&"[object WeakMap]"!=mt(new Y))&&(mt=function(t){var e=L.call(t),n="[object Object]"==e?t.constructor:void 0,r=n?_t(n):void 0;if(r)switch(r){case Q:return"[object DataView]";case Z:return s;case X:return"[object Promise]";case tt:return a;case et:return"[object WeakMap]"}return e});var It=Array.isArray;function St(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}(t.length)&&!At(t)}var Ot=$||function(){return!1};function At(t){var e=Tt(t)?L.call(t):"";return e==o||e==i}function Tt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Nt(t){return St(t)?ut(t):function(t){if(!wt(t))return V(t);var e=[];for(var n in Object(t))P.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}n.exports=function(t){return lt(t,!0,!0)}}).call(this,n(7),n(32)(t))},function(t,e,n){n(15),t.exports=n(16)},function(t,e,n){var r=function(t){"use strict";var e=Object.prototype,n=e.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",a=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function c(t,e,n,o){var i=e&&e.prototype instanceof h?e:h,s=Object.create(i.prototype),a=new O(o||[]);return r(s,"_invoke",{value:_(t,n,a)}),s}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function h(){}function p(){}function d(){}var y={};u(y,i,(function(){return this}));var g=Object.getPrototypeOf,v=g&&g(g(A([])));v&&v!==e&&n.call(v,i)&&(y=v);var m=d.prototype=h.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var o;r(this,"_invoke",{value:function(r,i){function s(){return new e((function(o,s){!function r(o,i,s,a){var u=f(t[o],t,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,s,a)}),(function(t){r("throw",t,s,a)})):e.resolve(l).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,a)}))}a(u.arg)}(r,i,o,s)}))}return o=o?o.then(s,s):s()}})}function _(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return T()}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var a=E(s,n);if(a){if(a===l)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=f(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function E(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;var o=f(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,l;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function A(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return p.prototype=d,r(m,"constructor",{value:d,configurable:!0}),r(d,"constructor",{value:p,configurable:!0}),p.displayName=u(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,u(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),u(w.prototype,s,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new w(c(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},b(m),u(m,a,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=A,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return s.type="throw",s.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var a=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(a&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;S(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:A(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=r(n(38)),i=n(36),s=n(30),a=n(31),u=n(37),c=n(33),f=n(35),l=r(n(34)).default.version;o.default.registerVersion(l);try{i.registerAuth(o.default),s.registerFunctions(o.default),a.registerStorage(o.default),f.registerDatabase(o.default),u.registerRealtime(o.default),c.registerAnalytics(o.default)}catch(t){}try{window.cloudbase=o.default}catch(t){}e.default=o.default,t.exports=o.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var s,a=i(n(19)),u=n(4);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(s=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t){for(var e=0,n=u.isArray(t)?t:[t];e<n.length;e++){var r=n[e],o=r.isMatch,i=r.genAdapter,s=r.runtime;if(o())return{adapter:i(),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:a.genAdapter(),runtime:s.WEB}}},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=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)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return(i=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}).apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=n(3),c=n(4),f=n(8),l=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return o(e,t),e.prototype.get=function(t){return this.request(i(i({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(i(i({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,o=t.method,s=t.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",r),c.append("file",n),this.request(i(i({},t),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,n,r,o;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,u=t.headers,l=void 0===u?{}:u,h=t.data,p=t.responseType,d=t.withCredentials,y=t.body,g=t.onUploadProgress,v=c.formatUrl(f.getProtocol(),a,"get"===r?h:{}),m=new XMLHttpRequest;m.open(r,v),p&&(m.responseType=p),Object.keys(l).forEach((function(t){m.setRequestHeader(t,l[t])})),g&&m.upload.addEventListener("progress",g),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o})),t.header=n,t.statusCode=m.status;try{t.data="blob"===p?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===p?m.response:m.responseText}clearTimeout(i),o(t)}},e&&n.timeout&&(i=setTimeout((function(){console.warn(n.timeoutMsg),m.abort()}),n.timeout)),s=c.isFormData(h)?h:"application/x-www-form-urlencoded"===l["content-type"]?c.toQueryString(h):y||(h?JSON.stringify(h):void 0),d&&(m.withCredentials=!0),m.send(s)}))},e}(u.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},function(t,e,n){var r;t.exports=(r=n(5),n(21),n(22),r.HmacSHA256)},function(t,e,n){var r;t.exports=(r=n(5),function(t){var e=r,n=e.lib,o=n.WordArray,i=n.Hasher,s=e.algo,a=[],u=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)e(r)&&(o<8&&(a[o]=n(t.pow(r,.5))),u[o]=n(t.pow(r,1/3)),o++),r++}();var c=[],f=s.SHA256=i.extend({_doReset:function(){this._hash=new o.init(a.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],a=n[4],f=n[5],l=n[6],h=n[7],p=0;p<64;p++){if(p<16)c[p]=0|t[e+p];else{var d=c[p-15],y=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=c[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;c[p]=y+c[p-7]+v+c[p-16]}var m=r&o^r&i^o&i,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),w=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&l)+u[p]+c[p];h=l,l=f,f=a,a=s+w|0,s=i,i=o,o=r,r=w+(b+m)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+f|0,n[6]=n[6]+l|0,n[7]=n[7]+h|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,o=8*e.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=t.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=i._createHelper(f),e.HmacSHA256=i._createHmacHelper(f)}(Math),r.SHA256)},function(t,e,n){var r,o,i,s;t.exports=(r=n(5),i=(o=r).lib.Base,s=o.enc.Utf8,void(o.algo.HMAC=i.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=s.parse(e));var n=t.blockSize,r=4*n;e.sigBytes>r&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),i=this._iKey=e.clone(),a=o.words,u=i.words,c=0;c<n;c++)a[c]^=1549556828,u[c]^=909522486;o.sigBytes=i.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,n=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(n))}})))},function(t,e,n){var r,o,i;t.exports=(i=n(5),o=(r=i).lib.WordArray,r.enc.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp();for(var o=[],i=0;i<n;i+=3)for(var s=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a<n;a++)o.push(r.charAt(s>>>6*(3-a)&63));var u=r.charAt(64);if(u)for(;o.length%4;)o.push(u);return o.join("")},parse:function(t){var e=t.length,n=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var i=0;i<n.length;i++)r[n.charCodeAt(i)]=i}var s=n.charAt(64);if(s){var a=t.indexOf(s);-1!==a&&(e=a)}return function(t,e,n){for(var r=[],i=0,s=0;s<e;s++)if(s%4){var a=n[t.charCodeAt(s-1)]<<s%4*2,u=n[t.charCodeAt(s)]>>>6-s%4*2;r[i>>>2]|=(a|u)<<24-i%4*8,i++}return o.create(r,i)}(t,e,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)},function(t,e,n){var r;t.exports=(r=n(5),r.enc.Utf8)},function(t,e,n){"use strict";(function(t){var r,o=this&&this.__extends||(r=function(t,e){return(r=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)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=n(3),u=n(4),c=n(6),f=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return o(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(a.AbstractStorage);var l=function(){function e(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,o=t.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:(u.printWarn(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(e.root));case"none":return new f(e.root);default:return e.localStorage?e.localStorage:(u.printWarn(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(e.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"["+c.getSdkName()+"]["+c.ERRORS.OPERATION_FAIL+"]setStore failed",info:t}))}}else u.printWarn(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(t,e,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,n){var r;if("async"!==this.mode){try{if(void 0!==t&&(null===(r=t.env)||void 0===r?void 0:r.tcb_token))return t.env.tcb_token;if(!this.storage)return""}catch(t){return""}n=n||"localCachev1";var o=this.storage.getItem(e);return o&&o.indexOf(n)>=0?JSON.parse(o).content:""}u.printWarn(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,n){var r;return i(this,void 0,void 0,(function(){var o;return s(this,(function(i){switch(i.label){case 0:try{if(void 0!==t&&(null===(r=t.env)||void 0===r?void 0:r.tcb_token))return[2,t.env.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return n=n||"localCachev1",[4,this.storage.getItem(e)];case 1:return(o=i.sent())&&o.indexOf(n)>=0?[2,JSON.parse(o).content]:[2,""]}}))}))},e.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):u.printWarn(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},e}();e.CloudbaseCache=l}).call(this,n(9))},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=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)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__spreadArrays||function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=n(4);var a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var u=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return o(e,t),e}(a);e.IErrorEvent=u;var c=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(s.isInstanceOf(t,u))return console.error(t.error),this;var n=s.isString(t)?new a(t,e||{}):t,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,c=this.listeners[r]?i(this.listeners[r]):[];o<c.length;o++){c[o].call(this,n)}}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=c;var f=new c;e.addEventListener=function(t,e){f.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),f.fire(t,e)},e.removeEventListener=function(t,e){f.off(t,e)}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(28),e)},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=n(4),s=n(6),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function f(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]\\s*\\(.*\\)$"),f=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]"),l=s.findIndex((function(t){return u.test(t)}));if(-1!==l){var h=s.filter((function(t,e){return e>l}));h.unshift(s[l].replace(f,n+"."+r).replace(c,o)),(i=new Error).stack=(a?"@debugger":"Error")+"\n"+h.join("\n")}return i}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,a=t.customInfo,l=void 0===a?{}:a,h=t.title,p=t.messages,d=void 0===p?[]:p;return function(t,e,a){if(s.IS_DEBUG_MODE){var p=l.className||t.constructor.name,y=l.methodName||e,g=a.value,v=function(t){var e="",n=t.stack.split("\n"),r=n.findIndex((function(t){return u.test(t)}));if(-1!==r){var o=c.exec(n[r+1]||"");e=o?o[0]:""}return e}(new Error);a.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=f({err:new Error,className:p,methodName:y,sourceLink:v});try{return g.apply(this,t)}catch(t){var r=t,o=t.message,s=t.error,a=t.error_description,u={title:h||p+"."+y+" failed",content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(n?(n.code=c.code,n.msg=c.msg):(t.code=c.code,t.message=c.msg),r=n||t,u.content=d.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(u.subtitle=a,n?(n.code=s,n.msg=a):(t.code=s,t.message=a),r=n||t,u.content=d.map((function(t){return{type:"info",body:t}}))),i.printGroupLog(u),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r(this,void 0,void 0,(function(){var e,n,r,s,a,u,c,l;return o(this,(function(o){switch(o.label){case 0:e=f({err:new Error,className:p,methodName:y,sourceLink:v}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,g.apply(this,t)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,a=n.error,u=n.error_description,c={title:h||p+"."+y+" failed",content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),c.subtitle=l,l.code&&(e?(e.code=l.code,e.message=l.msg):(n.code=l.code,n.message=l.msg),r=e||n,c.content=d.map((function(t){return{type:"info",body:t}})))),a&&u&&(c.subtitle=u,e?(e.code=a,e.msg=u):(n.code=a,n.message=u),r=e||n,c.content=d.map((function(t){return{type:"info",body:t}}))),i.printGroupLog(c),r;case 4:return[2]}}))}))}}}}},function(t,e,n){"use strict";function r(t){this.message=t}n.r(e),n.d(e,"InvalidTokenError",(function(){return s})),r.prototype=new Error,r.prototype.name="InvalidCharacterError";var o="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,s=0,a="";o=e.charAt(s++);~o&&(n=i%4?64*n+o:o,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return a};function i(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(o(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return o(e)}}function s(t){this.message=t}s.prototype=new Error,s.prototype.name="InvalidTokenError",e.default=function(t,e){if("string"!=typeof t)throw new s("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(i(t.split(".")[n]))}catch(t){throw new s("Invalid token specified: "+t.message)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"registerFunctions",(function(){return d}));var r=n(0),o=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},i=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},u=r.constants.getSdkName,c=r.constants.ERRORS,f=r.constants.COMMUNITY_SITE_URL,l=r.utils.execCallback,h=r.helpers.catchErrorsDecorator,p={name:"functions",entity:{callFunction:(new(function(){function t(){}return t.prototype.callFunction=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s,f,h,p,d,y,g,v;return a(this,(function(a){switch(a.label){case 0:if(n=t.name,r=t.data,o=t.query,i=t.parse,s=t.search,!n)throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[functions.callFunction] invalid function name"}));try{f=r?JSON.stringify(r):""}catch(t){throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[functions.callFunction] invalid data"}))}h="functions.invokeFunction",p={inQuery:o,parse:i,search:s,function_name:n,request_data:f},d=this.request,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,d.send(h,p)];case 2:if((y=a.sent()).code)return[2,l(e,null,y)];if(g=y.data.response_data,i)return[2,l(e,null,{result:g,requestId:y.requestId})];try{return g=JSON.parse(y.data.response_data),[2,l(e,null,{result:g,requestId:y.requestId})]}catch(t){l(e,new Error("["+u()+"]["+c.INVALID_PARAMS+"][functions.callFunction] response data must be json"))}return[3,4];case 3:return v=a.sent(),l(e,v),[3,4];case 4:return[2]}}))}))},o([h({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"callFunction",null),t}())).callFunction}};try{cloudbase.registerComponent(p)}catch(t){}function d(t){try{t.registerComponent(p)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"registerStorage",(function(){return w}));var r,o=n(0),i=function(){return(i=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}).apply(this,arguments)},s=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},a=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},u=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},c=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}};!function(t){t.put="put",t.post="post"}(r||(r={}));var f=o.constants.getSdkName,l=o.constants.ERRORS,h=o.constants.COMMUNITY_SITE_URL,p=o.utils.isArray,d=o.utils.isString,y=o.utils.isPalinObject,g=o.utils.execCallback,v=o.helpers.catchErrorsDecorator,m=new(function(){function t(){}return t.prototype.uploadFile=function(t,e){return u(this,void 0,void 0,(function(){var n,o,s,a,u,h,p,y,v,m,b,w,_,E,I,S,O,A,T,N,R,x,C,P,L;return c(this,(function(c){switch(c.label){case 0:if(n=t.cloudPath,o=t.filePath,s=t.onUploadProgress,a=t.method,u=void 0===a?"put":a,h=t.headers,p=void 0===h?{}:h,!d(n)||!o)throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.uploadFile] invalid params"}));return y={put:r.put,post:r.post}[u.toLocaleLowerCase()]||r.put,"storage.getUploadMetadata",v=this.request,m={path:n,method:y},y===r.put&&(m.headers=p),[4,v.send("storage.getUploadMetadata",m)];case 1:return b=c.sent(),w=b.data,_=w.url,E=w.authorization,I=w.token,S=w.fileId,O=w.cosFileId,A=w.download_url,T=b.requestId,R=i(i({},N={url:_,file:o,name:n,onUploadProgress:s}),{method:r.put,headers:i(i({},p),{authorization:E,"x-cos-meta-fileid":O,"x-cos-security-token":I})}),x=i(i({},N),{method:r.post,data:{key:n,signature:E,"x-cos-meta-fileid":O,success_action_status:"201","x-cos-security-token":I}}),(L={})[r.put]={params:R,isSuccess:function(t){return t>=200&&t<300}},L[r.post]={params:x,isSuccess:function(t){return 201===t}},C=L,[4,v.upload(C[y].params)];case 2:return P=c.sent(),C[y].isSuccess(P.statusCode)?[2,g(e,null,{fileID:S,download_url:A,requestId:T})]:[2,g(e,new Error("["+f()+"]["+l.OPERATION_FAIL+"][storage]:"+P.data))]}}))}))},t.prototype.getUploadMetadata=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s;return c(this,(function(a){switch(a.label){case 0:if(n=t.cloudPath,!d(n))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getUploadMetadata] invalid cloudPath"}));r=this.request,o="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.send(o,{path:n})];case 2:return i=a.sent(),[2,g(e,null,i)];case 3:return s=a.sent(),[2,g(e,s)];case 4:return[2]}}))}))},t.prototype.deleteFile=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(!(n=t.fileList)||!p(n)||0===n.length)throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.deleteFile] fileList must not be empty"}));for(r=0,o=n;r<o.length;r++)if(!(i=o[r])||!d(i))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.deleteFile] fileID must be string"}));return"storage.batchDeleteFile",[4,this.request.send("storage.batchDeleteFile",{fileid_list:n})];case 1:return(s=u.sent()).code?[2,g(e,null,s)]:(a={fileList:s.data.delete_list,requestId:s.requestId},[2,g(e,null,a)])}}))}))},t.prototype.getTempFileURL=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(!(n=t.fileList)||!p(n)||0===n.length)throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getTempFileURL] fileList must not be empty"}));for(r=[],o=0,i=n;o<i.length;o++)if(s=i[o],y(s)){if(!Object.prototype.hasOwnProperty.call(s,"fileID")||!Object.prototype.hasOwnProperty.call(s,"maxAge"))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getTempFileURL] file info must include fileID and maxAge"}));r.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!d(s))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getTempFileURL] invalid fileList"}));r.push({fileid:s})}return"storage.batchGetDownloadUrl",[4,this.request.send("storage.batchGetDownloadUrl",{file_list:r})];case 1:return(a=u.sent()).code?[2,g(e,null,a)]:[2,g(e,null,{fileList:a.data.download_list,requestId:a.requestId})]}}))}))},t.prototype.downloadFile=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(n=t.fileID,!d(n))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getTempFileURL] fileID must be string"}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}]})];case 1:return r=u.sent(),"SUCCESS"!==(o=r.fileList[0]).code?[2,g(e,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return a=u.sent(),[2,g(e,null,a)]}}))}))},s([v({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"uploadFile",null),s([v({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"getUploadMetadata",null),s([v({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"deleteFile",null),s([v({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"getTempFileURL",null),s([v({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"downloadFile",null),t}()),b={name:"storage",entity:{uploadFile:m.uploadFile,deleteFile:m.deleteFile,getTempFileURL:m.getTempFileURL,downloadFile:m.downloadFile,getUploadMetadata:m.getUploadMetadata}};try{cloudbase.registerComponent(b)}catch(t){}function w(t){try{t.registerComponent(b)}catch(t){console.warn(t)}}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){"use strict";n.r(e),n.d(e,"registerAnalytics",(function(){return p}));var r=n(0),o=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},i=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},u=r.constants.ERRORS,c=r.constants.COMMUNITY_SITE_URL,f=r.helpers.catchErrorsDecorator,l=["mall"];var h={name:"analytics",entity:{analytics:(new(function(){function t(){}return t.prototype.analytics=function(t){return s(this,void 0,void 0,(function(){var e,n,r;return a(this,(function(o){if(!function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))return!1;var e=t.report_data,n=t.report_type;return!1!==l.includes(n)&&("Object"===Object.prototype.toString.call(e).slice(8,-1)&&(!(void 0!==e.action_time&&!Number.isInteger(e.action_time))&&"string"==typeof e.action_type))}(t))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[analytics.analytics] invalid report data"}));return"analytics.report",e=void 0===t.report_data.action_time?Math.floor(Date.now()/1e3):t.report_data.action_time,n={analytics_scene:t.report_type,analytics_data:Object.assign({},t.report_data,{action_time:e})},r={requestData:n},this.request.send("analytics.report",r),[2]}))}))},o([f({customInfo:{className:"Cloudbase",methodName:"analytics"},title:"上报调用失败",messages:["请确认以下各项:"," 1 - 调用 analytics() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+c]}),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],t.prototype,"analytics",null),t}())).analytics}};try{cloudbase.registerComponent(h)}catch(t){}function p(t){try{t.registerComponent(h)}catch(t){console.warn(t)}}},function(t){t.exports=JSON.parse('{"version":"2.5.7-beta.0"}')},function(t,e,n){"use strict";n.r(e),n.d(e,"registerDatabase",(function(){return we}));var r,o,i={};n.r(i),n.d(i,"Point",(function(){return ct})),n.d(i,"LineString",(function(){return K})),n.d(i,"Polygon",(function(){return z})),n.d(i,"MultiPoint",(function(){return Z})),n.d(i,"MultiLineString",(function(){return tt})),n.d(i,"MultiPolygon",(function(){return nt})),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a="Number",u="Object",c="Array",f="GeoPoint",l="GeoLineString",h="GeoPolygon",p="GeoMultiPoint",d="GeoMultiLineString",y="GeoMultiPolygon",g="Date",v="ServerDate",m="BsonDate",b=["desc","asc"],w=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(s||(s={}));var _;(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte";!function(t){t.WHERE="WHERE",t.DOC="DOC"}(_||(_={}));var E,I=(E=function(t,e){return(E=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)},function(t,e){function n(){this.constructor=t}E(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),S=[],O={},A=function(t){function e(e,n){if(n!==O)throw new TypeError("InternalSymbol cannot be constructed with new operator");return t.call(this,e)||this}return I(e,t),e.for=function(t){for(var n=0,r=S.length;n<r;n++)if(S[n].target===t)return S[n].instance;var o=new e(t,O);return S.push({target:t,instance:o}),o},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})})),T=A,N=T.for("UNSET_FIELD_NAME"),R=T.for("UPDATE_COMMAND"),x=T.for("QUERY_COMMAND"),C=T.for("LOGIC_COMMAND"),P=T.for("GEO_POINT"),L=T.for("SYMBOL_GEO_LINE_STRING"),U=T.for("SYMBOL_GEO_POLYGON"),D=T.for("SYMBOL_GEO_MULTI_POINT"),j=T.for("SYMBOL_GEO_MULTI_LINE_STRING"),k=T.for("SYMBOL_GEO_MULTI_POLYGON"),M=T.for("SERVER_DATE"),B=T.for("REGEXP"),q=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},F=function(t){return"object"===q(t)},W=function(t){return"number"===q(t)},$=function(t){return Array.isArray(t)},V=function(t){return"date"===q(t)},H=function(t){return"regexp"===q(t)},G=function(t){return t&&t._internalType instanceof A},J=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.")},K=function(){function t(t){if(!$(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 ct))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||!$(t.coordinates))return!1;try{for(var r=J(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!W(i[0])||!W(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 L},enumerable:!0,configurable:!0}),t}(),Y=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.")},z=function(){function t(t){if(!$(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 K))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]");if(!K.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||!$(t.coordinates))return!1;try{for(var i=Y(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var u=(r=void 0,Y(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!W(f[0])||!W(f[1]))return!1}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.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 k},enumerable:!0,configurable:!0}),t}(),Q=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.")},Z=function(){function t(t){if(!$(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 ct))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||!$(t.coordinates))return!1;try{for(var r=Q(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!W(i[0])||!W(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 D},enumerable:!0,configurable:!0}),t}(),X=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.")},tt=function(){function t(t){if(!$(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 K))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||!$(t.coordinates))return!1;try{for(var i=X(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var u=(r=void 0,X(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!W(f[0])||!W(f[1]))return!1}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),t}(),et=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.")},nt=function(){function t(t){var e,n;if(!$(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=et(t),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof z))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,s;if("MultiPolygon"!==t.type||!$(t.coordinates))return!1;try{for(var a=et(t.coordinates),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var f=(r=void 0,et(c)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,et(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!W(y[0])||!W(y[1]))return!1}}catch(t){i={error:t}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return U},enumerable:!0,configurable:!0}),t}(),rt=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 M},enumerable:!0,configurable:!0}),t.prototype.parse=function(){return{$date:{offset:this.offset}}},t}();function ot(t){return new rt(t)}var it,st=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},at=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 ct(i.coordinates[0],i.coordinates[1]);break;case l:o=new K(i.coordinates.map((function(t){return new ct(t[0],t[1])})));break;case h:o=new z(i.coordinates.map((function(t){return new K(t.map((function(t){var e=st(t,2),n=e[0],r=e[1];return new ct(n,r)})))})));break;case p:o=new Z(i.coordinates.map((function(t){return new ct(t[0],t[1])})));break;case d:o=new tt(i.coordinates.map((function(t){return new K(t.map((function(t){var e=st(t,2),n=e[0],r=e[1];return new ct(n,r)})))})));break;case y:o=new nt(i.coordinates.map((function(t){return new z(t.map((function(t){return new K(t.map((function(t){var e=st(t,2),n=e[0],r=e[1];return new ct(n,r)})))})))})));break;case g:o=new Date(1e3*i.$timestamp);break;case u:case c:o=t.formatField(i);break;case v: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===g)return m;if(e===u){if(t instanceof ct)return f;if(t instanceof Date)return g;if(t instanceof rt)return v;t.$timestamp?e=g:t.$date?e=v:ct.validate(t)?e=f:K.validate(t)?e=l:z.validate(t)?e=h:Z.validate(t)?e=p:tt.validate(t)?e=d:nt.validate(t)&&(e=y)}return e},t.generateDocId=function(){for(var t="ABCDEFabcdef0123456789",e="",n=0;n<24;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},t}(),ut=function(){function t(){}return t.isGeopoint=function(t,e){if(at.whichType(e)!==a)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===b.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}(),ct=function(){function t(t,e){ut.isGeopoint("longitude",t),ut.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&&$(t.coordinates)&&ut.isGeopoint("longitude",t.coordinates[0])&&ut.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return P},enumerable:!0,configurable:!0}),t}(),ft=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"}(it||(it={}));var lt=function(){function t(t,e,n){this._internalType=R,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||N}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function ht(t){return t&&t instanceof lt&&t._internalType===R}var pt;!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(pt||(pt={}));var dt=function(){function t(t,e,n){if(this._internalType=C,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||N,this.fieldName!==N)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++){(yt(i=e[r])||bt(i))&&(e[r]=i._setFieldName(this.fieldName))}}else{var i;(yt(i=e)||bt(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(pt.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(pt.OR,r,this.fieldName)},t}();function yt(t){return t&&t instanceof dt&&t._internalType===C}var gt,vt=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])})(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"}(gt||(gt={}));var mt=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 vt(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case gt.IN:case gt.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(gt.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(gt.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(gt.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(gt.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(gt.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(gt.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(gt.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(gt.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof ct))throw new TypeError('"geometry" must be of type Point. Received type '+typeof t.geometry);if(void 0!==t.maxDistance&&!W(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof t.maxDistance);if(void 0!==t.minDistance&&!W(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof t.minDistance);var n=new e(gt.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof nt||t.geometry instanceof z))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof t.geometry);var n=new e(gt.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof ct||t.geometry instanceof K||t.geometry instanceof z||t.geometry instanceof Z||t.geometry instanceof tt||t.geometry instanceof nt))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof t.geometry);var n=new e(gt.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(dt);function bt(t){return t&&t instanceof mt&&t._internalType===x}function wt(t){return bt(t)}var _t={};for(var Et in gt)_t[Et]="$"+Et;for(var Et in pt)_t[Et]="$"+Et;for(var Et in it)_t[Et]="$"+Et;function It(t){return _t[t]||"$"+t}_t[gt.NEQ]="$ne",_t[it.REMOVE]="$unset",_t[it.SHIFT]="$pop",_t[it.UNSHIFT]="$push";var St=function(){return(St=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}).apply(this,arguments)},Ot=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},At=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ot(arguments[e]));return t};function Tt(t){return function t(e,n){if(!G(e)){if(V(e))return{$date:+e};if(H(e))return{$regex:e.source,$options:e.flags};if($(e))return e.map((function(e){if(n.indexOf(e)>-1)throw new Error("Cannot convert circular structure to JSON");return t(e,At(n,[e]))}));if(F(e)){var r=St({},e);for(var o in r){if(n.indexOf(r[o])>-1)throw new Error("Cannot convert circular structure to JSON");r[o]=t(r[o],At(n,[r[o]]))}return r}return e}switch(e._internalType){case P:return e.toJSON();case M:case B:return e.parse();default:return e.toJSON?e.toJSON():e}}(t,[t])}var Nt=function(){return(Nt=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}).apply(this,arguments)},Rt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},xt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Rt(arguments[e]));return t};function Ct(t,e,n,r){var o=Nt({},t);for(var i in t)if(!/^\$/.test(i)){var s=t[i];if(s&&F(s)&&!e(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Ct(s,e,xt(n,[i]),xt(r,[s]));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o[i+"."+c]=a[c],delete o[i][c]);u||delete o[i]}}return o}function Pt(t){return Ct(t,Ut,[],[t])}function Lt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?$(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 "+q(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+q(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]}function Ut(t){return G(t)||V(t)||H(t)}function Dt(t){return Tt(t)}var jt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return ht(t)?this.encodeUpdateCommand(t):"object"===q(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===N)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case it.PUSH:case it.PULL:case it.PULL_ALL:case it.POP:case it.SHIFT:case it.UNSHIFT:case it.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=It(t.operator);switch(t.operator){case it.REMOVE:return(e={})[i]=((n={})[t.fieldName]="",n),e;default:return(r={})[i]=((o={})[t.fieldName]=t.operands[0],o),r}},t.prototype.encodeArrayUpdateCommand=function(t){var e,n,r,o,i,s,a,u,c,f,l=It(t.operator);switch(t.operator){case it.PUSH:var h=void 0;return h=$(t.operands)?{$each:t.operands.map(Dt)}:t.operands,(e={})[l]=((n={})[t.fieldName]=h,n),e;case it.UNSHIFT:h={$each:t.operands.map(Dt),$position:0};return(r={})[l]=((o={})[t.fieldName]=h,o),r;case it.POP:return(i={})[l]=((s={})[t.fieldName]=1,s),i;case it.SHIFT:return(a={})[l]=((u={})[t.fieldName]=-1,u),a;default:return(c={})[l]=((f={})[t.fieldName]=Dt(t.operands),f),c}},t.prototype.encodeUpdateObject=function(t){var e=Pt(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(ht(r)){e[n]=r._setFieldName(n),Lt(e,this.encodeUpdateCommand(e[n]),n)}else{e[n]=r=Dt(r);var o=new lt(it.SET,[r],n);Lt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),kt={};function Mt(t){if(!ve.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return kt[e]||(kt[e]=new ve.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new ve.reqClass(t.config)}}})),kt[e]}var Bt=function(){return(Bt=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}).apply(this,arguments)},qt=function(){function t(t,e,n,r){var o=this;void 0===r&&(r={}),this.watch=function(t){return Mt(o._db).watch(Bt(Bt({},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 ve.reqClass(this._db.config),this.projection=r}return t.prototype.create=function(t,e){e=e||ft();var n={collectionName:this._coll,data:Tt(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||ft(),!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 lt?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:_.DOC,data:Tt(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||ft(),!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:_.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||ft();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:_.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||ft();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:_.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=at.formatResDocumentData(e.data.list);t(0,{data:n,requestId:e.requestId,total:e.TotalCount,limit:e.Limit,offset:e.Offset})}})).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}(),Ft=function(){function t(){}return t.encode=function(t){return(new Wt).encodeQuery(t)},t}(),Wt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return Ut(t)?yt(t)?this.encodeLogicCommand(t):bt(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,s,a,u=this;switch(t.operator){case pt.NOR:case pt.AND:case pt.OR:var c=It(t.operator),f=t.operands.map((function(e){return u.encodeQuery(e,t.fieldName)}));return(e={})[c]=f,e;case pt.NOT:c=It(t.operator);var l=t.operands[0];if(H(l))return(n={})[t.fieldName]=((r={})[c]=this.encodeRegExp(l),r),n;f=this.encodeQuery(l)[t.fieldName];return(o={})[t.fieldName]=((i={})[c]=f,i),o;default:c=It(t.operator);if(1===t.operands.length){var h=this.encodeQuery(t.operands[0]);return(s={})[c]=h,s}f=t.operands.map(this.encodeQuery.bind(this));return(a={})[c]=f,a}},t.prototype.encodeQueryCommand=function(t){return wt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,s,a,u,c;if(t.fieldName===N)throw new Error("Cannot encode a comparison command with unset field name");var f=It(t.operator);switch(t.operator){case gt.EQ:case gt.NEQ:case gt.LT:case gt.LTE:case gt.GT:case gt.GTE:case gt.ELEM_MATCH:case gt.EXISTS:case gt.SIZE:case gt.MOD:return(e={})[t.fieldName]=((n={})[f]=Dt(t.operands[0]),n),e;case gt.IN:case gt.NIN:case gt.ALL:return(r={})[t.fieldName]=((o={})[f]=Dt(t.operands),o),r;case gt.GEO_NEAR:var l=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case gt.GEO_WITHIN:l=t.operands[0];return(s={})[t.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case gt.GEO_INTERSECTS:l=t.operands[0];return(a={})[t.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(u={})[t.fieldName]=((c={})[f]=Dt(t.operands[0]),c),u}},t.prototype.encodeQueryObject=function(t){var e=Pt(t);for(var n in e){var r=e[n];if(yt(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else if(wt(r)){e[n]=r._setFieldName(n);o=this.encodeComparisonCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else Ut(r)&&(e[n]=Dt(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?$(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 "+q(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+q(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),$t=function(){return($t=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}).apply(this,arguments)},Vt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return Mt(i._db).watch($t($t({},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 ve.reqClass(this._db.config)}return t.prototype.get=function(t){t=t||ft();var e=[];this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)}));var n={collectionName:this._coll,queryType:_.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:at.formatResDocumentData(e.data.list),requestId:e.requestId};e.TotalCount&&(n.total=e.TotalCount),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||ft();var e={collectionName:this._coll,queryType:_.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,Ft.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){ut.isFieldPath(e),ut.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){ut.isInteger("limit",e);var n=$t({},this._queryOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){ut.isInteger("offset",e);var n=$t({},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||ft(),!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:_.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=$t({},this._queryOptions);return r.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.remove=function(t){t=t||ft(),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:Ft.encode(this._fieldFilters),queryType:_.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}(),Ht=n(2),Gt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},Jt=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},Kt=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=new ve.reqClass(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return Gt(this,void 0,void 0,(function(){var t;return Jt(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(Ht.a.parse)}]:[2,t]}}))}))},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=Ft.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new ct(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",Ft.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}(),Yt=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])})(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)}}(),zt=function(t){function e(e,n){return t.call(this,e,n)||this}return Yt(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 qt(this._db,this._coll,t)},e.prototype.add=function(t,e){return new qt(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new Kt(this._db,this._coll)},e}(Vt),Qt={eq:function(t){return new mt(gt.EQ,[t])},neq:function(t){return new mt(gt.NEQ,[t])},lt:function(t){return new mt(gt.LT,[t])},lte:function(t){return new mt(gt.LTE,[t])},gt:function(t){return new mt(gt.GT,[t])},gte:function(t){return new mt(gt.GTE,[t])},in:function(t){return new mt(gt.IN,t)},nin:function(t){return new mt(gt.NIN,t)},all:function(t){return new mt(gt.ALL,t)},elemMatch:function(t){return new mt(gt.ELEM_MATCH,[t])},exists:function(t){return new mt(gt.EXISTS,[t])},size:function(t){return new mt(gt.SIZE,[t])},mod:function(t){return new mt(gt.MOD,[t])},geoNear:function(t){return new mt(gt.GEO_NEAR,[t])},geoWithin:function(t){return new mt(gt.GEO_WITHIN,[t])},geoIntersects:function(t){return new mt(gt.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new dt(pt.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new dt(pt.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new dt(pt.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new dt(pt.NOT,n)},set:function(t){return new lt(it.SET,[t])},remove:function(){return new lt(it.REMOVE,[])},inc:function(t){return new lt(it.INC,[t])},mul:function(t){return new lt(it.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=$(e[0])?e[0]:Array.from(e);return new lt(it.PUSH,t)},pull:function(t){return new lt(it.PULL,t)},pullAll:function(t){return new lt(it.PULL_ALL,t)},pop:function(){return new lt(it.POP,[])},shift:function(){return new lt(it.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new lt(it.UNSHIFT,n)},addToSet:function(t){return new lt(it.ADD_TO_SET,t)},rename:function(t){return new lt(it.RENAME,[t])},bit:function(t){return new lt(it.BIT,[t])},max:function(t){return new lt(it.MAX,[t])},min:function(t){return new lt(it.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===q(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new Kt},abs:function(t){return new Zt("abs",t)},add:function(t){return new Zt("add",t)},ceil:function(t){return new Zt("ceil",t)},divide:function(t){return new Zt("divide",t)},exp:function(t){return new Zt("exp",t)},floor:function(t){return new Zt("floor",t)},ln:function(t){return new Zt("ln",t)},log:function(t){return new Zt("log",t)},log10:function(t){return new Zt("log10",t)},mod:function(t){return new Zt("mod",t)},multiply:function(t){return new Zt("multiply",t)},pow:function(t){return new Zt("pow",t)},sqrt:function(t){return new Zt("sqrt",t)},subtract:function(t){return new Zt("subtract",t)},trunc:function(t){return new Zt("trunc",t)},arrayElemAt:function(t){return new Zt("arrayElemAt",t)},arrayToObject:function(t){return new Zt("arrayToObject",t)},concatArrays:function(t){return new Zt("concatArrays",t)},filter:function(t){return new Zt("filter",t)},in:function(t){return new Zt("in",t)},indexOfArray:function(t){return new Zt("indexOfArray",t)},isArray:function(t){return new Zt("isArray",t)},map:function(t){return new Zt("map",t)},range:function(t){return new Zt("range",t)},reduce:function(t){return new Zt("reduce",t)},reverseArray:function(t){return new Zt("reverseArray",t)},size:function(t){return new Zt("size",t)},slice:function(t){return new Zt("slice",t)},zip:function(t){return new Zt("zip",t)},and:function(t){return new Zt("and",t)},not:function(t){return new Zt("not",t)},or:function(t){return new Zt("or",t)},cmp:function(t){return new Zt("cmp",t)},eq:function(t){return new Zt("eq",t)},gt:function(t){return new Zt("gt",t)},gte:function(t){return new Zt("gte",t)},lt:function(t){return new Zt("lt",t)},lte:function(t){return new Zt("lte",t)},neq:function(t){return new Zt("ne",t)},cond:function(t){return new Zt("cond",t)},ifNull:function(t){return new Zt("ifNull",t)},switch:function(t){return new Zt("switch",t)},dateFromParts:function(t){return new Zt("dateFromParts",t)},dateFromString:function(t){return new Zt("dateFromString",t)},dayOfMonth:function(t){return new Zt("dayOfMonth",t)},dayOfWeek:function(t){return new Zt("dayOfWeek",t)},dayOfYear:function(t){return new Zt("dayOfYear",t)},isoDayOfWeek:function(t){return new Zt("isoDayOfWeek",t)},isoWeek:function(t){return new Zt("isoWeek",t)},isoWeekYear:function(t){return new Zt("isoWeekYear",t)},millisecond:function(t){return new Zt("millisecond",t)},minute:function(t){return new Zt("minute",t)},month:function(t){return new Zt("month",t)},second:function(t){return new Zt("second",t)},hour:function(t){return new Zt("hour",t)},week:function(t){return new Zt("week",t)},year:function(t){return new Zt("year",t)},literal:function(t){return new Zt("literal",t)},mergeObjects:function(t){return new Zt("mergeObjects",t)},objectToArray:function(t){return new Zt("objectToArray",t)},allElementsTrue:function(t){return new Zt("allElementsTrue",t)},anyElementTrue:function(t){return new Zt("anyElementTrue",t)},setDifference:function(t){return new Zt("setDifference",t)},setEquals:function(t){return new Zt("setEquals",t)},setIntersection:function(t){return new Zt("setIntersection",t)},setIsSubset:function(t){return new Zt("setIsSubset",t)},setUnion:function(t){return new Zt("setUnion",t)},concat:function(t){return new Zt("concat",t)},dateToString:function(t){return new Zt("dateToString",t)},indexOfBytes:function(t){return new Zt("indexOfBytes",t)},indexOfCP:function(t){return new Zt("indexOfCP",t)},split:function(t){return new Zt("split",t)},strLenBytes:function(t){return new Zt("strLenBytes",t)},strLenCP:function(t){return new Zt("strLenCP",t)},strcasecmp:function(t){return new Zt("strcasecmp",t)},substr:function(t){return new Zt("substr",t)},substrBytes:function(t){return new Zt("substrBytes",t)},substrCP:function(t){return new Zt("substrCP",t)},toLower:function(t){return new Zt("toLower",t)},toUpper:function(t){return new Zt("toUpper",t)},meta:function(t){return new Zt("meta",t)},addToSet:function(t){return new Zt("addToSet",t)},avg:function(t){return new Zt("avg",t)},first:function(t){return new Zt("first",t)},last:function(t){return new Zt("last",t)},max:function(t){return new Zt("max",t)},min:function(t){return new Zt("min",t)},push:function(t){return new Zt("push",t)},stdDevPop:function(t){return new Zt("stdDevPop",t)},stdDevSamp:function(t){return new Zt("stdDevSamp",t)},sum:function(t){return new Zt("sum",t)},let:function(t){return new Zt("let",t)}},project:{slice:function(t){return new Xt("slice",t)},elemMatch:function(t){return new Xt("elemMatch",t)}}},Zt=function(t,e){this["$"+t]=e},Xt=function(t,e){this["$"+t]=e},te=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 B},enumerable:!0,configurable:!0}),t}();function ee(t){return new te(t)}var ne={code:"INSERT_DOC_FAIL",message:"insert document failed"},re={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},oe=function(){return(oe=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}).apply(this,arguments)},ie=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},se=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},ae="database.updateDocInTransaction",ue=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 ie(this,void 0,void 0,(function(){var e,n,r,o;return se(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:Ht.a.stringify(Tt(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=Ht.a.parse(n.inserted),1==(o=Ht.a.parse(n.ok))&&1==r)return[2,oe(oe({},n),{ok:o,inserted:r})];throw new Error(ne.message)}}))}))},t.prototype.get=function(){return ie(this,void 0,void 0,(function(){var t,e;return se(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?at.formatField(Ht.a.parse(e.data)):Ht.a.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return ie(this,void 0,void 0,(function(){var e,n;return se(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Ht.a.stringify(Tt(t),{relaxed:!1}),upsert:!0},[4,this._request.send(ae,e)];case 1:if((n=r.sent()).code)throw n;return[2,oe(oe({},n),{updated:Ht.a.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},t.prototype.update=function(t){return ie(this,void 0,void 0,(function(){var e,n;return se(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Ht.a.stringify(jt.encode(t),{relaxed:!1})},[4,this._request.send(ae,e)];case 1:if((n=r.sent()).code)throw n;return[2,oe(oe({},n),{updated:Ht.a.parse(n.updated)})]}}))}))},t.prototype.delete=function(){return ie(this,void 0,void 0,(function(){var t,e;return se(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,oe(oe({},e),{deleted:Ht.a.parse(e.deleted)})]}}))}))},t}(),ce=function(t,e){this._coll=e,this._transaction=t},fe=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])})(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)}}(),le=function(t){function e(e,n){return t.call(this,e,n)||this}return fe(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 ue(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new ue(this._transaction,this._coll,e).create(t)},e}(ce),he=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},pe=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},de=function(){function t(t){this._db=t,this._request=new ve.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return he(this,void 0,void 0,(function(){var t;return pe(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 le(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return he(this,void 0,void 0,(function(){var t,e;return pe(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 he(this,void 0,void 0,(function(){var e,n;return pe(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 ye(){return he(this,void 0,void 0,(function(){var t;return pe(this,(function(e){switch(e.label){case 0:return[4,(t=new de(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function ge(t,e){return void 0===e&&(e=3),he(this,void 0,void 0,(function(){var n,r,o,i,s=this;return pe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new de(this)).init()];case 1:return a.sent(),[4,t(n)];case 2:if(r=a.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return a.sent(),[2,r];case 4:if(o=a.sent(),!1===n.inited)throw o;return i=function(t){return he(s,void 0,void 0,(function(){return pe(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:return e.sent(),[3,4];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:a.sent(),a.label=6;case 6:return o&&o.code===re.code?[4,ge.bind(this)(t,--e)]:[3,8];case 7:return[2,a.sent()];case 8:return[4,i(o)];case 9:return a.sent(),[3,10];case 10:return[2]}}))}))}var ve=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=ot,this.command=Qt,this.RegExp=ee,this.startTransaction=ye,this.runTransaction=ge,this.logicCommand=dt,this.updateCommand=lt,this.queryCommand=mt}return t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new zt(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return new t.reqClass(this.config).send("database.addCollection",n)},t}(),me=function(){return(me=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}).apply(this,arguments)};var be={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,r=e.runtime;return ve.reqClass=this.request.constructor,ve.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},ve.runtime=r,this.wsClientClass&&(ve.wsClass=n.wsClass,ve.wsClientClass=this.wsClientClass),ve.ws||(ve.ws=null),new ve(me(me(me({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(be)}catch(t){}function we(t){try{t.registerComponent(be)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"LoginState",(function(){return $})),n.d(e,"Auth",(function(){return V})),n.d(e,"registerAuth",(function(){return G}));var r,o,i=n(0);function s(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}!function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(r||(r={})),function(t){t.UNREACHABLE="unreachable",t.LOCAL="local",t.CANCELLED="cancelled",t.UNKNOWN="unknown",t.INVALID_ARGUMENT="invalid_argument",t.DEADLINE_EXCEEDED="deadline_exceeded",t.NOT_FOUND="not_found",t.ALREADY_EXISTS="already_exists",t.PERMISSION_DENIED="permission_denied",t.UNAUTHENTICATED="unauthenticated",t.RESOURCE_EXHAUSTED="resource_exhausted",t.FAILED_PRECONDITION="failed_precondition",t.ABORTED="aborted",t.OUT_OF_RANGE="out_of_range",t.UNIMPLEMENTED="unimplemented",t.INTERNAL="internal",t.UNAVAILABLE="unavailable",t.DATA_LOSS="data_loss",t.CAPTCHA_REQUIRED="captcha_required",t.CAPTCHA_INVALID="captcha_invalid",t.INVALID_PASSWORD="invalid_password",t.INVALID_STATUS="invalid_status",t.USER_PENDING="user_pending",t.USER_BLOCKED="user_blocked",t.INVALID_VERIFICATION_CODE="invalid_verification_code",t.TWO_FACTOR_REQUIRED="two_factor_required",t.INVALID_TWO_FACTOR="invalid_two_factor",t.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",t.UNDER_REVIEW="under_review",t.INVALID_REQUEST="invalid_request",t.UNAUTHORIZED_CLIENT="unauthorized_client",t.ACCESS_DENIED="access_denied",t.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",t.INVALID_SCOPE="invalid_scope",t.INVALID_GRANT="invalid_grant",t.SERVER_ERROR="server_error",t.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",t.INTERACTION_REQUIRED="interaction_required",t.LOGIN_REQUIRED="login_required",t.ACCOUNT_SELECTION_REQUIRED="account_selection_required",t.CONSENT_REQUIRED="consent_required",t.INVALID_REQUEST_URI="invalid_request_uri",t.INVALID_REQUEST_OBJECT="invalid_request_object",t.REQUEST_NOT_SUPPORTED="request_not_supported",t.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",t.REGISTRATION_NOT_SUPPORTED="registration_not_supported"}(o||(o={}));var a=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},u=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},c=function(){function t(){this.fnPromiseMap=new Map}return t.prototype.run=function(t,e){return a(this,void 0,void 0,(function(){var n,r=this;return u(this,(function(o){switch(o.label){case 0:return[4,n=this.fnPromiseMap.get(t)];case 1:return o.sent()||(n=new Promise((function(n,o){a(r,void 0,void 0,(function(){var r,i,s;return u(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return a.sent(),r=e(),i=n,[4,r];case 2:return i.apply(void 0,[a.sent()]),[3,5];case 3:return s=a.sent(),o(s),[3,5];case 4:return this.fnPromiseMap.delete(t),[7];case 5:return[2]}}))}))})),this.fnPromiseMap.set(t,n)),[2,n]}}))}))},t.prototype.runIdlePromise=function(){return Promise.resolve()},t}(),f=function(){return(f=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}).apply(this,arguments)},l=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},h=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},p=function(t,e){return l(this,void 0,void 0,(function(){var n,r,i,s,a;return h(this,(function(u){switch(u.label){case 0:n=null,r=null,u.label=1;case 1:return u.trys.push([1,4,,5]),(i=Object.assign({},e)).method||(i.method="GET"),i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body)),[4,fetch(t,i)];case 2:return[4,u.sent().json()];case 3:return(null==(s=u.sent())?void 0:s.error)?(r=s).error_uri=new URL(t).pathname:n=s,[3,5];case 4:return a=u.sent(),r={error:o.UNREACHABLE,error_description:a.message,error_uri:new URL(t).pathname},[3,5];case 5:if(r)throw r;return[2,n]}}))}))};var d=new(function(){function t(){}return t.prototype.getItem=function(t){return l(this,void 0,void 0,(function(){return h(this,(function(e){return[2,window.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return l(this,void 0,void 0,(function(){return h(this,(function(e){return window.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return l(this,void 0,void 0,(function(){return h(this,(function(n){return window.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return window.localStorage.getItem(t)},t.prototype.removeItemSync=function(t){window.localStorage.removeItem(t)},t.prototype.setItemSync=function(t,e){window.localStorage.setItem(t,e)},t}());function y(t){var e=!0;return(null==t?void 0:t.expires_at)&&(null==t?void 0:t.access_token)&&(e=t.expires_at<new Date),e}var g,v,m,b=function(){function t(t){this.credentials=null,this.singlePromise=new c,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage}return t.prototype.getStorageCredentialsSync=function(){var t=null,e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t},t.prototype.setCredentials=function(t){return l(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return(null==t?void 0:t.expires_in)?(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30)),this.storage?(e=JSON.stringify(t),[4,this.storage.setItem(this.tokenSectionName,e)]):[3,2]):[3,3];case 1:n.sent(),n.label=2;case 2:return this.credentials=t,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:n.sent(),n.label=5;case 5:this.credentials=null,n.label=6;case 6:return[2]}}))}))},t.prototype.getCredentials=function(){return l(this,void 0,void 0,(function(){var t=this;return h(this,(function(e){return[2,this.singlePromise.run("getCredentials",(function(){return l(t,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return y(this.credentials)?(t=this,[4,this.getStorageCredentials()]):[3,2];case 1:t.credentials=e.sent(),e.label=2;case 2:return[2,this.credentials]}}))}))}))]}))}))},t.prototype.getStorageCredentials=function(){return l(this,void 0,void 0,(function(){var t=this;return h(this,(function(e){return[2,this.singlePromise.run("_getStorageCredentials",(function(){return l(t,void 0,void 0,(function(){var t,e;return h(this,(function(n){switch(n.label){case 0:return t=null,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),t=null,[3,5];case 5:return[2,t]}}))}))}))]}))}))},t}(),w=function(){function t(e){this.singlePromise=new c,this.apiOrigin=e.apiOrigin,this.clientId=e.clientId,this.retry=this.formatRetry(e.retry,t.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=p,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||d,this.localCredentials=new b({tokenSectionName:"credentials_"+e.clientId,storage:this.storage}),this.clientSecret=e.clientSecret,this.refreshTokenFunc=e.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=e.anonymousSignInFunc}return t.prototype.setCredentials=function(t){return this.localCredentials.setCredentials(t)},t.prototype.getAccessToken=function(){return l(this,void 0,void 0,(function(){var t,e;return h(this,(function(n){switch(n.label){case 0:return[4,this.getCredentials()];case 1:return(null==(t=n.sent())?void 0:t.access_token)?[2,Promise.resolve(t.access_token)]:(e={error:o.UNAUTHENTICATED},[2,Promise.reject(e)])}}))}))},t.prototype.request=function(e,n){return l(this,void 0,void 0,(function(){var r,i,a,u,c,l,p;return h(this,(function(h){switch(h.label){case 0:return n||(n={}),r=this.formatRetry(n.retry,this.retry),n.headers=n.headers||{},this.headers&&(n.headers=f(f({},this.headers),n.headers)),n.headers["x-request-id"]||(n.headers["x-request-id"]=s()),n.headers["x-device-id"]?[3,2]:[4,this.getDeviceId()];case 1:i=h.sent(),n.headers["x-device-id"]=i,h.label=2;case 2:return(null==n?void 0:n.withCredentials)?[4,this.getCredentials()]:[3,4];case 3:return(a=h.sent())&&(this.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token="+a.access_token):n.headers.Authorization=a.token_type+" "+a.access_token),[3,5];case 4:this.clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id="+this.clientId),h.label=5;case 5:e.startsWith("/")&&(e=this.apiOrigin+e),u=null,c=r+1,l=0,h.label=6;case 6:if(!(l<c))return[3,15];h.label=7;case 7:return h.trys.push([7,9,,12]),[4,this.baseRequest(e,n)];case 8:return u=h.sent(),[3,15];case 9:return p=h.sent(),n.withCredentials&&p&&p.error===o.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,11];case 10:return h.sent(),[2,Promise.reject(p)];case 11:return l!==r&&p&&"unreachable"===p.error?[3,12]:[2,Promise.reject(p)];case 12:return[4,this.sleep(t.retryInterval)];case 13:h.sent(),h.label=14;case 14:return l++,[3,6];case 15:return[2,u]}}))}))},t.prototype.getCredentials=function(){return l(this,void 0,void 0,(function(){var t,e,n;return h(this,(function(r){switch(r.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return y(t=r.sent())?t&&"anonymous"===t.scope?this.anonymousSignInFunc?[4,this.anonymousSignInFunc(t)]:[3,5]:[3,8]:[3,10];case 2:return e=r.sent(),(n=e)?[3,4]:[4,this.localCredentials.getCredentials()];case 3:n=r.sent(),r.label=4;case 4:return t=n,[3,7];case 5:return[4,this.anonymousSignIn(t)];case 6:t=r.sent(),r.label=7;case 7:return[3,10];case 8:return[4,this.refreshToken(t)];case 9:t=r.sent(),r.label=10;case 10:return[2,t]}}))}))},t.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},t.prototype.getCredentialsAsync=function(){return this.localCredentials.getCredentials()},t.prototype.getScope=function(){return l(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=e.sent())?[2,t.scope]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},t.prototype.getGroups=function(){return l(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=e.sent())?[2,t.groups]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},t.prototype.checkRetry=function(e){var n=null;if(("number"!=typeof e||e<t.minRetry||e>t.maxRetry)&&(n={error:o.UNREACHABLE,error_description:"wrong options param: retry"}),n)throw n;return e},t.prototype.formatRetry=function(t,e){return void 0===t?e:this.checkRetry(t)},t.prototype.sleep=function(t){return l(this,void 0,void 0,(function(){return h(this,(function(e){return[2,new Promise((function(e){setTimeout((function(){e()}),t)}))]}))}))},t.prototype.refreshToken=function(t){return l(this,void 0,void 0,(function(){var e=this;return h(this,(function(n){return[2,this.singlePromise.run("_refreshToken",(function(){return l(e,void 0,void 0,(function(){var e,n;return h(this,(function(r){switch(r.label){case 0:if(!t||!t.refresh_token)return[2,this.unAuthenticatedError("no refresh token found in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.refreshTokenFunc(t.refresh_token)];case 2:return e=r.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return r.sent(),[2,e];case 4:return(n=r.sent()).error!==o.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},t.prototype.anonymousSignIn=function(t){return l(this,void 0,void 0,(function(){var e=this;return h(this,(function(n){return[2,this.singlePromise.run("_anonymous",(function(){return l(e,void 0,void 0,(function(){var e,n;return h(this,(function(r){switch(r.label){case 0:if(!t||"anonymous"!==t.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.request("/auth/v1/signin/anonymously",{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret}})];case 2:return e=r.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return r.sent(),[2,e];case 4:return(n=r.sent()).error!==o.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},t.prototype.defaultRefreshTokenFunc=function(t){return void 0===t||""===t?this.unAuthenticatedError("refresh token not found"):this.request("/auth/v1/token",{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}})},t.prototype.getDeviceId=function(){return l(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem("device_id")];case 1:return"string"==typeof(t=e.sent())&&t.length>=16&&t.length<=48?[3,3]:(t=s(),[4,this.storage.setItem("device_id",t)]);case 2:e.sent(),e.label=3;case 3:return this.deviceID=t,[2,t]}}))}))},t.prototype.unAuthenticatedError=function(t){var e={error:o.UNAUTHENTICATED,error_description:t};return Promise.reject(e)},t.defaultRetry=2,t.minRetry=0,t.maxRetry=5,t.retryInterval=1e3,t}();!function(t){t.AUTH_SIGN_IN_URL="/auth/v1/signin",t.AUTH_SIGN_IN_ANONYMOUSLY_URL="/auth/v1/signin/anonymously",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v1/signin/with/provider",t.AUTH_SIGN_UP_URL="/auth/v1/signup",t.AUTH_TOKEN_URL="/auth/v1/token",t.AUTH_REVOKE_URL="/auth/v1/revoke",t.PROVIDER_BIND_URL="/auth/v1/user/provider/bind",t.PROVIDER_TOKEN_URL="/auth/v1/provider/token",t.PROVIDER_URI_URL="/auth/v1/provider/uri",t.USER_ME_URL="/auth/v1/user/me",t.USER_QUERY_URL="/auth/v1/user/query",t.USER_PRIFILE_URL="/auth/v1/user/profile",t.USER_TRANS_BY_PROVIDER_URL="/auth/v1/user/trans/by/provider",t.VERIFICATION_URL="/auth/v1/verification",t.VERIFY_URL="/auth/v1/verification/verify",t.PROVIDER_LIST="/auth/v1/user/provider",t.PROVIDER_UNBIND_URL="/auth/v1/user/provider",t.CHECK_PWD_URL="/auth/v1/user/sudo",t.SUDO_URL="/auth/v1/user/sudo",t.BIND_CONTACT_URL="/auth/v1/user/contact",t.AUTH_SET_PASSWORD="/auth/v1/user/password",t.AUTH_RESET_PASSWORD="/auth/v1/reset",t.AUTH_GET_DEVICE_CODE="/auth/v1/device/code",t.CHECK_USERNAME="/auth/v1/checkUsername",t.CHECK_IF_USER_EXIST="/auth/v1/checkIfUserExist"}(g||(g={})),function(t){t.REGISTER="REGISTER",t.SIGN_IN="SIGN_IN",t.PASSWORD_RESET="PASSWORD_RESET",t.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",t.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(v||(v={})),function(t){t.INVALID_ARGUMENT="invalid_argument",t.DEADLINE_EXCEEDED="deadline_exceeded",t.NOT_FOUND="not_found",t.ALREADY_EXISTS="already_exists",t.PERMISSION_DENIED="permission_denied",t.ABORTED="aborted",t.OUT_OF_RANGE="out_of_range",t.UNIMPLEMENTED="unimplemented",t.INTERNAL="internal",t.UNAVAILABLE="unavailable",t.DATA_LOSS="data_loss",t.CAPTCHA_REQUIRED="captcha_required",t.CAPTCHA_INVALID="captcha_invalid",t.INVALID_PASSWORD="invalid_password",t.PASSWORD_NOT_SET="password_not_set",t.INVALID_STATUS="invalid_status",t.USER_PENDING="user_pending",t.USER_BLOCKED="user_blocked"}(m||(m={}));var _=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},E=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},I=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=d),this.config=t,this.tokenSectionName="captcha_"+t.clientId}return t.prototype.request=function(t,e){return _(this,void 0,void 0,(function(){var n,r,o,i;return E(this,(function(s){switch(s.label){case 0:return e||(e={}),e.method||(e.method="GET"),n=e.method+":"+t,r=t,e.withCaptcha?[4,this.appendCaptchaTokenToURL(t,n,!1)]:[3,2];case 1:r=s.sent(),s.label=2;case 2:return s.trys.push([2,4,,7]),[4,this.config.request(r,e)];case 3:return o=s.sent(),[3,7];case 4:return"captcha_required"!==(i=s.sent()).error&&"captcha_invalid"!==i.error?[3,6]:[4,this.appendCaptchaTokenToURL(t,n,"captcha_invalid"===i.error)];case 5:return t=s.sent(),[2,this.config.request(t,e)];case 6:return[2,Promise.reject(i)];case 7:return[2,o]}}))}))},t.prototype.getDefaultOpenURIWithCallback=function(){if(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap")){var t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((function(){document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback},t.prototype.defaultOpenURIWithCallback=function(t){return _(this,void 0,void 0,(function(){var e,n;return E(this,(function(r){return e=document.getElementById("captcha_panel_wrap"),n=document.createElement("iframe"),e.innerHTML="",n.setAttribute("src",t),n.setAttribute("id","review-panel-iframe"),n.style.cssText="min-width:355px;display:block;height:355px;margin:0 auto;background-color: rgb(255, 255, 255);border: none;",e.appendChild(n),e.style.display="block",[2,new Promise((function(t,r){n.onload=function(){try{var o=window.location,i=n.contentWindow.location;if(i.host+i.pathname===o.host+o.pathname){e.style.display="none";var s=new URLSearchParams(i.search),a=s.get("captcha_token");return a?t({captcha_token:a,expires_in:Number(s.get("expires_in"))}):r({error:s.get("error"),error_description:s.get("error_description")})}e.style.display="block"}catch(t){e.style.display="block"}}}))]}))}))},t.prototype.getCaptchaToken=function(t,e){return _(this,void 0,void 0,(function(){var n,r,o,i,s;return E(this,(function(a){switch(a.label){case 0:return t?[3,2]:[4,this.findCaptchaToken()];case 1:if(n=a.sent())return[2,n];a.label=2;case 2:return r=window.location.origin+window.location.pathname+"?__captcha=on",[4,this.config.request("/auth/v1/captcha/init",{method:"POST",body:{client_id:this.config.clientId,redirect_uri:r,state:e},withCredentials:!1})];case 3:return(o=a.sent()).captcha_token?(i={captcha_token:o.captcha_token,expires_in:o.expires_in},this.saveCaptchaToken(i),[2,o.captcha_token]):[4,this.config.openURIWithCallback(o.url)];case 4:return s=a.sent(),this.saveCaptchaToken(s),[2,s.captcha_token]}}))}))},t.prototype.appendCaptchaTokenToURL=function(t,e,n){return _(this,void 0,void 0,(function(){var r;return E(this,(function(o){switch(o.label){case 0:return[4,this.getCaptchaToken(n,e)];case 1:return r=o.sent(),t.indexOf("?")>0?t+="&captcha_token="+r:t+="?captcha_token="+r,[2,t]}}))}))},t.prototype.saveCaptchaToken=function(t){return _(this,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:return t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10)),e=JSON.stringify(t),[4,this.config.storage.setItem(this.tokenSectionName,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.findCaptchaToken=function(){return _(this,void 0,void 0,(function(){var t,e;return E(this,(function(n){switch(n.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(t=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?[2,null]:[2,e.captcha_token];case 3:return n.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),[2,null];case 5:return[2,null]}}))}))},t}(),S=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},O=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},A=function(){function t(t){var e=t.request,n=t.credentialsClient;if(!n){var r={apiOrigin:t.apiOrigin,clientId:t.clientId,storage:t.storage};n=new w(r)}if(!e){var o=n.request.bind(n),i=new I({clientId:t.clientId,request:o,storage:t.storage});e=i.request.bind(i)}this.config={apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:n,storage:t.storage||d}}return t.parseParamsToSearch=function(t){return Object.keys(t).forEach((function(e){t[e]||delete t[e]})),new URLSearchParams(t).toString()},t.prototype.signIn=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.request(g.AUTH_SIGN_IN_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.request(g.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signUp=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.request(g.AUTH_SIGN_UP_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signOut=function(){return S(this,void 0,void 0,(function(){var t,e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.credentialsClient.getAccessToken()];case 1:return t=n.sent(),[4,this.config.request(g.AUTH_REVOKE_URL,{method:"POST",body:{token:t}})];case 2:return e=n.sent(),[4,this.config.credentialsClient.setCredentials()];case 3:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.getVerification=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return e=!1,"CUR_USER"!==t.target?[3,1]:(e=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:n.sent()&&(e=!0),n.label=3;case 3:return[2,this.config.request(g.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:!0,withCredentials:e})]}}))}))},t.prototype.verify=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.VERIFY_URL,{method:"POST",body:t})]}))}))},t.prototype.genProviderRedirectUri=function(t){return S(this,void 0,void 0,(function(){var e,n;return O(this,(function(r){return e=g.PROVIDER_URI_URL+"?client_id="+this.config.clientId+"&provider_id="+t.provider_id+"&redirect_uri="+encodeURIComponent(t.provider_redirect_uri)+"&state="+t.state,(n=t.other_params)&&"string"==typeof n.sign_out_uri&&n.sign_out_uri.length>0&&(e+="&other_params[sign_out_uri]="+n.sign_out_uri),[2,this.config.request(e,{method:"GET"})]}))}))},t.prototype.grantProviderToken=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.patchProviderToken=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]}))}))},t.prototype.signInWithProvider=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.request(g.AUTH_SIGN_IN_WITH_PROVIDER_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.bindWithProvider=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.getUserProfile=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.getUserInfo()]}))}))},t.prototype.getUserInfo=function(){return S(this,void 0,void 0,(function(){var t;return O(this,(function(e){switch(e.label){case 0:return[4,this.config.request(g.USER_ME_URL,{method:"GET",withCredentials:!0})];case 1:return(t=e.sent()).sub&&(t.uid=t.sub),[2,t]}}))}))},t.prototype.deleteMe=function(e){return S(this,void 0,void 0,(function(){var n;return O(this,(function(r){return n=g.USER_ME_URL+"?"+t.parseParamsToSearch(e),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.hasLoginState=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},t.prototype.getLoginState=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.config.credentialsClient.getCredentialsAsync()]}))}))},t.prototype.transByProvider=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.grantToken=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.AUTH_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.getProviders=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.config.request(g.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},t.prototype.unbindProvider=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_UNBIND_URL+"/"+t.provider_id,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.checkPassword=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.CHECK_PWD_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.bindPhone=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.BIND_CONTACT_URL,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.bindEmail=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.BIND_CONTACT_URL,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.setPassword=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.AUTH_SET_PASSWORD,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.updatePasswordByOld=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.sudo({password:t.old_password})];case 1:return e=n.sent(),[2,this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})]}}))}))},t.prototype.sudo=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.SUDO_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.getCurUserVerification=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return t.target="CUR_USER",[2,this.config.request(g.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]}))}))},t.prototype.changeBindedProvider=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_LIST+"/"+t.provider_id+"/trans",{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})]}))}))},t.prototype.setUserProfile=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.queryUserProfile=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){return e=new URLSearchParams(t),[2,this.config.request(g.USER_QUERY_URL+"?"+e.toString(),{method:"GET",withCredentials:!0})]}))}))},t.prototype.setCustomSignFunc=function(t){this.getCustomSignTicketFn=t},t.prototype.signInWithCustomTicket=function(){return S(this,void 0,void 0,(function(){var t;return O(this,(function(e){switch(e.label){case 0:return[4,this.getCustomSignTicketFn()];case 1:return t=e.sent(),[2,this.signInWithProvider({provider_id:"custom",provider_token:t})]}}))}))},t.prototype.resetPassword=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.AUTH_RESET_PASSWORD,{method:"POST",body:t})]}))}))},t.prototype.deviceAuthorize=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.checkUsername=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]}))}))},t.prototype.checkIfUserExist=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){return e=new URLSearchParams(t),[2,this.config.request(g.CHECK_IF_USER_EXIST+"?"+e.toString(),{method:"GET"})]}))}))},t.prototype.loginScope=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.config.credentialsClient.getScope()]}))}))},t.prototype.loginGroups=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.config.credentialsClient.getGroups()]}))}))},t}(),T=(n(10),function(){return(T=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}).apply(this,arguments)}),N=function(t){var e=t.apiOrigin,n=t.clientId,r=t.storage,o=t.request,i=t.anonymousSignInFunc;this.oauth2client=new w({apiOrigin:e,clientId:n,storage:r,baseRequest:o,anonymousSignInFunc:i}),this.authApi=new A(T(T({credentialsClient:this.oauth2client},t),{request:o?this.oauth2client.request.bind(this.oauth2client):void 0}))},R=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}).apply(this,arguments)},x=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},C=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},P=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},L=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},U=i.utils.printWarn,D=i.utils.throwError,j=i.constants.ERRORS,k=i.constants.COMMUNITY_SITE_URL,M=i.helpers.catchErrorsDecorator,B=i.events.CloudbaseEventEmitter,q="loginStateChanged",F=new B,W=function(){function t(t){var e=t.cache,n=t.oauthInstance;this.cache=e,this.oauthInstance=n,this.setUserInfo()}return t.prototype.checkLocalInfo=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return P(this,void 0,void 0,(function(){var t,e,n,r;return L(this,(function(o){switch(o.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=o.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),n=this,[4,this.getLocalUserInfoAsync("email")];case 3:return n.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),r=this,[4,this.getLocalUserInfoAsync("username")];case 4:return r.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}}))}))},t.prototype.update=function(t){return P(this,void 0,void 0,(function(){var e;return L(this,(function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(R({},t))];case 1:return e=n.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&D(j.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(){return P(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo()];case 1:return t=e.sent(),this.setLocalUserInfo(t),[2,t]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;return this.cache.getStore(e)[t]},t.prototype.getLocalUserInfoAsync=function(t){return P(this,void 0,void 0,(function(){var e;return L(this,(function(n){switch(n.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,n.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,n=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username"].forEach((function(e){t[e]=n[e]}))},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},x([M({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"update",null),x([M({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[String,String]),C("design:returntype",void 0)],t.prototype,"updatePassword",null),x([M({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",void 0)],t.prototype,"updateUsername",null),x([M({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"refresh",null),t}(),$=function(){function t(t){var e=t.envId,n=t.cache,r=t.oauthInstance;e||D(j.INVALID_PARAMS,"envId is not defined"),this.cache=n,this.oauthInstance=r,this.user=new W({cache:this.cache,oauthInstance:r})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}}))}))},t}(),V=function(){function t(t){this.config=t,this.cache=t.cache,this.oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.bindPhone(t)]}))}))},t.prototype.unbindProvider=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},t.prototype.bindEmail=function(t){return this.oauthInstance.authApi.bindEmail(t)},t.prototype.verify=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.getVerification(t)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}U(j.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return P(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return[4,this.getLoginState()];case 1:return(t=e.sent())?[4,t.user.checkLocalInfoAsync()]:[3,3];case 2:return e.sent(),[2,t.user||null];case 3:return[2,null]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signIn=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signUp=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signUp(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setPassword=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&D(j.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,e.sent().exist]}}))}))},t.prototype.signOut=function(){return P(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut()];case 1:return e.sent(),[4,this.cache.removeStoreAsync(t)];case 2:return e.sent(),F.fire(q),[2]}}))}))},t.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new $({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;U(j.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.getLoginState()];case 1:return t.sent()?[2,new $({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.getUserInfo()]}))}))},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}}))}))},t.prototype.grantProviderToken=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.patchProviderToken=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.grantToken=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return P(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return P(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return P(this,void 0,void 0,(function(){var e,n=this;return L(this,(function(r){switch(r.label){case 0:return F.on(q,(function(){return P(n,void 0,void 0,(function(){var e;return L(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=r.sent(),t.call(this,e),[2]}}))}))},t.prototype.createLoginState=function(){return P(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return[4,(t=new $({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return e.sent(),[4,t.user.refresh()];case 2:return e.sent(),F.fire(q),[2,t]}}))}))},x([M({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),x([M({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"unbindProvider",null),x([M({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",void 0)],t.prototype,"bindEmail",null),x([M({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"verify",null),x([M({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"getVerification",null),x([M({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"getCurrentUser",null),x([M({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"signInAnonymously",null),x([M({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),x([M({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"signUp",null),x([M({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),x([M({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"signOut",null),x([M({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"getLoginState",null),x([M({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"getUserInfo",null),x([M({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"bindWithProvider",null),t}(),H={name:"auth",namespace:"auth",entity:function(t){if(void 0===t&&(t={region:"",persistence:"local"}),this.authInstance)return U(j.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var e=this.platform,n=e.adapter,r=e.runtime,o=t.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=this.config,s=i.env,a=i.persistence,u=i.debug,c=i.clientId,f=i.storage,l=new N({clientId:c,apiOrigin:this.request.getBaseEndPoint(),storage:(null==t?void 0:t.storage)||f,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc});return this.oauthInstance=l,this.authInstance=new V({env:s,region:t.region,persistence:a,debug:u,cache:this.cache,runtime:r,_fromApp:this,oauthInstance:l}),this.authInstance}};try{cloudbase.registerComponent(H)}catch(t){}function G(t){try{t.registerComponent(H)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"registerRealtime",(function(){return q}));var r=n(11),o=n.n(r),i=n(12),s=n.n(i),a=n(13),u=n.n(a);function c(t){return void 0===t&&(t=""),(t?t+"_":"")+ +new Date+"_"+Math.random()}var f,l,h=function(t){this.close=t.close,this.onChange=t.onChange,this.onError=t.onError,t.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return t.virtualClient}})},p=function(t){var e,n,r=t.id,o=t.docChanges,i=t.docs,s=t.msgType,a=t.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return e||(e=JSON.parse(JSON.stringify(o))),e},enumerable:!0},docs:{get:function(){return n||(n=JSON.parse(JSON.stringify(i))),n},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})},d=(f=function(t,e){return(f=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)},function(t,e){function n(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),y=function(t){function e(e){var n=t.call(this,"Watch Error "+JSON.stringify(e.msgData)+" (requestid: "+e.requestId+")")||this;return n.isRealtimeErrorMessageError=!0,n.payload=e,n}return d(e,t),e}(Error),g=function(t){return null==t?void 0:t.isRealtimeErrorMessageError},v=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="timeout",e.payload=null,e.generic=!0,e}return d(e,t),e}(Error),m=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="cancelled",e.payload=null,e.generic=!0,e}return d(e,t),e}(Error),b=function(t){function e(e){var n=t.call(this,e.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: "+this.errCode+" "+(w[this.errCode]||"")+" | errMsg: "+this.errMsg},set:function(t){this.errMsg=t}}}),n.errCode=e.errCode||"UNKNOWN_ERROR",n.errMsg=e.errMsg,n}return d(e,t),Object.defineProperty(e.prototype,"message",{get:function(){return"errCode: "+this.errCode+" | errMsg: "+this.errMsg},set:function(t){this.errMsg=t},enumerable:!1,configurable:!0}),e}(Error),w={UNKNOWN_ERROR:"UNKNOWN_ERROR",SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG:"SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG",SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA:"SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED",SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL",SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR:"SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR"},_=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},E=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},I=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},S=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};!function(t){t.LOGGINGIN="LOGGINGIN",t.INITING="INITING",t.REBUILDING="REBUILDING",t.ACTIVE="ACTIVE",t.ERRORED="ERRORED",t.CLOSING="CLOSING",t.CLOSED="CLOSED",t.PAUSED="PAUSED",t.RESUMING="RESUMING"}(l||(l={}));var O=function(){function t(t){var e=this;this.watchStatus=l.INITING,this.wsLogin=function(t,n){return E(e,void 0,void 0,(function(){var e;return I(this,(function(r){switch(r.label){case 0:return this.watchStatus=l.LOGGINGIN,[4,this.login(t,n)];case 1:return e=r.sent(),this.envId||(this.envId=e.envId),[2,e]}}))}))},this.initWatch=function(t){return E(e,void 0,void 0,(function(){var e,n=this;return I(this,(function(r){switch(r.label){case 0:if(null!==this.initWatchPromise&&void 0!==this.initWatchPromise)return[2,this.initWatchPromise];this.initWatchPromise=new Promise((function(e,r){E(n,void 0,void 0,(function(){var n,o,i,s,a,u,f,h,d,y;return I(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):[4,this.wsLogin(this.envId,t)];case 1:return n=g.sent().envId,this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):(this.watchStatus=l.INITING,o={watchId:this.watchId,requestId:c(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(i=g.sent(),s=i.msgData,a=s.events,u=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:u-1,currentDocs:[]},a.length>0){for(f=0,h=a;f<h.length;f++)h[f].ID=u;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=u,d=new p({id:u,docChanges:[],docs:[],type:"init"}),this.listener.onChange(d),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=l.ACTIVE,this.availableRetries.INIT_WATCH=2,e(),[3,4];case 3:return y=g.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:e,reject:r}),[3,4];case 4:return[2]}}))}))})),e=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return r.sent(),e=!0,[3,4];case 3:return this.initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch "+(e?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(t){return E(e,void 0,void 0,(function(){var e,n=this;return I(this,(function(r){switch(r.label){case 0:if(null!==this.rebuildWatchPromise&&void 0!==this.rebuildWatchPromise)return[2,this.rebuildWatchPromise];this.rebuildWatchPromise=new Promise((function(e,r){E(n,void 0,void 0,(function(){var n,o,i,s;return I(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):[4,this.wsLogin(this.envId,t)];case 1:if(n=a.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):(this.watchStatus=l.REBUILDING,o={watchId:this.watchId,requestId:c(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return i=a.sent(),this.handleServerEvents(i),this.watchStatus=l.ACTIVE,this.availableRetries.REBUILD_WATCH=2,e(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:e,reject:r}),[3,4];case 4:return[2]}}))}))})),e=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return r.sent(),e=!0,[3,4];case 3:return this.rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch "+(e?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(t,n){return E(e,void 0,void 0,(function(){var e,r,o,i=this;return I(this,(function(s){return e="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new b({errCode:e?w.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:w.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:t})),n.reject(t)},o=function(t){i.useRetryTicket(n.operationName)?e?(i.initWatchPromise=void 0,n.resolve(i.initWatch(t))):(i.rebuildWatchPromise=void 0,n.resolve(i.rebuildWatch(t))):r()},this.handleCommonError(t,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){E(i,void 0,void 0,(function(){var t,e=this;return I(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),t=function(){return E(e,void 0,void 0,(function(){return I(this,(function(t){switch(t.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return t.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,t()];case 1:return r.sent(),[3,7];case 2:return[4,_(100)];case 3:return r.sent(),this.watchStatus!==l.PAUSED?[3,4]:(n.reject(new m(n.operationName+" cancelled due to pause after unknownError")),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,t()];case 5:return r.sent(),[3,7];case 6:o(!1),r.label=7;case 7:return[3,9];case 8:return r.sent(),o(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return E(e,void 0,void 0,(function(){var t,e,n;return I(this,(function(r){switch(r.label){case 0:if(t=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==l.ACTIVE)return this.watchStatus=l.CLOSED,this.onWatchClose(this,t),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=l.CLOSING,e={watchId:this.watchId,requestId:c(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:e})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=l.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,t),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){e.clearACKSchedule(),e.ackTimeoutId=setTimeout((function(){e.waitExpectedTimeoutId?e.scheduleSendACK():e.sendACK()}),1e4)},this.clearACKSchedule=function(){e.ackTimeoutId&&clearTimeout(e.ackTimeoutId)},this.sendACK=function(){return E(e,void 0,void 0,(function(){var t,e,n;return I(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==l.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(t={watchId:this.watchId,requestId:c(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:t})]):(console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"),[2]);case 1:return r.sent(),this.scheduleSendACK(),[3,3];case 2:if(e=r.sent(),g(e))switch((n=e.payload).msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return this.rebuildWatch(),[2];case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":return this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:n.msgData.code})),[2]}return this.availableRetries.CHECK_LAST&&this.availableRetries.CHECK_LAST>0?(this.availableRetries.CHECK_LAST-=1,this.scheduleSendACK()):this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:e})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(t,e){if(g(t)){switch(t.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void e.onSignError(t);case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":default:return void e.onNotRetryableError(t)}}else{if(function(t){return"timeout"===t.type}(t))return void e.onTimeoutError(t);if(function(t){return"cancelled"===t.type}(t))return void e.onCancelledError(t)}e.onUnknownError(t)},this.watchId="watchid_"+ +new Date+"_"+Math.random(),this.envId=t.envId,this.collectionName=t.collectionName,this.query=t.query,this.limit=t.limit,this.orderBy=t.orderBy,this.send=t.send,this.login=t.login,this.isWSConnected=t.isWSConnected,this.onceWSConnected=t.onceWSConnected,this.getWaitExpectedTimeoutLength=t.getWaitExpectedTimeoutLength,this.onWatchStart=t.onWatchStart,this.onWatchClose=t.onWatchClose,this.debug=t.debug,this.availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new h({close:function(){e.closeWatch()},onChange:t.onChange,onError:t.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return t.prototype.onMessage=function(t){var e=this;switch(this.watchStatus){case l.PAUSED:if("ERROR"!==t.msgType)return;break;case l.LOGGINGIN:case l.INITING:case l.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while "+this.watchStatus);case l.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case l.ERRORED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has ended with error")}if(this.sessionInfo)switch(this.scheduleSendACK(),t.msgType){case"NEXT_EVENT":console.warn("nextevent "+t.msgData.currEvent+" ignored",t),this.handleServerEvents(t);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<t.msgData.currEvent&&(this.sessionInfo.expectEventId=t.msgData.currEvent,this.clearWaitExpectedEvent(),this.waitExpectedTimeoutId=setTimeout((function(){e.rebuildWatch()}),this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength "+this.getWaitExpectedTimeoutLength()));break;case"ERROR":this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:t.msgData.code+" - "+t.msgData.message}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg "+t.msgType+": ",t)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},t.prototype.closeWithError=function(t){var e;this.watchStatus=l.ERRORED,this.clearACKSchedule(),this.listener.onError(t),this.onWatchClose(this,(null===(e=this.sessionInfo)||void 0===e?void 0:e.queryID)||""),console.log("[realtime] client closed ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},t.prototype.pause=function(){this.watchStatus=l.PAUSED,console.log("[realtime] client paused ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},t.prototype.resume=function(){return E(this,void 0,void 0,(function(){var t;return I(this,(function(e){switch(e.label){case 0:this.watchStatus=l.RESUMING,console.log("[realtime] client resuming with "+(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH")+" ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return e.sent(),console.log("[realtime] client successfully resumed ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),[3,4];case 3:return t=e.sent(),console.error("[realtime] client resume failed ("+this.collectionName+" "+this.query+") ("+this.watchId+")",t),[3,4];case 4:return[2]}}))}))},t.prototype.useRetryTicket=function(t){return!!(this.availableRetries[t]&&this.availableRetries[t]>0)&&(this.availableRetries[t]-=1,console.log("[realtime] "+t+" use a retry ticket, now only "+this.availableRetries[t]+" retry left"),!0)},t.prototype.handleServerEvents=function(t){return E(this,void 0,void 0,(function(){var e;return I(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(t)];case 1:return n.sent(),this.postHandleServerEventsValidityCheck(t),[3,3];case 2:throw e=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",e),e;case 3:return[2]}}))}))},t.prototype.handleServerEventsInternel=function(t){return E(this,void 0,void 0,(function(){var e,n,r,i,a,c,f,l,h,d,y,g;return I(this,(function(v){switch(v.label){case 0:if(e=t.requestId,n=t.msgData.events,r=t.msgType,!n.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=n.map(A)}catch(t){return this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:t})),[2]}c=S(i.currentDocs),f=!1,l=function(n,l){var d,y,g,v,m,_,E,O,A,T,N,R;return I(this,(function(I){switch(I.label){case 0:return d=a[n],i.currentEventId>=d.id?(!a[n-1]||d.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur "+i.currentEventId+" but got "+d.id):console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId "+e+")"),[2,"continue"]):[3,1];case 1:if(i.currentEventId!==d.id-1)return[3,2];switch(d.dataType){case"update":if(!d.doc)switch(d.queueType){case"update":case"dequeue":if(y=c.find((function(t){return t._id===d.docId}))){if(g=u()(y),d.updatedFields&&Object.keys(d.updatedFields).forEach((function(t){o()(g,t,d.updatedFields[t])})),d.removedFields)for(v=0,m=d.removedFields;v<m.length;v++)_=m[v],s()(g,_);d.doc=g}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw O=new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '+t.requestId+")"}),h.closeWithError(O),O}break;case"replace":if(!d.doc)throw O=new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '+t.requestId+")"}),h.closeWithError(O),O;break;case"remove":(E=c.find((function(t){return t._id===d.docId})))?d.doc=E:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!d.doc)switch(d.queueType){case"dequeue":(E=c.find((function(t){return t._id===d.docId})))?d.doc=E:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw O=new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '+t.requestId+")"}),h.closeWithError(O),O}}switch(d.queueType){case"init":f?c.push(d.doc):(f=!0,c=[d.doc]);break;case"enqueue":c.push(d.doc);break;case"dequeue":(A=c.findIndex((function(t){return t._id===d.docId})))>-1?c.splice(A,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":(A=c.findIndex((function(t){return t._id===d.docId})))>-1?c[A]=d.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===l-1||a[n+1]&&a[n+1].id!==d.id)&&(T=S(c),N=a.slice(0,n+1).filter((function(t){return t.id===d.id})),h.sessionInfo.currentEventId=d.id,h.sessionInfo.currentDocs=c,R=new p({id:d.id,docChanges:N,docs:T,msgType:r}),h.listener.onChange(R)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur "+h.sessionInfo.currentEventId+" but got "+d.id),[4,h.rebuildWatch()];case 3:return I.sent(),[2,{value:void 0}];case 4:return[2]}}))},h=this,d=0,y=a.length,v.label=1;case 1:return d<y?[5,l(d,y)]:[3,4];case 2:if("object"==typeof(g=v.sent()))return[2,g.value];v.label=3;case 3:return d++,[3,1];case 4:return[2]}}))}))},t.prototype.postHandleServerEventsValidityCheck=function(t){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<t.msgData.currEvent&&console.warn("[realtime listener] internal non-fatal error: client eventId does not match with server event id after server event handling")):console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur")},t.prototype.clearWaitExpectedEvent=function(){this.waitExpectedTimeoutId&&(clearTimeout(this.waitExpectedTimeoutId),this.waitExpectedTimeoutId=void 0)},t}();function A(t){var e={id:t.ID,dataType:t.DataType,queueType:t.QueueType,docId:t.DocID,doc:t.Doc&&"{}"!==t.Doc?JSON.parse(t.Doc):void 0};return"update"===t.DataType&&(t.UpdatedFields&&(e.updatedFields=JSON.parse(t.UpdatedFields)),(t.removedFields||t.RemovedFields)&&(e.removedFields=JSON.parse(t.removedFields))),e}var T,N={1e3:{code:1e3,name:"Normal Closure",description:"Normal closure; the connection successfully completed whatever purpose for which it was created."},1001:{code:1001,name:"Going Away",description:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{code:1002,name:"Protocol Error",description:"The endpoint is terminating the connection due to a protocol error."},1003:{code:1003,name:"Unsupported Data",description:"The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)."},1005:{code:1005,name:"No Status Received",description:"Indicates that no status code was provided even though one was expected."},1006:{code:1006,name:"Abnormal Closure",description:"Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{code:1007,name:"Invalid frame payload data",description:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{code:1008,name:"Policy Violation",description:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{code:1009,name:"Message too big",description:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{code:1010,name:"Missing Extension",description:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{code:1011,name:"Internal Error",description:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{code:1012,name:"Service Restart",description:"The server is terminating the connection because it is restarting."},1013:{code:1013,name:"Try Again Later",description:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{code:1014,name:"Bad Gateway",description:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{code:1015,name:"TLS Handshake",description:"Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},3e3:{code:3e3,name:"Reconnect WebSocket",description:"The client is terminating the connection because it wants to reconnect"},3001:{code:3001,name:"No Realtime Listeners",description:"The client is terminating the connection because no more realtime listeners exist"},3002:{code:3002,name:"Heartbeat Ping Error",description:"The client is terminating the connection due to its failure in sending heartbeat messages"},3003:{code:3003,name:"Heartbeat Pong Timeout Error",description:"The client is terminating the connection because no heartbeat response is received from the server"},3050:{code:3050,name:"Server Close",description:"The client is terminating the connection because no heartbeat response is received from the server"}};!function(t){t[t.NormalClosure=1e3]="NormalClosure",t[t.GoingAway=1001]="GoingAway",t[t.ProtocolError=1002]="ProtocolError",t[t.UnsupportedData=1003]="UnsupportedData",t[t.NoStatusReceived=1005]="NoStatusReceived",t[t.AbnormalClosure=1006]="AbnormalClosure",t[t.InvalidFramePayloadData=1007]="InvalidFramePayloadData",t[t.PolicyViolation=1008]="PolicyViolation",t[t.MessageTooBig=1009]="MessageTooBig",t[t.MissingExtension=1010]="MissingExtension",t[t.InternalError=1011]="InternalError",t[t.ServiceRestart=1012]="ServiceRestart",t[t.TryAgainLater=1013]="TryAgainLater",t[t.BadGateway=1014]="BadGateway",t[t.TLSHandshake=1015]="TLSHandshake",t[t.ReconnectWebSocket=3e3]="ReconnectWebSocket",t[t.NoRealtimeListeners=3001]="NoRealtimeListeners",t[t.HeartbeatPingError=3002]="HeartbeatPingError",t[t.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",t[t.NoAuthentication=3050]="NoAuthentication"}(T||(T={}));var R=function(t,e){var n=N[t],r=n?n.name+", code "+t+", reason "+(e||n.description):"code "+t;return new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},x=null,C="web";function P(){return C}var L=function(){return(L=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}).apply(this,arguments)},U=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},D=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},j=1,k=function(){function t(t){var e=this;this.virtualWSClient=new Set,this.queryIdClientMap=new Map,this.watchIdClientMap=new Map,this.pingFailed=0,this.pongMissed=0,this.logins=new Map,this.wsReadySubsribers=[],this.wsResponseWait=new Map,this.rttObserved=[],this.send=function(t){return U(e,void 0,void 0,(function(){var e=this;return D(this,(function(n){return[2,new Promise((function(n,r){U(e,void 0,void 0,(function(){var e,o,i,s,a,u,c,f,l=this;return D(this,(function(h){switch(h.label){case 0:o=!1,i=!1,s=function(t){o=!0,e&&clearTimeout(e),n(t)},a=function(t){i=!0,e&&clearTimeout(e),r(t)},t.timeout&&(e=setTimeout((function(){U(l,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return o&&i?[3,2]:[4,_(0)];case 1:t.sent(),o&&i||a(new v("wsclient.send timedout")),t.label=2;case 2:return[2]}}))}))}),t.timeout)),h.label=1;case 1:return h.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:h.sent(),h.label=3;case 3:if(!this.ws)return a(new Error("invalid state: ws connection not exists, can not send message")),[2];if(this.ws.readyState!==j)return a(new Error("ws readyState invalid: "+this.ws.readyState+", can not send message")),[2];t.waitResponse&&(u={resolve:s,reject:a,skipOnMessage:t.skipOnMessage},this.wsResponseWait.set(t.msg.requestId,u)),h.label=4;case 4:return h.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(t.msg))];case 5:return h.sent(),t.waitResponse||s(void 0),[3,7];case 6:return(c=h.sent())&&(a(c),t.waitResponse&&this.wsResponseWait.delete(t.msg.requestId)),[3,7];case 7:return[3,9];case 8:return f=h.sent(),a(f),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(t){e.virtualWSClient.forEach((function(e){e.closeWithError(t)}))},this.pauseClients=function(t){(t||e.virtualWSClient).forEach((function(t){t.pause()}))},this.resumeClients=function(t){(t||e.virtualWSClient).forEach((function(t){t.resume()}))},this.initWebSocketConnection=function(t,n){return void 0===n&&(n=e.maxReconnect),U(e,void 0,void 0,(function(){var e=this;return D(this,(function(r){switch(r.label){case 0:if(t&&this.reconnectState)return[2];if(t&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];t&&this.pauseClients(),this.close(T.ReconnectWebSocket),this.wsInitPromise=new Promise((function(r,o){U(e,void 0,void 0,(function(){var e,i,s=this;return D(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return e=a.sent(),[4,new Promise((function(t){var n=e.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=x;s.ws=r?new r(n):new WebSocket(n),t(void 0)}))];case 2:return a.sent(),this.ws.connect?[4,this.ws.connect()]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return a.sent(),r(),t&&(this.resumeClients(),this.reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),n>0?(this.wsInitPromise=void 0,[4,_(this.reconnectInterval)]):[3,9];case 7:a.sent(),t&&(this.reconnectState=!1),a.label=8;case 8:return r(this.initWebSocketConnection(t,n-1)),[3,10];case 9:o(i),t&&this.closeAllClients(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:i})),a.label=10;case 10:return[3,11];case 11:return[2]}}))}))})),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this.wsInitPromise];case 2:return r.sent(),this.wsReadySubsribers.forEach((function(t){return(0,t.resolve)()})),[3,5];case 3:return r.sent(),this.wsReadySubsribers.forEach((function(t){return(0,t.reject)()})),[3,5];case 4:return this.wsInitPromise=void 0,this.wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(t,n){if(!e.ws)throw new Error("can not initWebSocketEvent, ws not exists");var r=!1;e.ws.onopen=function(e){console.warn("[realtime] ws event: open",e),r=!0,t()},e.ws.onerror=function(t){e.logins=new Map,r?(console.error("[realtime] ws event: error",t),e.clearHeartbeat(),e.virtualWSClient.forEach((function(e){return e.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:t}))}))):(console.error("[realtime] ws open failed with ws event: error",t),n(t))},e.ws.onclose=function(t){switch(console.warn("[realtime] ws event: close",t),e.logins=new Map,e.clearHeartbeat(),t.code){case T.ReconnectWebSocket:case T.NoRealtimeListeners:break;case T.HeartbeatPingError:case T.HeartbeatPongTimeoutError:case T.NormalClosure:case T.AbnormalClosure:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients(R(t.code));break;case T.NoAuthentication:e.closeAllClients(R(t.code,t.reason));break;default:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients(R(t.code))}},e.ws.onmessage=function(t){var n,r=t.data;e.heartbeat();try{n=JSON.parse(r)}catch(t){throw new Error("[realtime] onMessage parse res.data error: "+t)}if("ERROR"===n.msgType){var o=null;e.virtualWSClient.forEach((function(t){t.watchId===n.watchId&&(o=t)})),o&&o.listener.onError(n)}var i=e.wsResponseWait.get(n.requestId);if(i){try{"ERROR"===n.msgType?i.reject(new y(n)):i.resolve(n)}catch(t){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",t)}finally{e.wsResponseWait.delete(n.requestId)}if(i.skipOnMessage)return}if("PONG"!==n.msgType){var s=n.watchId&&e.watchIdClientMap.get(n.watchId);if(s)s.onMessage(n);else switch(console.error("[realtime] no realtime listener found responsible for watchId "+n.watchId+": ",n),n.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(s=e.queryIdClientMap.get(n.msgData.queryID))&&s.onMessage(n);break;default:for(var a=0,u=Array.from(e.watchIdClientMap.entries());a<u.length;a++){u[a][1].onMessage(n);break}}}else if(e.lastPingSendTS){var c=Date.now()-e.lastPingSendTS;if(c>1e4)return void console.warn("[realtime] untrusted rtt observed: "+c);e.rttObserved.length>=3&&e.rttObserved.splice(0,e.rttObserved.length-3+1),e.rttObserved.push(c)}},e.heartbeat()}))},this.isWSConnected=function(){return Boolean(e.ws&&e.ws.readyState===j)},this.onceWSConnected=function(){return U(e,void 0,void 0,(function(){var t=this;return D(this,(function(e){return this.isWSConnected()?[2]:null!==this.wsInitPromise&&void 0!==this.wsInitPromise?[2,this.wsInitPromise]:[2,new Promise((function(e,n){t.wsReadySubsribers.push({resolve:e,reject:n})}))]}))}))},this.webLogin=function(t,n){return U(e,void 0,void 0,(function(){var e,r,o,i,s,a,u,f,l=this;return D(this,(function(h){switch(h.label){case 0:if(!n)if(t){if(e=this.logins.get(t)){if(e.loggedIn&&e.loginResult)return[2,e.loginResult];if(null!==e.loggingInPromise&&void 0!==e.loggingInPromise)return[2,e.loggingInPromise]}}else if(null!==(null==(r=this.logins.get(""))?void 0:r.loggingInPromise)&&void 0!==(null==r?void 0:r.loggingInPromise))return[2,r.loggingInPromise];o=new Promise((function(t,e){U(l,void 0,void 0,(function(){var n,r,o,i,s;return D(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return n=a.sent(),r={envId:n.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:c(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:P(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(i=a.sent()).msgData.code?e(new Error(i.msgData.code+" "+i.msgData.message)):t({envId:n.envId}),[3,4];case 3:return s=a.sent(),e(s),[3,4];case 4:return[2]}}))}))})),i=t&&this.logins.get(t),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this.logins.set(t||"",i)),h.label=1;case 1:return h.trys.push([1,3,,4]),[4,o];case 2:if(a=h.sent(),(u=t&&this.logins.get(t))&&u===i&&u.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(u){if(u.loggedIn&&u.loginResult)return[2,u.loginResult];if(null!==u.loggingInPromise&&void 0!==u.loggingInPromise)return[2,u.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw f=h.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,f;case 4:return[2]}}))}))},this.getWsSign=function(){return U(e,void 0,void 0,(function(){var t,e,n,r,o,i,s;return D(this,(function(a){switch(a.label){case 0:return this.wsSign&&this.wsSign.expiredTs>Date.now()?[2,this.wsSign]:(t=Date.now()+6e4,[4,this.context.appConfig.request.send("auth.wsWebSign",{runtime:P()})]);case 1:if((e=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: "+e.code);if(e.data)return n=e.data,r=n.signStr,o=n.wsUrl,i=n.secretVersion,s=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:i,envId:s,expiredTs:t}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return e.rttObserved.length?e.rttObserved.reduce((function(t,e){return t+e}))/e.rttObserved.length*1.5:5e3},this.ping=function(){return U(e,void 0,void 0,(function(){var t;return D(this,(function(e){switch(e.label){case 0:return t={watchId:void 0,requestId:c(),msgType:"PING",msgData:null},[4,this.send({msg:t})];case 1:return e.sent(),[2]}}))}))},this.onWatchStart=function(t,n){e.queryIdClientMap.set(n,t)},this.onWatchClose=function(t,n){n&&e.queryIdClientMap.delete(n),e.watchIdClientMap.delete(t.watchId),e.virtualWSClient.delete(t),e.virtualWSClient.size||e.close(T.NoRealtimeListeners)},this.maxReconnect=t.maxReconnect||5,this.reconnectInterval=t.reconnectInterval||1e4,this.context=t.context}return t.prototype.clearHeartbeat=function(){this.pingTimeoutId&&clearTimeout(this.pingTimeoutId),this.pongTimeoutId&&clearTimeout(this.pongTimeoutId)},t.prototype.close=function(t){this.clearHeartbeat(),this.ws&&(this.ws.close(t,N[t].name),this.ws=void 0)},t.prototype.watch=function(t){this.ws||void 0!==this.wsInitPromise&&null!==this.wsInitPromise||this.initWebSocketConnection(!1);var e=new O(L(L({},t),{send:this.send,login:this.webLogin,isWSConnected:this.isWSConnected,onceWSConnected:this.onceWSConnected,getWaitExpectedTimeoutLength:this.getWaitExpectedTimeoutLength,onWatchStart:this.onWatchStart,onWatchClose:this.onWatchClose,debug:!0}));return this.virtualWSClient.add(e),this.watchIdClientMap.set(e.watchId,e),e.listener},t.prototype.heartbeat=function(t){var e=this;this.clearHeartbeat(),this.pingTimeoutId=setTimeout((function(){U(e,void 0,void 0,(function(){var t=this;return D(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),this.ws&&this.ws.readyState===j?(this.lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return e.sent(),this.pingFailed=0,this.pongTimeoutId=setTimeout((function(){console.error("pong timed out"),t.pongMissed<2?(t.pongMissed+=1,t.heartbeat(!0)):t.initWebSocketConnection(!0)}),this.context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return e.sent(),this.pingFailed<2?(this.pingFailed+=1,this.heartbeat()):this.close(T.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),t?0:this.context.appConfig.realtimePingInterval)},t}(),M={target:"database",entity:function(){var t,e=this.platform,n=e.adapter,r=e.runtime;t=n.wsClass,x=t,function(t){C=t}(r)}},B={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=k}};try{cloudbase.registerComponent(B),cloudbase.registerHook(M)}catch(t){}function q(t){try{t.registerComponent(B),t.registerHook(M)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"getBaseEndPoint",(function(){return O.b})),n.d(e,"cloudbase",(function(){return Q}));var r,o=n(0),i=n(3),s=(r=function(t,e){return(r=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)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),a=function(){return(a=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}).apply(this,arguments)},u=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},c=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}};var f=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return s(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(n,r){var o=t.url,s=t.data,a=t.headers,u=wx.request({url:Object(i.formatUrl)("https:",o),data:s,timeout:e._timeout,method:"POST",header:a,success:function(t){n(t)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&(e._timeout&&-1!==e._restrictedMethods.indexOf("post")&&"request:fail timeout"===t.errMsg)){console.warn(e._timeoutMsg);try{u.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,n=this;return new Promise((function(r){return u(e,void 0,void 0,(function(){var e,o,i,s,u,f;return c(this,(function(c){return e=t.url,o=t.file,i=t.data,s=t.headers,u=t.onUploadProgress,f=wx.uploadFile({url:e,filePath:o,name:"file",formData:a({},i),header:s,timeout:this._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&i.success_action_status&&(e.statusCode=parseInt(i.success_action_status,10)),r(e)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg)){console.warn(n._timeoutMsg);try{f.abort()}catch(t){}}}}),u&&f.onProgressUpdate((function(t){u(t)})),[2]}))}))}))},e.prototype.download=function(t){var e=this,n=this;return new Promise((function(r,o){var s=t.url,a=t.headers,u=wx.downloadFile({url:Object(i.formatUrl)("https:",s),header:a,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?r({statusCode:200,tempFilePath:t.tempFilePath}):r(t)},fail:function(t){o(t)},complete:function(t){if(t&&t.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg)){console.warn(n._timeoutMsg);try{u.abort()}catch(t){}}}})}))},e}(i.AbstractSDKRequest),l={setItem:function(t,e){wx.setStorageSync(t,e)},getItem:function(t){return wx.getStorageSync(t)},removeItem:function(t){wx.removeStorageSync(t)},clear:function(){wx.clearStorageSync()}},h=function(t,e){void 0===e&&(e={});var n=wx.connectSocket(a({url:t},e));return{set onopen(t){n.onOpen(t)},set onmessage(t){n.onMessage(t)},set onclose(t){n.onClose(t)},set onerror(t){n.onError(t)},send:function(t){return n.send({data:t})},close:function(t,e){return n.close({code:t,reason:e})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};var p={genAdapter:function(){return{root:{},reqClass:f,wsClass:h,localStorage:l,primaryStorage:i.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0},runtime:"wx_mp"},d=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r},y=o.constants.ERRORS,g={};function v(t,e){var n=e.name,r=e.namespace,o=e.entity,i=e.injectEvents,s=e.IIFE,a=void 0!==s&&s;if(g[n]||r&&t[r])throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"Duplicate component "+n}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:y.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(t)}if(g[n]=e,r?t.prototype[r]=o:function t(e,n){if(!(n instanceof Object))return n;switch(n.constructor){case Date:return new Date(n.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return n}for(var r=Object.keys(n),o=0,i=r;o<i.length;o++){var s=i[o];Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=t(e[s],n[s]))}return e}(t.prototype,o),i){var u=i.bus,c=i.events;if(!u||!c||0===c.length)return;var f=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[n]?t.prototype.events[n].events=d(t.prototype.events[n].events,c):t.prototype.events[n]={bus:u,events:c},t.prototype.fire=function(t,e){f(t,e);for(var n=0,r=Object.keys(this.events);n<r.length;n++){var o=r[n],i=this.events[o],s=i.bus;if(i.events.includes(t)){s.fire(t,e);break}}}}}var m={},b=function(){return(b=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}).apply(this,arguments)},w=o.cache.CloudbaseCache,_={},E={};function I(t){var e=t.env,n=t.platformInfo,r={userInfoKey:"user_info_"+e};_[e]=_[e]||new w(b(b({},t),{keys:r,platformInfo:n})),E[e]=E[e]||new w(b(b({},t),{keys:r,platformInfo:n,persistence:"local"}))}function S(t){return E[t]}var O=n(1),A=function(){return(A=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}).apply(this,arguments)},T=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},N=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},R=o.constants.ERRORS,x=o.utils.genSeqId,C=o.utils.isFormData,P=o.utils.formatUrl,L=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function U(t,e,n){var r=t[e];t[e]=function(e){var o={},i={};n.forEach((function(n){var r=n.call(t,e),s=r.data,a=r.headers;Object.assign(o,s),Object.assign(i,a)}));var s=e.data;return s&&(C(s)?Object.keys(o).forEach((function(t){s.append(t,o[t])})):e.data=A(A({},s),o)),e.headers=A(A({},e.headers||{}),i),r.call(t,e)}}function D(){var t=x();return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+Object(O.e)(),"x-seqid":t}}}var j=function(){function t(t){this.throwWhenRequestFail=!1,this.config=t;var e={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post","put"]};this.reqClass=new m.adapter.reqClass(e),this.throwWhenRequestFail=t.throw||!1,this.localCache=S(this.config.env),U(this.reqClass,"post",[D]),U(this.reqClass,"upload",[D]),U(this.reqClass,"download",[D])}return t.prototype.post=function(t){return T(this,void 0,void 0,(function(){return N(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.upload=function(t){return T(this,void 0,void 0,(function(){return N(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.upload(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return T(this,void 0,void 0,(function(){return N(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.download(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(){return Object(O.b)()},t.prototype.getOauthAccessTokenV2=function(t){return T(this,void 0,void 0,(function(){var e,n;return N(this,(function(r){switch(r.label){case 0:return[4,t.getAccessToken()];case 1:return e=r.sent(),[4,t.getCredentials()];case 2:return n=r.sent(),[2,{accessToken:e,accessTokenExpire:new Date(n.expires_at).getTime()}]}}))}))},t.prototype.request=function(t,e,n){var r;return T(this,void 0,void 0,(function(){var o,i,s,a,u,c,f,l,h,p,d,y,g,v,m,b,w,_,E,I;return N(this,(function(S){switch(S.label){case 0:if(o="x-tcb-trace_"+this.config.env,i="application/x-www-form-urlencoded",s=A({action:t,dataVersion:O.a,env:this.config.env},e),-1!==L.indexOf(t))return[3,2];if(!(a=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return u=a.oauthInstance,c=u.oauth2client,f=s,[4,this.getOauthAccessTokenV2(c)];case 1:f.access_token=S.sent().accessToken,S.label=2;case 2:return"storage.uploadFile"===t?(l=new FormData,Object.keys(l).forEach((function(t){Object.prototype.hasOwnProperty.call(l,t)&&void 0!==l[t]&&l.append(t,s[t])})),i="multipart/form-data"):(i="application/json;charset=UTF-8",l={},Object.keys(s).forEach((function(t){void 0!==s[t]&&(l[t]=s[t])}))),h={headers:{"content-type":i}},(null==n?void 0:n.onUploadProgress)&&(h.onUploadProgress=n.onUploadProgress),this.config.region&&(h.headers["X-TCB-Region"]=this.config.region),(p=this.localCache.getStore(o))&&(h.headers["X-TCB-Trace"]=p),d=e.parse,y=e.inQuery,g=e.search,v={env:this.config.env},d&&(v.parse=!0),y&&(v=A(A({},y),v)),m=Object(O.c)(),b=m.BASE_URL,w=m.PROTOCOL,_=P(w,b,v),g&&(_+=g),[4,this.post(A({url:_,data:l},h))];case 3:if(E=S.sent(),(I=null===(r=E.header)||void 0===r?void 0:r["x-tcb-trace"])&&this.localCache.setStore(o,I),200!==Number(E.status)&&200!==Number(E.statusCode)||!E.data)throw new Error("network request error");return[2,E]}}))}))},t.prototype.send=function(t,e){return void 0===e&&(e={}),T(this,void 0,void 0,(function(){var n;return N(this,(function(r){switch(r.label){case 0:return[4,this.request(t,e,{onUploadProgress:e.onUploadProgress})];case 1:if((n=r.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:R.OPERATION_FAIL,msg:"["+n.data.code+"] "+n.data.message}));return[2,n.data]}}))}))},t}(),k={};var M=function(){return(M=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}).apply(this,arguments)},B=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},q=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},F=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},W=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}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,a])}}},$=o.adapters.useAdapters,V=o.adapters.useDefaultAdapter,H=o.constants.ERRORS,G=o.constants.COMMUNITY_SITE_URL,J=o.utils.printWarn,K=o.helpers.catchErrorsDecorator,Y={timeout:15e3,persistence:"local"},z={},Q=new(function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return m},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this.cloudbaseConfig.env,_[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return S(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this.cloudbaseConfig.env,k[t];var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){if(!e.env)throw new Error(JSON.stringify({code:H.INVALID_PARAMS,msg:"env must not be specified"}));m.adapter||this.useDefaultAdapter();var n={timeout:e.timeout||5e3,timeoutMsg:"["+Object(O.d)()+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+e.timeout/1e3+"s"};this.requestClient=new m.adapter.reqClass(n),this.cloudbaseConfig=M(M({},Y),e),this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var r=this.cloudbaseConfig,o=r.env,i=r.persistence,s=r.debug,a=r.timeout,u=r.oauthClient;I({env:o,persistence:i,debug:s,platformInfo:this.platform}),Object(O.g)(o,e.region||"");var c=new t(this.cloudbaseConfig);return function(t){k[t.env]=new j(A(A({},t),{throw:!0}))}({env:o,region:e.region||"",timeout:a,oauthClient:u,_fromApp:c}),c.requestClient=this.requestClient,c},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=n,I({env:this.cloudbaseConfig.env,persistence:e,debug:n,platformInfo:this.platform})},t.prototype.registerExtension=function(t){z[t.name]=t},t.prototype.invokeExtension=function(t,e){return F(this,void 0,void 0,(function(){var n;return W(this,(function(r){switch(r.label){case 0:if(!(n=z[t]))throw new Error(JSON.stringify({code:H.INVALID_PARAMS,msg:"extension:"+t+" must be registered before invoke"}));return[4,n.invoke(e,this)];case 1:return[2,r.sent()]}}))}))},t.prototype.useAdapters=function(t){var e=$(t)||{},n=e.adapter,r=e.runtime;n&&(m.adapter=n),r&&(m.runtime=r)},t.prototype.registerHook=function(e){!function(t,e){var n=e.entity,r=e.target;if(Object.prototype.hasOwnProperty.call(t,r))throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"target:"+r+" is not exist"}));var o=t.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"target:"+r+" is not a function which is the only type supports hook"}));t.prototype[r]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.call.apply(n,d([this],t)),o.call.apply(o,d([this],t))}}(t,e)},t.prototype.registerComponent=function(e){v(t,e)},t.prototype.registerVersion=function(t){Object(O.i)(t)},t.prototype.registerSdkName=function(t){Object(O.h)(t)},t.prototype.registerEndPoint=function(t,e){Object(O.f)(t,e)},t.prototype.useDefaultAdapter=function(){var t=V(),e=t.adapter,n=t.runtime;m.adapter=e,m.runtime=n},t.prototype.formatTimeout=function(t){switch(!0){case t>6e5:return J(H.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),6e5;case t<100:return J(H.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},B([K({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+G]}),q("design:type",Function),q("design:paramtypes",[Object]),q("design:returntype",t)],t.prototype,"init",null),B([K({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+G]}),q("design:type",Function),q("design:paramtypes",[String,Object]),q("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}());Q.useAdapters(p);e.default=Q}])}));