@be-link/request 1.2.0 → 1.2.1

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Buffer as e}from"buffer";function t(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){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(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function i(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];return n.push.apply(n,arguments),new(Function.bind.apply(t,n))}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var s={},a={},c={};Object.defineProperty(c,"__esModule",{value:!0}),c.COMMUNITY_SITE_URL=c.IS_DEBUG_MODE=c.getProtocol=c.setProtocol=c.getSdkName=c.setSdkName=void 0;var u="@cloudbase/js-sdk";c.setSdkName=function(e){u=e},c.getSdkName=function(){return u};var f="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";c.setProtocol=function(e){f=e},c.getProtocol=function(){return f},c.IS_DEBUG_MODE="development"===process.env.NODE_ENV,c.COMMUNITY_SITE_URL="https://support.qq.com/products/148793";var l={};Object.defineProperty(l,"__esModule",{value:!0}),l.ERRORS=void 0,l.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(e){var t=r&&r.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=r&&r.__exportStar||function(e,n){for(var r in e)"default"===r||n.hasOwnProperty(r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(c,e),n(l,e)}(a);var h,p={},d={};!function(e){e.local="local",e.none="none",e.session="session"}(h||(h={}));var y=function(){},g=function(){};function v(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}var m,_=i(Object.freeze({__proto__:null,AbstractSDKRequest:y,AbstractStorage:g,get StorageType(){return h},formatUrl:v})),b={},w={exports:{}},E={exports:{}};function S(){return m||(m=1,E.exports=(e=e||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),r={},o=r.lib={},i=o.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=o.WordArray=i.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[r+i>>>2]|=s<<24-(r+i)%4*8}else for(i=0;i<o;i+=4)t[r+i>>>2]=n[i>>>2];return this.sigBytes+=o,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],o=function(t){var n=987654321,r=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},i=0;i<t;i+=4){var a=o(4294967296*(n||e.random()));n=987654071*a(),r.push(4294967296*a()|0)}return new s.init(r,t)}}),a=r.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},f=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},l=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,a=o/(4*i),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*i,u=e.min(4*c,o);if(c){for(var f=0;f<c;f+=i)this._doProcessBlock(r,f);var l=r.splice(0,c);n.sigBytes-=u}return new s.init(l,u)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});o.Hasher=l.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=r.algo={};return r}(Math),e)),E.exports;var e}var I,O={exports:{}};function A(){return I?O.exports:(I=1,O.exports=(e=S(),function(t){var n=e,r=n.lib,o=r.WordArray,i=r.Hasher,s=n.algo,a=[],c=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,o=0;o<64;)e(r)&&(o<8&&(a[o]=n(t.pow(r,.5))),c[o]=n(t.pow(r,1/3)),o++),r++}();var u=[],f=s.SHA256=i.extend({_doReset:function(){this._hash=new o.init(a.slice(0))},_doProcessBlock:function(e,t){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)u[p]=0|e[t+p];else{var d=u[p-15],y=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=u[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;u[p]=y+u[p-7]+v+u[p-16]}var m=r&o^r&i^o&i,_=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&l)+c[p]+u[p];h=l,l=f,f=a,a=s+b|0,s=i,i=o,o=r,r=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 e=i.clone.call(this);return e._hash=this._hash.clone(),e}});n.SHA256=i._createHelper(f),n.HmacSHA256=i._createHmacHelper(f)}(Math),e.SHA256));var e}var N,T,R,P,x,L={exports:{}};w.exports=function(e){return e.HmacSHA256}(S(),A(),N||(N=1,L.exports=(T=S(),P=(R=T).lib.Base,x=R.enc.Utf8,void(R.algo.HMAC=P.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=x.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),s=o.words,a=i.words,c=0;c<n;c++)s[c]^=1549556828,a[c]^=909522486;o.sigBytes=i.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))));var C=w.exports,k={exports:{}};k.exports=function(e){return function(){var t=e,n=t.lib.WordArray;function r(e,t,r){for(var o=[],i=0,s=0;s<t;s++)if(s%4){var a=r[e.charCodeAt(s-1)]<<s%4*2,c=r[e.charCodeAt(s)]>>>6-s%4*2;o[i>>>2]|=(a|c)<<24-i%4*8,i++}return n.create(o,i)}t.enc.Base64={stringify:function(e){var t=e.words,n=e.sigBytes,r=this._map;e.clamp();for(var o=[],i=0;i<n;i+=3)for(var s=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[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 c=r.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(e){var t=e.length,n=this._map,o=this._reverseMap;if(!o){o=this._reverseMap=[];for(var i=0;i<n.length;i++)o[n.charCodeAt(i)]=i}var s=n.charAt(64);if(s){var a=e.indexOf(s);-1!==a&&(t=a)}return r(e,t,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64}(S());var D=k.exports,j={exports:{}};j.exports=function(e){return e.enc.Utf8}(S());var U=j.exports,M=r&&r.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(b,"__esModule",{value:!0}),b.transformPhone=b.sleep=b.printGroupLog=b.throwError=b.printInfo=b.printError=b.printWarn=b.execCallback=b.createPromiseCallback=b.removeParam=b.getHash=b.getQuery=b.toQueryString=b.createSign=b.formatUrl=b.genSeqId=b.isFormData=b.isInstanceOf=b.isNull=b.isPalinObject=b.isUndefined=b.isString=b.isArray=void 0;var q=M(C),W=M(D),F=M(U),B=a;function $(e){var t=W.default.stringify(e);return t=(t=(t=t.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}b.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},b.isString=function(e){return"string"==typeof e},b.isUndefined=function(e){return void 0===e},b.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},b.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},b.isInstanceOf=function(e,t){return e instanceof t},b.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},b.genSeqId=function(){return Math.random().toString(16).slice(2)},b.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t},b.createSign=function(e,t){var n=$(F.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+$(F.default.parse(JSON.stringify(e)));return n+"."+$(q.default(n,t))},b.toQueryString=function(e){void 0===e&&(e={});var t=[];for(var n in e)t.push(n+"="+encodeURIComponent(e[n]));return t.join("&")},b.getQuery=function(e,t){if("undefined"==typeof window)return!1;var n=t||window.location.search,r=new RegExp("(^|&)"+e+"=([^&]*)(&|$)"),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},b.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]"+e+"=([^&#]*)"));return t?t[1]:""},b.removeParam=function(e,t){var n=t.split("?")[0],r=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===e&&r.splice(i,1);n=n+"?"+r.join("&")}return n},b.createPromiseCallback=function(){var e;if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e},b.execCallback=function(e,t,n){if(void 0===n&&(n=null),e&&"function"==typeof e)return e(t,n);if(t)throw t;return n},b.printWarn=function(e,t){console.warn("["+B.getSdkName()+"]["+e+"]:"+t)},b.printError=function(e,t){console.error({code:e,msg:"["+B.getSdkName()+"]["+e+"]:"+t})},b.printInfo=function(e,t){console.log("["+B.getSdkName()+"]["+e+"]:"+t)},b.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"["+B.getSdkName()+"]["+e+"]:"+t}))},b.printGroupLog=function(e){var t=e.title,n=e.subtitle,r=void 0===n?"":n,o=e.content,i=void 0===o?[]:o,s=e.printTrace,a=void 0!==s&&s,c=e.collapsed;void 0!==c&&c?console.groupCollapsed(t,r):console.group(t,r);for(var u=0,f=i;u<f.length;u++){var l=f[u],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()},b.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},b.transformPhone=function(e){return"+86"+e};var H,G=r&&r.__extends||(H=function(e,t){return H=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},H(e,t)},function(e,t){function n(){this.constructor=e}H(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),K=r&&r.__assign||function(){return K=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},K.apply(this,arguments)},V=r&&r.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},J=r&&r.__generator||function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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(d,"__esModule",{value:!0}),d.WebRequest=d.genAdapter=void 0;var Y=b,Z=c,X=function(e){function t(t){var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return G(t,e),t.prototype.get=function(e){return this._request(K(K({},e),{method:"get"}),this._restrictedMethods.includes("get"))},t.prototype.post=function(e){return this._request(K(K({},e),{method:"post"}),this._restrictedMethods.includes("post"))},t.prototype.put=function(e){return this._request(K(K({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,n=e.file,r=e.name,o=new FormData;for(var i in t)o.append(i,t[i]);return o.append("key",r),o.append("file",n),this._request(K(K({},e),{data:o,method:"post"}),this._restrictedMethods.includes("upload"))},t.prototype.download=function(e){return V(this,void 0,void 0,(function(){var t,n,r,o;return J(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(K(K({},e),{headers:{},responseType:"blob"}))];case 1:return t=i.sent().data,n=window.URL.createObjectURL(new Blob([t])),r=decodeURIComponent(new URL(e.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 i.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype._request=function(e,t){var n=this;void 0===t&&(t=!1);var r=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=e.url,c=e.headers,u=void 0===c?{}:c,f=e.data,l=e.responseType,h=e.withCredentials,p=e.body,d=e.onUploadProgress,y=Y.formatUrl(Z.getProtocol(),a,"get"===r?f:{}),g=new XMLHttpRequest;for(var v in g.open(r,y),l&&(g.responseType=l),u)g.setRequestHeader(v,u[v]);d&&g.upload.addEventListener("progress",d),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};t.forEach((function(e){var t=e.split(": "),r=t.shift().toLowerCase(),o=t.join(": ");n[r]=o})),e.header=n,e.statusCode=g.status;try{e.data="blob"===l?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===l?g.response:g.responseText}clearTimeout(i),o(e)}},t&&n._timeout&&(i=setTimeout((function(){console.warn(n._timeoutMsg),g.abort()}),n._timeout)),s=Y.isFormData(f)?f:"application/x-www-form-urlencoded"===u["content-type"]?Y.toQueryString(f):p||(f?JSON.stringify(f):void 0),h&&(g.withCredentials=!0),g.send(s)}))},t}(_.AbstractSDKRequest);d.WebRequest=X,d.genAdapter=function(){return{root:window,reqClass:X,wsClass:WebSocket,localStorage:localStorage,sessionStorage:sessionStorage}},function(e){var t=r&&r.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=r&&r.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=r&&r.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var o in e)"default"!==o&&Object.hasOwnProperty.call(e,o)&&t(r,e,o);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var i,s=o(d),a=b;!function(e){e.WEB="web",e.WX_MP="wx_mp"}(i=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(e){for(var t=0,n=a.isArray(e)?e:[e];t<n.length;t++){var r=n[t],o=r.isMatch,i=r.genAdapter,s=r.runtime;if(o())return{adapter:i(),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:s.genAdapter(),runtime:i.WEB}}}(p);var z={},Q=r&&r.__extends||function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ee=r&&r.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},te=r&&r.__generator||function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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(z,"__esModule",{value:!0}),z.CloudbaseCache=void 0;var ne=b,re=a,oe=function(e){function t(t){var n=e.call(this)||this;return n._root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return Q(t,e),t.prototype.setItem=function(e,t){this._root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this._root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this._root.tcbCacheObject[e]},t.prototype.clear=function(){delete this._root.tcbCacheObject},t}(_.AbstractStorage);function ie(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:(ne.printWarn(re.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new oe(t.root));case"none":return new oe(t.root);case"session":return t.sessionStorage?t.sessionStorage:(ne.printWarn(re.ERRORS.INVALID_PARAMS,"sessionStorage is not supported on current platform"),new oe(t.root))}}var se=function(){function e(e){this.keys={};var t=e.persistence,n=e.platformInfo,r=void 0===n?{}:n,o=e.keys,i=void 0===o?{}:o,s=e.alwaysLocalKeys,a=void 0===s?[]:s;this._platformInfo=r,this._alwaysLocalKeys=a,this._storage||(this._persistence=r.adapter.primaryStorage||t,this._storage=ie(this._persistence,r.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._persistence},enumerable:!1,configurable:!0}),e.prototype.updatePersistence=function(e){if("async"!==this.mode){if(e!==this._persistence){var t="local"===this._persistence;this._persistence=e;var n=ie(e,this._platformInfo.adapter);for(var r in this.keys){var o=this.keys[r];if(!t||!this._alwaysLocalKeys.includes(r)){var i=this._storage.getItem(o);ne.isUndefined(i)||ne.isNull(i)||(n.setItem(o,i),this._storage.removeItem(o))}}this._storage=n}}else ne.printWarn(re.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use updatePersistenceAsync insteed")},e.prototype.updatePersistenceAsync=function(e){return ee(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c;return te(this,(function(u){switch(u.label){case 0:if(e===this._persistence)return[2];for(o in t="local"===this._persistence,this._persistence=e,n=ie(e,this._platformInfo.adapter),r=[],this.keys)r.push(o);i=0,u.label=1;case 1:return i<r.length?(s=r[i],a=this.keys[s],t&&this._alwaysLocalKeys.includes(s)?[3,4]:[4,this._storage.getItem(a)]):[3,5];case 2:return c=u.sent(),ne.isUndefined(c)||ne.isNull(c)?[3,4]:(n.setItem(a,c),[4,this._storage.removeItem(a)]);case 3:u.sent(),u.label=4;case 4:return i++,[3,1];case 5:return this._storage=n,[2]}}))}))},e.prototype.setStore=function(e,t,n){if("async"!==this.mode){if(this._storage)try{var r={version:n||"localCachev1",content:t};this._storage.setItem(e,JSON.stringify(r))}catch(e){throw new Error(JSON.stringify({code:re.ERRORS.OPERATION_FAIL,msg:"["+re.getSdkName()+"]["+re.ERRORS.OPERATION_FAIL+"]setStore failed",info:e}))}}else ne.printWarn(re.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,n){return ee(this,void 0,void 0,(function(){var r;return te(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:t},[4,this._storage.setItem(e,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,t){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.tcb_token))return process.env.tcb_token;if(!this._storage)return""}catch(e){return""}t=t||"localCachev1";var r=this._storage.getItem(e);return r&&r.indexOf(t)>=0?JSON.parse(r).content:""}ne.printWarn(re.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var n;return ee(this,void 0,void 0,(function(){var r;return te(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.tcb_token))return[2,process.env.tcb_token];if(!this._storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this._storage.getItem(e)];case 1:return(r=o.sent())&&r.indexOf(t)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this._storage.removeItem(e):ne.printWarn(re.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return ee(this,void 0,void 0,(function(){return te(this,(function(t){switch(t.label){case 0:return[4,this._storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}();z.CloudbaseCache=se;var ae={},ce=r&&r.__extends||function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ue=r&&r.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};Object.defineProperty(ae,"__esModule",{value:!0}),ae.removeEventListener=ae.activateEvent=ae.addEventListener=ae.CloudbaseEventEmitter=ae.IErrorEvent=ae.CloudbaseEvent=void 0;var fe=b;var le=function(e,t){this.data=t||null,this.name=e};ae.CloudbaseEvent=le;var he=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return ce(t,e),t}(le);ae.IErrorEvent=he;var pe=function(){function e(){this._listeners={}}return e.prototype.on=function(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this},e.prototype.off=function(e,t){return function(e,t,n){if(null==n?void 0:n[e]){var r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}(e,t,this._listeners),this},e.prototype.fire=function(e,t){if(fe.isInstanceOf(e,he))return console.error(e.error),this;var n=fe.isString(e)?new le(e,t||{}):e,r=n.name;if(this._listens(r)){n.target=this;for(var o=0,i=this._listeners[r]?ue(this._listeners[r]):[];o<i.length;o++){i[o].call(this,n)}}return this},e.prototype._listens=function(e){return this._listeners[e]&&this._listeners[e].length>0},e}();ae.CloudbaseEventEmitter=pe;var de=new pe;ae.addEventListener=function(e,t){de.on(e,t)},ae.activateEvent=function(e,t){void 0===t&&(t={}),de.fire(e,t)},ae.removeEventListener=function(e,t){de.off(e,t)};var ye={},ge={},ve=r&&r.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},me=r&&r.__generator||function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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(ge,"__esModule",{value:!0}),ge.catchErrorsDecorator=void 0;var _e=b,be=a,we=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(we=-1!==navigator.userAgent.indexOf("Firefox"));var Ee=we?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,Se=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function Ie(e){var t=e.err,n=e.className,r=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),a=we?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]\\s*\\(.*\\)$"),c=we?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]"),u=s.findIndex((function(e){return a.test(e)}));if(-1!==u){var f=s.filter((function(e,t){return t>u}));f.unshift(s[u].replace(c,n+"."+r).replace(Se,o)),(i=new Error).stack=(we?"@debugger":"Error")+"\n"+f.join("\n")}return i}ge.catchErrorsDecorator=function(e){var t=e.mode,n=void 0===t?"async":t,r=e.customInfo,o=void 0===r?{}:r,i=e.title,s=e.messages,a=void 0===s?[]:s;return function(e,t,r){if(be.IS_DEBUG_MODE){var s=o.className||e.constructor.name,c=o.methodName||t,u=r.value,f=function(e){var t="",n=e.stack.split("\n"),r=n.findIndex((function(e){return Ee.test(e)}));if(-1!==r){var o=Se.exec(n[r+1]||"");t=o?o[0]:""}return t}(new Error);r.value="sync"===n?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ie({err:new Error,className:s,methodName:c,sourceLink:f});try{return u.apply(this,e)}catch(e){var r=e,o=e.message,l={title:i||s+"."+c+" failed",content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var h=JSON.parse(o);l.subtitle=o,h.code&&(n?(n.code=h.code,n.msg=h.msg):(e.code=h.code,e.message=h.msg),r=n||e,l.content=a.map((function(e){return{type:"info",body:e}})))}throw _e.printGroupLog(l),r}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ve(this,void 0,void 0,(function(){var t,n,r,o,l,h;return me(this,(function(p){switch(p.label){case 0:t=Ie({err:new Error,className:s,methodName:c,sourceLink:f}),p.label=1;case 1:return p.trys.push([1,3,,4]),[4,u.apply(this,e)];case 2:return[2,p.sent()];case 3:throw n=p.sent(),r=n,o=n.message,l={title:i||s+"."+c+" failed",content:[{type:"error",body:n}]},o&&/^\{.*\}$/.test(o)&&(h=JSON.parse(o),l.subtitle=h,h.code&&(t?(t.code=h.code,t.message=h.msg):(n.code=h.code,n.message=h.msg),r=t||n,l.content=a.map((function(e){return{type:"info",body:e}})))),_e.printGroupLog(l),r;case 4:return[2]}}))}))}}}},function(e){var t=r&&r.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=r&&r.__exportStar||function(e,n){for(var r in e)"default"===r||n.hasOwnProperty(r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(ge,e)}(ye);var Oe=r&&r.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),Ae=r&&r.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ne=r&&r.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&Oe(t,e,n);return Ae(t,e),t};Object.defineProperty(s,"__esModule",{value:!0});var Te=s.helpers=s.utils=s.events=s.cache=s.adapters=s.constants=void 0,Re=Ne(a),Pe=s.constants=Re,xe=Ne(p),Le=s.adapters=xe,Ce=Ne(z),ke=s.cache=Ce,De=Ne(ae),je=s.events=De,Ue=Ne(b),Me=s.utils=Ue,qe=Ne(ye);Te=s.helpers=qe;var We=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Fe=function(){return Fe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Fe.apply(this,arguments)},Be=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},$e=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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 He=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return We(t,e),t.prototype.post=function(e){var t=this;return new Promise((function(n,r){var o=e.url,i=e.data,s=e.headers,a=wx.request({url:v("https:",o),data:i,timeout:t._timeout,method:"POST",header:s,success:function(e){n(e)},fail:function(e){r(e)},complete:function(e){if(e&&e.errMsg&&(t._timeout&&-1!==t._restrictedMethods.indexOf("post")&&"request:fail timeout"===e.errMsg)){console.warn(t._timeoutMsg);try{a.abort()}catch(e){}}}})}))},t.prototype.upload=function(e){var t=this,n=this;return new Promise((function(r){return Be(t,void 0,void 0,(function(){var t,o,i,s,a,c;return $e(this,(function(u){return t=e.url,o=e.file,i=e.data,s=e.headers,a=e.onUploadProgress,c=wx.uploadFile({url:t,filePath:o,name:"file",formData:Fe({},i),header:s,timeout:this._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(t.statusCode=parseInt(i.success_action_status,10)),r(t)},fail:function(e){r(e)},complete:function(e){if(e&&e.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg)){console.warn(n._timeoutMsg);try{c.abort()}catch(e){}}}}),a&&c.onProgressUpdate((function(e){a(e)})),[2]}))}))}))},t.prototype.download=function(e){var t=this,n=this;return new Promise((function(r,o){var i=e.url,s=e.headers,a=wx.downloadFile({url:v("https:",i),header:s,timeout:t._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?r({statusCode:200,tempFilePath:e.tempFilePath}):r(e)},fail:function(e){o(e)},complete:function(e){if(e&&e.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===e.errMsg)){console.warn(n._timeoutMsg);try{a.abort()}catch(e){}}}})}))},t}(y),Ge={setItem:function(e,t){wx.setStorageSync(e,t)},getItem:function(e){return wx.getStorageSync(e)},removeItem:function(e){wx.removeStorageSync(e)},clear:function(){wx.clearStorageSync()}},Ke=function(e,t){void 0===t&&(t={});var n=wx.connectSocket(Fe({url:e},t));return{set onopen(e){n.onOpen(e)},set onmessage(e){n.onMessage(e)},set onclose(e){n.onClose(e)},set onerror(e){n.onError(e)},send:function(e){return n.send({data:e})},close:function(e,t){return n.close({code:e,reason:t})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};var Ve={genAdapter:function(){return{root:{},reqClass:He,wsClass:Ke,localStorage:Ge,primaryStorage:h.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.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(e){return!1}return!0},runtime:"wx_mp"},Je=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r},Ye=Pe.ERRORS,Ze={};function Xe(e,t){var n=t.name,r=t.namespace,o=t.entity,i=t.injectEvents,s=t.IIFE,a=void 0!==s&&s;if(Ze[n]||r&&e[r])throw new Error(JSON.stringify({code:Ye.INVALID_OPERATION,msg:"Duplicate component "+n}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:Ye.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(e)}if(Ze[n]=t,r?e.prototype[r]=o:ze(e.prototype,o),i){var c=i.bus,u=i.events;if(!c||!u||0===u.length)return;var f=e.prototype.fire||function(){};e.prototype.events||(e.prototype.events={}),(e.prototype.events||{})[n]?e.prototype.events[n].events=Je(e.prototype.events[n].events,u):e.prototype.events[n]={bus:c,events:u},e.prototype.fire=function(e,t){for(var n in f(e,t),this.events){var r=this.events[n],o=r.bus;if(r.events.includes(e)){o.fire(e,t);break}}}}}function ze(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var n in t)t.hasOwnProperty(n)&&(e[n]=ze(e[n],t[n]));return e}var Qe={},et=function(){return et=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},et.apply(this,arguments)},tt=ke.CloudbaseCache,nt={},rt={};function ot(e){var t=e.env,n=e.persistence,r=e.platformInfo,o={accessTokenKey:"access_token_"+t,accessTokenExpireKey:"access_token_expire_"+t,refreshTokenKey:"refresh_token_"+t,anonymousUuidKey:"anonymous_uuid_"+t,loginTypeKey:"login_type_"+t,userInfoKey:"user_info_"+t};nt[t]?nt[t].updatePersistence(n):nt[t]=new tt(et(et({},e),{keys:o,platformInfo:r,alwaysLocalKeys:["anonymousUuidKey"]})),rt[t]=rt[t]||new tt(et(et({},e),{keys:o,platformInfo:r,persistence:"local"}))}function it(e){return nt[e]}function st(e){return rt[e]}var at=Pe.setSdkName,ct=Pe.setProtocol,ut="",ft="@cloudbase/js-sdk";var lt,ht="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",pt="undefined"!=typeof process&&"e2e"===process.env.NODE_ENV&&"pre"===process.env.END_POINT?"//tcb-pre.tencentcloudapi.com/web":"//tcb-api.tencentcloudapi.com/web";function dt(e,t){pt=e,t&&(ht=t,ct(t))}function yt(){return{BASE_URL:pt,PROTOCOL:ht}}!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.CUSTOM="CUSTOM",e.NULL="NULL"}(lt||(lt={}));var gt="loginStateExpire",vt="refreshAccessToken",mt=function(){return mt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},mt.apply(this,arguments)},_t=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},bt=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},wt=Pe.ERRORS,Et=Me.genSeqId,St=Me.isFormData,It=Me.formatUrl,Ot=Me.createSign,At=Le.RUNTIME,Nt=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function Tt(e,t,n){var r=e[t];e[t]=function(t){var o={},i={};n.forEach((function(n){var r=n.call(e,t),s=r.data,a=r.headers;Object.assign(o,s),Object.assign(i,a)}));var s=t.data;return s&&function(){if(St(s))for(var e in o)s.append(e,o[e]);else t.data=mt(mt({},s),o)}(),t.headers=mt(mt({},t.headers||{}),i),r.call(e,t)}}function Rt(){var e=Et();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+ut,"x-seqid":e}}}var Pt=function(){function e(e){this._throwWhenRequestFail=!1,this.config=e,this._reqClass=new Qe.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post"]}),this._throwWhenRequestFail=e.throw||!1,this._cache=it(this.config.env),this._localCache=st(this.config.env),Tt(this._reqClass,"post",[Rt]),Tt(this._reqClass,"upload",[Rt]),Tt(this._reqClass,"download",[Rt])}return e.prototype.post=function(e){return _t(this,void 0,void 0,(function(){return bt(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.post(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.upload=function(e){return _t(this,void 0,void 0,(function(){return bt(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.upload(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.download=function(e){return _t(this,void 0,void 0,(function(){return bt(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.download(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.refreshAccessToken=function(){return _t(this,void 0,void 0,(function(){var e,t,n;return bt(this,(function(r){switch(r.label){case 0:this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken()),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._refreshAccessTokenPromise];case 2:return e=r.sent(),[3,4];case 3:return n=r.sent(),t=n,[3,4];case 4:if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return[2,e]}}))}))},e.prototype.getAccessToken=function(){return _t(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a,c;return bt(this,(function(u){switch(u.label){case 0:return e=this._cache.keys,t=e.accessTokenKey,n=e.accessTokenExpireKey,r=e.refreshTokenKey,[4,this._cache.getStoreAsync(r)];case 1:if(!u.sent())throw new Error(JSON.stringify({code:wt.OPERATION_FAIL,msg:"refresh token is not exist, your local data might be messed up, please retry after clear localStorage or sessionStorage"}));return[4,this._cache.getStoreAsync(t)];case 2:return o=u.sent(),s=Number,[4,this._cache.getStoreAsync(n)];case 3:return i=s.apply(void 0,[u.sent()]),a=!0,(c=this._shouldRefreshAccessTokenHook)?[4,this._shouldRefreshAccessTokenHook(o,i)]:[3,5];case 4:c=!u.sent(),u.label=5;case 5:return c&&(a=!1),o&&i&&!(i<Date.now())||!a?[3,7]:[4,this.refreshAccessToken()];case 6:return[2,u.sent()];case 7:return[2,{accessToken:o,accessTokenExpire:i}]}}))}))},e.prototype.request=function(e,t,n){return _t(this,void 0,void 0,(function(){var r,o,i,s,a,c,u,f,l,h,p,d,y,g,v,m,_,b,w,E,S,I,O,A,N,T;return bt(this,(function(R){switch(R.label){case 0:return r="x-tcb-trace_"+this.config.env,o="application/x-www-form-urlencoded",i=mt({action:e,dataVersion:"2020-01-10",env:this.config.env},t),-1!==Nt.indexOf(e)?[3,3]:(s=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(s)]);case 1:return R.sent()?(a=i,[4,this.getAccessToken()]):[3,3];case 2:a.access_token=R.sent().accessToken,R.label=3;case 3:if("storage.uploadFile"===e){for(u in c=new FormData)c.hasOwnProperty(u)&&void 0!==c[u]&&c.append(u,i[u]);o="multipart/form-data"}else for(u in o="application/json;charset=UTF-8",c={},i)void 0!==i[u]&&(c[u]=i[u]);return f={headers:{"content-type":o}},(null==n?void 0:n.onUploadProgress)&&(f.onUploadProgress=n.onUploadProgress),this.config.region&&(f.headers["X-TCB-Region"]=this.config.region),(l=this._localCache.getStore(r))&&(f.headers["X-TCB-Trace"]=l),Qe.runtime!==At.WEB&&(h=this.config,p=h.appSign,d=h.appSecret,y=Date.now(),g=d.appAccessKey,v=d.appAccessKeyId,m=Ot({data:{},timestamp:y,appAccessKeyId:v,appSign:p},g),f.headers["X-TCB-App-Source"]="timestamp="+y+";appAccessKeyId="+v+";appSign="+p+";sign="+m),_=t.parse,b=t.inQuery,w=t.search,E={env:this.config.env},_&&(E.parse=!0),b&&(E=mt(mt({},b),E)),S=yt(),I=S.BASE_URL,O=S.PROTOCOL,A=It(O,I,E),w&&(A+=w),[4,this.post(mt({url:A,data:c},f))];case 4:if(N=R.sent(),(T=N.header&&N.header["x-tcb-trace"])&&this._localCache.setStore(r,T),200!==Number(N.status)&&200!==Number(N.statusCode)||!N.data)throw new Error("network request error");return[2,N]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t={}),_t(this,void 0,void 0,(function(){var n;return bt(this,(function(r){switch(r.label){case 0:return[4,this.request(e,t,{onUploadProgress:t.onUploadProgress})];case 1:return"ACCESS_TOKEN_EXPIRED"!==(n=r.sent()).data.code||-1!==Nt.indexOf(e)?[3,4]:[4,this.refreshAccessToken()];case 2:return r.sent(),[4,this.request(e,t,{onUploadProgress:t.onUploadProgress})];case 3:n=r.sent(),r.label=4;case 4:if(n.data.code&&this._throwWhenRequestFail)throw new Error(JSON.stringify({code:wt.OPERATION_FAIL,msg:"["+n.data.code+"] "+n.data.message}));return[2,n.data]}}))}))},e.prototype._refreshAccessToken=function(e){return void 0===e&&(e=1),_t(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,u,f,l,h,p;return bt(this,(function(d){switch(d.label){case 0:return t=this._cache.keys,n=t.accessTokenKey,r=t.accessTokenExpireKey,o=t.refreshTokenKey,i=t.loginTypeKey,s=t.anonymousUuidKey,[4,this._cache.removeStoreAsync(n)];case 1:return d.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return d.sent(),[4,this._cache.getStoreAsync(o)];case 3:if(!(a=d.sent()))throw new Error(JSON.stringify({code:wt.INVALID_OPERATION,msg:"not login"}));return c={refresh_token:a},[4,this.request("auth.fetchAccessTokenWithRefreshToken",c)];case 4:return(u=d.sent()).data.code?"SIGN_PARAM_INVALID"!==(f=u.data.code)&&"REFRESH_TOKEN_EXPIRED"!==f&&"INVALID_REFRESH_TOKEN"!==f?[3,11]:[4,this._cache.getStoreAsync(i)]:[3,12];case 5:return d.sent()===lt.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===f?[4,this._cache.getStoreAsync(s)]:[3,9];case 6:return l=d.sent(),[4,this._cache.getStoreAsync(o)];case 7:return h=d.sent(),[4,this.send("auth.signInAnonymously",{anonymous_uuid:l,refresh_token:h})];case 8:if(p=d.sent(),this._setRefreshToken(p.refresh_token),e>=1)return[2,this._refreshAccessToken(--e)];throw new Error(JSON.stringify({code:wt.OPERATION_FAIL,message:"重试获取 refresh token 失败"}));case 9:return Jt.fire(gt),[4,this._cache.removeStoreAsync(o)];case 10:d.sent(),d.label=11;case 11:throw new Error(JSON.stringify({code:wt.NETWORK_ERROR,msg:"refresh access_token failed:"+u.data.code}));case 12:return u.data.access_token?(Jt.fire(vt),[4,this._cache.setStoreAsync(n,u.data.access_token)]):[3,15];case 13:return d.sent(),[4,this._cache.setStoreAsync(r,u.data.access_token_expire+Date.now())];case 14:return d.sent(),[2,{accessToken:u.data.access_token,accessTokenExpire:u.data.access_token_expire}];case 15:return u.data.refresh_token?[4,this._cache.removeStoreAsync(o)]:[3,19];case 16:return d.sent(),[4,this._cache.setStoreAsync(o,u.data.refresh_token)];case 17:return d.sent(),[4,this._refreshAccessToken()];case 18:d.sent(),d.label=19;case 19:return[2]}}))}))},e.prototype._setRefreshToken=function(e){return _t(this,void 0,void 0,(function(){var t,n,r,o;return bt(this,(function(i){switch(i.label){case 0:return t=this._cache.keys,n=t.accessTokenKey,r=t.accessTokenExpireKey,o=t.refreshTokenKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,e)];case 3:return i.sent(),[2]}}))}))},e}(),xt={};var Lt=function(){return Lt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Lt.apply(this,arguments)},Ct=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},kt=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Dt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},jt=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},Ut=Le.useAdapters,Mt=Le.useDefaultAdapter,qt=Le.RUNTIME,Wt=Pe.ERRORS,Ft=Pe.COMMUNITY_SITE_URL,Bt=Me.printWarn,$t=Te.catchErrorsDecorator,Ht={timeout:15e3,persistence:"local"},Gt=6e5,Kt={},Vt=function(){function e(e){this._config=e||this._config,this.authInstance=null}return Object.defineProperty(e.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return Qe},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return it(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return st(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return e=this._config.env,xt[e];var e},enumerable:!1,configurable:!0}),e.prototype.init=function(t){if(!t.env)throw new Error(JSON.stringify({code:Wt.INVALID_PARAMS,msg:"env must not be specified"}));if(Qe.adapter||this._useDefaultAdapter(),this.requestClient=new Qe.adapter.reqClass({timeout:t.timeout||5e3,timeoutMsg:"["+ft+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+t.timeout/1e3+"s"}),Qe.runtime!==qt.WEB){if(!t.appSecret)throw new Error(JSON.stringify({code:Wt.INVALID_PARAMS,msg:"invalid appSecret"}));var n=Qe.adapter.getAppSign?Qe.adapter.getAppSign():"";if(t.appSign&&n&&t.appSign!==n)throw new Error(JSON.stringify({code:Wt.INVALID_PARAMS,msg:"invalid appSign"}));if(n&&(t.appSign=n),!t.appSign)throw new Error(JSON.stringify({code:Wt.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=Lt(Lt({},Ht),t),this._config.timeout=this._formatTimeout(this._config.timeout);var r=this._config,o=r.env,i=r.persistence,s=r.debug,a=r.timeout,c=r.appSecret,u=r.appSign;ot({env:o,persistence:i,debug:s,platformInfo:this.platform}),function(e){xt[e.env]=new Pt(mt(mt({},e),{throw:!0}))}({env:o,region:t.region||"",timeout:a,appSecret:c,appSign:u}),t.region&&function(e,t,n){dt(t?"//"+e+"."+t+".tcb-api.tencentcloudapi.com/web":"//"+e+".ap-shanghai.tcb-api.tencentcloudapi.com/web",n)}(o,t.region||"");var f=new e(this._config);return f.requestClient=this.requestClient,f},e.prototype.updateConfig=function(e){var t=e.persistence,n=e.debug;this._config.persistence=t,this._config.debug=n,ot({env:this._config.env,persistence:t,debug:n,platformInfo:this.platform})},e.prototype.registerExtension=function(e){Kt[e.name]=e},e.prototype.invokeExtension=function(e,t){return Dt(this,void 0,void 0,(function(){var n;return jt(this,(function(r){switch(r.label){case 0:if(!(n=Kt[e]))throw new Error(JSON.stringify({code:Wt.INVALID_PARAMS,msg:"extension:"+e+" must be registered before invoke"}));return[4,n.invoke(t,this)];case 1:return[2,r.sent()]}}))}))},e.prototype.useAdapters=function(e){var t=Ut(e)||{},n=t.adapter,r=t.runtime;n&&(Qe.adapter=n),r&&(Qe.runtime=r)},e.prototype.registerHook=function(t){!function(e,t){var n=t.entity,r=t.target;if(!e.prototype.hasOwnProperty(r))throw new Error(JSON.stringify({code:Ye.INVALID_OPERATION,msg:"target:"+r+" is not exist"}));var o=e.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:Ye.INVALID_OPERATION,msg:"target:"+r+" is not a function which is the only type supports hook"}));e.prototype[r]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.call.apply(n,Je([this],e)),o.call.apply(o,Je([this],e))}}(e,t)},e.prototype.registerComponent=function(t){Xe(e,t)},e.prototype.registerVersion=function(e){!function(e){ut=e}(e)},e.prototype.registerSdkName=function(e){!function(e){ft=e,at(e)}(e)},e.prototype.registerEndPoint=function(e,t){dt(e,t)},e.prototype._useDefaultAdapter=function(){var e=Mt(),t=e.adapter,n=e.runtime;Qe.adapter=t,Qe.runtime=n},e.prototype._formatTimeout=function(e){switch(!0){case e>Gt:return Bt(Wt.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),Gt;case e<100:return Bt(Wt.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},Ct([$t({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ft]}),kt("design:type",Function),kt("design:paramtypes",[Object]),kt("design:returntype",e)],e.prototype,"init",null),Ct([$t({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ft]}),kt("design:type",Function),kt("design:paramtypes",[String,Object]),kt("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}(),Jt=new Vt;Jt.useAdapters(Ve);var Yt,Zt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Xt=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},zt=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request}return e.prototype.checkLocalLoginState=function(){return Zt(this,void 0,void 0,(function(){var e,t,n,r,o,i;return Xt(this,(function(s){switch(s.label){case 0:return e=this._cache.keys,t=e.accessTokenKey,n=e.accessTokenExpireKey,[4,this._cache.getStoreAsync(t)];case 1:return r=s.sent(),[4,this._cache.getStoreAsync(n)];case 2:return o=s.sent(),r?o&&o>Date.now()?[4,(i=new Dr({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,4]:[3,7];case 3:return s.sent(),[2,i];case 4:return[4,this._cache.removeStoreAsync(t)];case 5:return s.sent(),[4,this._cache.removeStoreAsync(n)];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},e.prototype.setRefreshToken=function(e){return Zt(this,void 0,void 0,(function(){var t,n,r,o;return Xt(this,(function(i){switch(i.label){case 0:return t=this._cache.keys,n=t.accessTokenKey,r=t.accessTokenExpireKey,o=t.refreshTokenKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,e)];case 3:return i.sent(),[2]}}))}))},e.prototype.setAccessToken=function(e,t){return Zt(this,void 0,void 0,(function(){var n,r,o;return Xt(this,(function(i){switch(i.label){case 0:return n=this._cache.keys,r=n.accessTokenKey,o=n.accessTokenExpireKey,[4,this._cache.setStoreAsync(r,e)];case 1:return i.sent(),[4,this._cache.setStoreAsync(o,t)];case 2:return i.sent(),[2]}}))}))},e.prototype.refreshUserInfo=function(){return Zt(this,void 0,void 0,(function(){var e;return Xt(this,(function(t){switch(t.label){case 0:return"auth.getUserInfo",[4,this._request.send("auth.getUserInfo",{})];case 1:return e=t.sent().data,[4,this.setLocalUserInfo(e)];case 2:return t.sent(),[2,e]}}))}))},e.prototype.setLocalUserInfo=function(e){return Zt(this,void 0,void 0,(function(){var t;return Xt(this,(function(n){switch(n.label){case 0:return t=this._cache.keys.userInfoKey,[4,this._cache.setStoreAsync(t,e)];case 1:return n.sent(),[2]}}))}))},e}();!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL",e.PHONE="PHONE"}(Yt||(Yt={}));var Qt=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),en=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},tn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},nn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},rn=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},on=Pe.getSdkName,sn=Pe.ERRORS,an=Pe.COMMUNITY_SITE_URL,cn=Le.RUNTIME,un=Me.getQuery,fn=Me.getHash,ln=Me.removeParam,hn=Me.printWarn,pn=Te.catchErrorsDecorator,dn=function(e){function t(t,n,r,o){var i=e.call(this,t)||this;return i._runtime=t.runtime,i._appid=n,i._scope=r,i._state=o||"weixin",i}return Qt(t,e),t.prototype.signIn=function(){return nn(this,void 0,void 0,(function(){return rn(this,(function(e){return[2,hn(sn.OPERATION_FAIL,"API signIn has been deprecated, please use signInWithRedirect insteed")]}))}))},t.prototype.signInWithRedirect=function(){return nn(this,void 0,void 0,(function(){return rn(this,(function(e){return[2,this._redirect()]}))}))},t.prototype.getRedirectResult=function(e){return nn(this,void 0,void 0,(function(){var t;return rn(this,(function(n){return(t=yn())?[2,this._signInWithCode(t,e)]:[2,null]}))}))},t.prototype.getLinkRedirectResult=function(e){return void 0===e&&(e={}),nn(this,void 0,void 0,(function(){var t,n,r,o,i,s;return rn(this,(function(a){return t=e.withUnionId,n=void 0!==t&&t,(r=yn())?(o=this._appid,c=this._scope,i="snsapi_login"===c?"WECHAT-OPEN":"WECHAT-PUBLIC",s=this._runtime===cn.WX_MP?"1":"0",[2,this._request.send("auth.linkWithWeixinCode",{payload:{appid:o,loginType:i,code:r,hybridMiniapp:s,withUnionId:n}})]):[2,null];var c}))}))},t.prototype._redirect=function(){var e=ln("code",location.href);e=ln("state",e),e=encodeURIComponent(e);var t="//open.weixin.qq.com/connect/oauth2/authorize";"snsapi_login"===this._scope&&(t="//open.weixin.qq.com/connect/qrconnect");try{location.href=t+"?appid="+this._appid+"&redirect_uri="+e+"&response_type=code&scope="+this._scope+"&state="+this._state+"#wechat_redirect"}catch(e){throw new Error("["+on()+"]["+sn.UNKOWN_ERROR+"]"+e)}},t.prototype._signInWithCode=function(e,t){return nn(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u;return rn(this,(function(f){switch(f.label){case 0:return n=this._cache.keys,r=n.accessTokenKey,o=n.accessTokenExpireKey,i=n.refreshTokenKey,l=this._scope,s="snsapi_login"===l?"WECHAT-OPEN":"WECHAT-PUBLIC",[4,this._getRefreshTokenByWXCode(this._appid,s,e,t)];case 1:return a=f.sent(),c=a.refreshToken,[4,this._cache.setStoreAsync(i,c)];case 2:return f.sent(),a.accessToken?[4,this._cache.setStoreAsync(r,a.accessToken)]:[3,4];case 3:f.sent(),f.label=4;case 4:return a.accessTokenExpire?[4,this._cache.setStoreAsync(o,String(a.accessTokenExpire+Date.now()))]:[3,6];case 5:f.sent(),f.label=6;case 6:return Cr.fire(Ur.LOGIN_STATE_CHANGED),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.WECHAT,persistence:this._config.persistence}),[4,this.refreshUserInfo()];case 7:return f.sent(),[4,(u=new Dr({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return f.sent(),[2,u]}var l}))}))},t.prototype._getRefreshTokenByWXCode=function(e,t,n,r){return void 0===r&&(r={}),nn(this,void 0,void 0,(function(){var o,i,s,a,c,u;return rn(this,(function(f){return o=r.withUnionId,i=void 0!==o&&o,s=r.createUser,a=void 0===s||s,c="snsapi_base"!==this._scope&&(r.syncUserInfo||!1),"auth.signIn",u=this._runtime===cn.WX_MP?"1":"0",[2,this._request.send("auth.signIn",{appid:e,loginType:t,hybridMiniapp:u,syncUserInfo:c,loginCredential:n,withUnionId:i,createUser:a}).then((function(e){if(e.code)throw new Error("["+on()+"]["+sn.OPERATION_FAIL+"] failed login via wechat: "+e.code);if(e.refresh_token)return{refreshToken:e.refresh_token,accessToken:e.access_token,accessTokenExpire:e.access_token_expire};throw new Error("["+on()+"]["+sn.OPERATION_FAIL+"] action:getJwt not return refreshToken")}))]}))}))},en([pn({title:"跳转微信公众号授权失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().signInWithRedirect() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+an]}),tn("design:type",Function),tn("design:paramtypes",[]),tn("design:returntype",Promise)],t.prototype,"signInWithRedirect",null),en([pn({title:"微信公众号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+an]}),tn("design:type",Function),tn("design:paramtypes",[Object]),tn("design:returntype",Promise)],t.prototype,"getRedirectResult",null),en([pn({title:"获取微信重定向绑定结果",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getLinkRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+an]}),tn("design:type",Function),tn("design:paramtypes",[Object]),tn("design:returntype",Promise)],t.prototype,"getLinkRedirectResult",null),t}(zt);function yn(){return un("code")||fn("code")}var gn=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),vn=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},mn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},_n=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},bn=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},wn=Pe.ERRORS,En=Pe.COMMUNITY_SITE_URL,Sn=Me.throwError,In=Me.isString,On=je.addEventListener,An=Te.catchErrorsDecorator,Nn=function(e){function t(t){var n=e.call(this,t)||this;return n._onConverted=n._onConverted.bind(n),On(Ur.ANONYMOUS_CONVERTED,n._onConverted),n}return gn(t,e),t.prototype.signIn=function(){return _n(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return bn(this,(function(a){switch(a.label){case 0:return[4,this._cache.updatePersistenceAsync("local")];case 1:return a.sent(),e=this._cache.keys,t=e.anonymousUuidKey,n=e.refreshTokenKey,[4,this._cache.getStoreAsync(t)];case 2:return r=a.sent(),[4,this._cache.getStoreAsync(n)];case 3:return o=a.sent(),[4,this._request.send("auth.signInAnonymously",{anonymous_uuid:r,refresh_token:o})];case 4:return(i=a.sent()).uuid&&i.refresh_token?[4,this._setAnonymousUUID(i.uuid)]:[3,10];case 5:return a.sent(),[4,this.setRefreshToken(i.refresh_token)];case 6:return a.sent(),[4,this._request.refreshAccessToken()];case 7:return a.sent(),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.ANONYMOUS,persistence:"local"}),Cr.fire(Ur.LOGIN_STATE_CHANGED),[4,(s=new Dr({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return a.sent(),[4,s.user.refresh()];case 9:return a.sent(),[2,s];case 10:throw new Error(JSON.stringify({code:wn.OPERATION_FAIL,msg:JSON.stringify(i)||"anonymous signIn failed"}))}}))}))},t.prototype.linkAndRetrieveDataWithTicket=function(e){return _n(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return bn(this,(function(c){switch(c.label){case 0:return In(e)||Sn(wn.INVALID_PARAMS,"ticket must be a string"),t=this._cache.keys,n=t.anonymousUuidKey,r=t.refreshTokenKey,[4,this._cache.getStoreAsync(n)];case 1:return o=c.sent(),[4,this._cache.getStoreAsync(r)];case 2:return i=c.sent(),[4,this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:o,refresh_token:i,ticket:e})];case 3:return(s=c.sent()).refresh_token?[4,this._clearAnonymousUUID()]:[3,8];case 4:return c.sent(),[4,this.setRefreshToken(s.refresh_token)];case 5:return c.sent(),[4,this._request.refreshAccessToken()];case 6:return c.sent(),Cr.fire(Ur.ANONYMOUS_CONVERTED,{env:this._config.env}),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{loginType:Yt.CUSTOM,persistence:"local"}),[4,(a=new Dr({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 7:return c.sent(),[2,a];case 8:Sn(wn.OPERATION_FAIL,JSON.stringify(s)||"linkAndRetrieveDataWithTicket failed"),c.label=9;case 9:return[2]}}))}))},t.prototype._setAnonymousUUID=function(e){return _n(this,void 0,void 0,(function(){var t,n,r;return bn(this,(function(o){switch(o.label){case 0:return t=this._cache.keys,n=t.anonymousUuidKey,r=t.loginTypeKey,[4,this._cache.removeStoreAsync(n)];case 1:return o.sent(),[4,this._cache.setStoreAsync(n,e)];case 2:return o.sent(),[4,this._cache.setStoreAsync(r,Yt.ANONYMOUS)];case 3:return o.sent(),[2]}}))}))},t.prototype._clearAnonymousUUID=function(){return _n(this,void 0,void 0,(function(){return bn(this,(function(e){switch(e.label){case 0:return[4,this._cache.removeStoreAsync(this._cache.keys.anonymousUuidKey)];case 1:return e.sent(),[2]}}))}))},t.prototype._onConverted=function(e){return _n(this,void 0,void 0,(function(){return bn(this,(function(t){switch(t.label){case 0:return e.data.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(this._config.persistence)];case 1:return t.sent(),[2]}}))}))},vn([An({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().anonymouseProvider().signIn() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+En]}),mn("design:type",Function),mn("design:paramtypes",[]),mn("design:returntype",Promise)],t.prototype,"signIn",null),t}(zt),Tn=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Rn=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Pn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},xn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Ln=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},Cn=Pe.ERRORS,kn=Pe.COMMUNITY_SITE_URL,Dn=Me.isString,jn=Te.catchErrorsDecorator,Un=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Tn(t,e),t.prototype.signIn=function(e){return xn(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return Ln(this,(function(c){switch(c.label){case 0:if(!Dn(e))throw new Error(JSON.stringify({code:Cn.INVALID_PARAMS,msg:"ticket must be a string"}));return t=this._cache.keys.refreshTokenKey,o=(r=this._request).send,i=["auth.signInWithTicket"],s={ticket:e},[4,this._cache.getStoreAsync(t)];case 1:return[4,o.apply(r,i.concat([(s.refresh_token=c.sent()||"",s)]))];case 2:return(n=c.sent()).refresh_token?[4,this.setRefreshToken(n.refresh_token)]:[3,7];case 3:return c.sent(),[4,this._request.refreshAccessToken()];case 4:return c.sent(),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.CUSTOM,persistence:this._config.persistence}),Cr.fire(Ur.LOGIN_STATE_CHANGED),[4,this.refreshUserInfo()];case 5:return c.sent(),[4,(a=new Dr({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 6:return c.sent(),[2,a];case 7:throw new Error(JSON.stringify({code:Cn.OPERATION_FAIL,msg:"custom signIn failed"}))}}))}))},Rn([jn({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().customAuthProvider().signIn() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kn]}),Pn("design:type",Function),Pn("design:paramtypes",[String]),Pn("design:returntype",Promise)],t.prototype,"signIn",null),t}(zt),Mn=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),qn=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Wn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Fn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Bn=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},$n=Me.throwError,Hn=Me.isString,Gn=Pe.ERRORS,Kn=Pe.COMMUNITY_SITE_URL,Vn=Te.catchErrorsDecorator,Jn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Mn(t,e),t.prototype.signIn=function(e,t){return Fn(this,void 0,void 0,(function(){var n,r,o,i,s;return Bn(this,(function(a){switch(a.label){case 0:return Hn(e)||$n(Gn.INVALID_PARAMS,"email must be a string"),n=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(n)||""})];case 1:return r=a.sent(),o=r.refresh_token,i=r.access_token,s=r.access_token_expire,o?[4,this.setRefreshToken(o)]:[3,8];case 2:return a.sent(),i&&s?[4,this.setAccessToken(i,s)]:[3,4];case 3:return a.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:a.sent(),a.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return a.sent(),Cr.fire(Ur.LOGIN_STATE_CHANGED),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.EMAIL,persistence:this._config.persistence}),[2,new Dr({envId:this._config.env,cache:this._cache,request:this._request})];case 8:r.code?$n(Gn.OPERATION_FAIL,"Email login fail["+r.code+"] "+r.message):$n(Gn.OPERATION_FAIL,"Email login fail"),a.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t){return Fn(this,void 0,void 0,(function(){return Bn(this,(function(n){return[2,this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})]}))}))},t.prototype.resetPassword=function(e){return Fn(this,void 0,void 0,(function(){return Bn(this,(function(t){return[2,this._request.send("auth.sendPasswordResetEmail",{email:e})]}))}))},t.prototype.resetPasswordWithToken=function(e,t){return Fn(this,void 0,void 0,(function(){return Bn(this,(function(n){return[2,this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})]}))}))},t.prototype.activate=function(e){return Fn(this,void 0,void 0,(function(){return Bn(this,(function(t){return[2,this._request.send("auth.activateEndUserMail",{token:e})]}))}))},qn([Vn({title:"邮箱密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().emailAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 邮箱地址与密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Kn]}),Wn("design:type",Function),Wn("design:paramtypes",[String,String]),Wn("design:returntype",Promise)],t.prototype,"signIn",null),qn([Vn({title:"邮箱注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithEmailAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Kn]}),Wn("design:type",Function),Wn("design:paramtypes",[String,String]),Wn("design:returntype",Promise)],t.prototype,"signUp",null),qn([Vn({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用 auth().sendPasswordResetEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经与当前用户绑定"," 4 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Kn]}),Wn("design:type",Function),Wn("design:paramtypes",[String]),Wn("design:returntype",Promise)],t.prototype,"resetPassword",null),qn([Vn({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Kn]}),Wn("design:type",Function),Wn("design:paramtypes",[String,String]),Wn("design:returntype",Promise)],t.prototype,"resetPasswordWithToken",null),qn([Vn({title:"邮箱激活失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Kn]}),Wn("design:type",Function),Wn("design:paramtypes",[String]),Wn("design:returntype",Promise)],t.prototype,"activate",null),t}(zt),Yn=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Zn=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Xn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},zn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Qn=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},er=Me.printWarn,tr=Pe.ERRORS,nr=Pe.COMMUNITY_SITE_URL,rr=Te.catchErrorsDecorator,or=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Yn(t,e),t.prototype.signIn=function(e,t){return zn(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u,f;return Qn(this,(function(l){switch(l.label){case 0:if("string"!=typeof e)throw new Error(JSON.stringify({code:tr.INVALID_PARAMS,msg:"username must be a string"}));return"string"!=typeof t&&(t="",er(tr.INVALID_PARAMS,"password is empty")),n=this._cache.keys.refreshTokenKey,i=(o=this._request).send,s=["auth.signIn"],a={loginType:Yt.USERNAME,username:e,password:t},[4,this._cache.getStoreAsync(n)];case 1:return[4,i.apply(o,s.concat([(a.refresh_token=l.sent()||"",a)]))];case 2:return r=l.sent(),c=r.refresh_token,u=r.access_token_expire,f=r.access_token,c?[4,this.setRefreshToken(c)]:[3,9];case 3:return l.sent(),f&&u?[4,this.setAccessToken(f,u)]:[3,5];case 4:return l.sent(),[3,7];case 5:return[4,this._request.refreshAccessToken()];case 6:l.sent(),l.label=7;case 7:return[4,this.refreshUserInfo()];case 8:return l.sent(),Cr.fire(Ur.LOGIN_STATE_CHANGED),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.USERNAME,persistence:this._config.persistence}),[2,new Dr({envId:this._config.env,cache:this._cache,request:this._request})];case 9:throw r.code?new Error(JSON.stringify({code:tr.OPERATION_FAIL,msg:"login by username failed:["+r.code+"] "+r.message})):new Error(JSON.stringify({code:tr.OPERATION_FAIL,msg:"login by username failed"}));case 10:return[2]}}))}))},Zn([rr({title:"用户名密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().signInWithUsernameAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录"," 3 - 用户名密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+nr]}),Xn("design:type",Function),Xn("design:paramtypes",[String,String]),Xn("design:returntype",Promise)],t.prototype,"signIn",null),t}(zt),ir=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),sr=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},ar=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},cr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},ur=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},fr=Me.throwError,lr=Me.isString,hr=Me.transformPhone,pr=Pe.ERRORS,dr=Pe.COMMUNITY_SITE_URL,yr=Te.catchErrorsDecorator,gr="SIGNIN",vr="SIGNUP",mr="FORCERESETPWD",_r=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ir(t,e),t.prototype.signIn=function(e){return cr(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,u;return ur(this,(function(f){switch(f.label){case 0:return t=e.phoneNumber,n=e.phoneCode,r=e.password,o=e.signMethod,lr(t)||fr(pr.INVALID_PARAMS,"phoneNumber must be a string"),lr(n)||lr(r)||fr(pr.INVALID_PARAMS,"phoneCode or password must be a string"),o||(o=gr),i=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:Yt.PHONE,phoneNumber:hr(t),phoneCode:n,password:r,refresh_token:this._cache.getStore(i)||"",signMethod:o})];case 1:return s=f.sent(),a=s.refresh_token,c=s.access_token,u=s.access_token_expire,a?[4,this.setRefreshToken(a)]:[3,8];case 2:return f.sent(),c&&u?[4,this.setAccessToken(c,u)]:[3,4];case 3:return f.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:f.sent(),f.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return f.sent(),Cr.fire(Ur.LOGIN_STATE_CHANGED),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.PHONE,persistence:this._config.persistence}),[2,new Dr({envId:this._config.env,cache:this._cache,request:this._request})];case 8:s.code?fr(pr.OPERATION_FAIL,"Phone login fail["+s.code+"] "+s.message):fr(pr.OPERATION_FAIL,"Phone login fail"),f.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t,n){return cr(this,void 0,void 0,(function(){return ur(this,(function(r){return[2,this.signIn({phoneNumber:e,phoneCode:t,password:n,signMethod:vr})]}))}))},t.prototype.forceResetPwd=function(e,t,n){return cr(this,void 0,void 0,(function(){return ur(this,(function(r){return[2,this.signIn({phoneNumber:e,phoneCode:t,password:n,signMethod:mr})]}))}))},sr([yr({title:"手机号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().SmsAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录"," 3 - 短信验证码/密码是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+dr]}),ar("design:type",Function),ar("design:paramtypes",[Object]),ar("design:returntype",Promise)],t.prototype,"signIn",null),sr([yr({title:"手机短信注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithPhoneCode() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+dr]}),ar("design:type",Function),ar("design:paramtypes",[String,String,String]),ar("design:returntype",Promise)],t.prototype,"signUp",null),sr([yr({title:"手机密码重置失败",messages:["请确认以下各项:"," 1 - 调用 auth().forceResetPwd() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+dr]}),ar("design:type",Function),ar("design:paramtypes",[String,String,String]),ar("design:returntype",Promise)],t.prototype,"forceResetPwd",null),t}(zt),br=function(){return br=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},br.apply(this,arguments)},wr=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Er=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Sr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Ir=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},Or=je.CloudbaseEventEmitter,Ar=Le.RUNTIME,Nr=Me.printWarn,Tr=Me.throwError,Rr=Me.transformPhone,Pr=Pe.ERRORS,xr=Pe.COMMUNITY_SITE_URL,Lr=Te.catchErrorsDecorator,Cr=new Or,kr=function(){function e(e){var t=e.cache,n=e.request;this._cache=t,this._request=n,this._setUserInfo()}return e.prototype.checkLocalInfo=function(){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(e){return this.uid=this._getLocalUserInfo("uid"),this.loginType=this._getLocalUserInfo("loginType"),this.openid=this._getLocalUserInfo("wxOpenId"),this.wxOpenId=this._getLocalUserInfo("wxOpenId"),this.wxPublicId=this._getLocalUserInfo("wxPublicId"),this.unionId=this._getLocalUserInfo("wxUnionId"),this.qqMiniOpenId=this._getLocalUserInfo("qqMiniOpenId"),this.customUserId=this._getLocalUserInfo("customUserId"),this.nickName=this._getLocalUserInfo("nickName"),this.gender=this._getLocalUserInfo("gender"),this.avatarUrl=this._getLocalUserInfo("avatarUrl"),this.email=this._getLocalUserInfo("email"),this.hasPassword=Boolean(this._getLocalUserInfo("hasPassword")),this.phone=this._getLocalUserInfo("phone"),this.username=this._getLocalUserInfo("username"),this.location={country:this._getLocalUserInfo("country"),province:this._getLocalUserInfo("province"),city:this._getLocalUserInfo("city")},[2]}))}))},e.prototype.checkLocalInfoAsync=function(){return Sr(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a,c,u,f,l,h,p,d,y,g,v;return Ir(this,(function(m){switch(m.label){case 0:return e=this,[4,this._getLocalUserInfoAsync("uid")];case 1:return e.uid=m.sent(),t=this,[4,this._getLocalUserInfoAsync("loginType")];case 2:return t.loginType=m.sent(),n=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 3:return n.openid=m.sent(),r=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 4:return r.wxOpenId=m.sent(),o=this,[4,this._getLocalUserInfoAsync("wxPublicId")];case 5:return o.wxPublicId=m.sent(),i=this,[4,this._getLocalUserInfoAsync("wxUnionId")];case 6:return i.unionId=m.sent(),s=this,[4,this._getLocalUserInfoAsync("qqMiniOpenId")];case 7:return s.qqMiniOpenId=m.sent(),a=this,[4,this._getLocalUserInfoAsync("customUserId")];case 8:return a.customUserId=m.sent(),c=this,[4,this._getLocalUserInfoAsync("nickName")];case 9:return c.nickName=m.sent(),u=this,[4,this._getLocalUserInfoAsync("gender")];case 10:return u.gender=m.sent(),f=this,[4,this._getLocalUserInfoAsync("avatarUrl")];case 11:return f.avatarUrl=m.sent(),l=this,[4,this._getLocalUserInfoAsync("email")];case 12:return l.email=m.sent(),h=this,p=Boolean,[4,this._getLocalUserInfoAsync("hasPassword")];case 13:return h.hasPassword=p.apply(void 0,[m.sent()]),d=this,[4,this._getLocalUserInfoAsync("phone")];case 14:return d.phone=m.sent(),y=this,[4,this._getLocalUserInfoAsync("username")];case 15:return y.username=m.sent(),g=this,v={},[4,this._getLocalUserInfoAsync("country")];case 16:return v.country=m.sent(),[4,this._getLocalUserInfoAsync("province")];case 17:return v.province=m.sent(),[4,this._getLocalUserInfoAsync("city")];case 18:return g.location=(v.city=m.sent(),v),[2]}}))}))},e.prototype.linkWithTicket=function(e){if("string"!=typeof e)throw new Error("ticket must be string");return this._request.send("auth.linkWithTicket",{ticket:e})},e.prototype.linkWithRedirect=function(e){e.signInWithRedirect()},e.prototype.getLinkedUidList=function(){return Sr(this,void 0,void 0,(function(){var e,t,n,r,o,i;return Ir(this,(function(s){switch(s.label){case 0:return[4,this._request.send("auth.getLinkedUidList",{})];case 1:for(e=s.sent().data,t=!1,n=e.users,r=0,o=n;r<o.length;r++)if((i=o[r]).wxOpenId&&i.wxPublicId){t=!0;break}return[2,{users:n,hasPrimaryUid:t}]}}))}))},e.prototype.setPrimaryUid=function(e){return this._request.send("auth.setPrimaryUid",{uid:e})},e.prototype.unlink=function(e){return this._request.send("auth.unlink",{platform:e})},e.prototype.update=function(e){return Sr(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return Ir(this,(function(c){switch(c.label){case 0:return t=e.nickName,n=e.gender,r=e.avatarUrl,o=e.province,i=e.country,s=e.city,[4,this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:r,province:o,country:i,city:s})];case 1:return a=c.sent().data,this._setLocalUserInfo(a),[2]}}))}))},e.prototype.updatePassword=function(e,t){return this._request.send("auth.updatePassword",{oldPassword:t,newPassword:e})},e.prototype.updateEmail=function(e,t){return this._request.send("auth.updateEmail",{newEmail:e,password:t})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&Tr(Pr.INVALID_PARAMS,"username must be a string"),this._request.send("auth.updateUsername",{username:e})},e.prototype.refresh=function(){return Sr(this,void 0,void 0,(function(){var e;return Ir(this,(function(t){switch(t.label){case 0:return"auth.getUserInfo",[4,this._request.send("auth.getUserInfo",{})];case 1:return e=t.sent().data,this._setLocalUserInfo(e),[2,e]}}))}))},e.prototype.linkWithPhoneNumber=function(e,t){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:Rr(e),phoneCode:t})]}))}))},e.prototype.updatePhoneNumber=function(e,t){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:Rr(e),phoneCode:t})]}))}))},e.prototype._getLocalUserInfo=function(e){var t=this._cache.keys.userInfoKey;return this._cache.getStore(t)[e]},e.prototype._getLocalUserInfoAsync=function(e){return Sr(this,void 0,void 0,(function(){var t;return Ir(this,(function(n){switch(n.label){case 0:return t=this._cache.keys.userInfoKey,[4,this._cache.getStoreAsync(t)];case 1:return[2,n.sent()[e]]}}))}))},e.prototype._setUserInfo=function(){var e=this,t=this._cache.keys.userInfoKey,n=this._cache.getStore(t);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl","phone","username"].forEach((function(t){e[t]=n[t]})),this.location={country:n.country,province:n.province,city:n.city}},e.prototype._setLocalUserInfo=function(e){var t=this._cache.keys.userInfoKey;this._cache.setStore(t,e),this._setUserInfo()},wr([Lr({title:"绑定自定义登录失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithTicket() 的语法或参数是否正确"," 2 - 此账户是否已经绑定自定义登录"," 3 - ticket 参数是否归属当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String]),Er("design:returntype",Promise)],e.prototype,"linkWithTicket",null),wr([Lr({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithRedirect() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方"," 3 - 此第三方是否已经授权","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[Object]),Er("design:returntype",void 0)],e.prototype,"linkWithRedirect",null),wr([Lr({title:"获取账户列表失败",messages:["请确认以下各项:"," 1 - 调用 User.getLinkedUidList() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[]),Er("design:returntype",Promise)],e.prototype,"getLinkedUidList",null),wr([Lr({title:"设置微信主账号失败",messages:["请确认以下各项:"," 1 - 调用 User.setPrimaryUid() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String]),Er("design:returntype",void 0)],e.prototype,"setPrimaryUid",null),wr([Lr({title:"接触绑定失败",messages:["请确认以下各项:"," 1 - 调用 User.unlink() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String]),Er("design:returntype",void 0)],e.prototype,"unlink",null),wr([Lr({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[Object]),Er("design:returntype",Promise)],e.prototype,"update",null),wr([Lr({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String,String]),Er("design:returntype",void 0)],e.prototype,"updatePassword",null),wr([Lr({title:"更新邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 User.updateEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String,String]),Er("design:returntype",void 0)],e.prototype,"updateEmail",null),wr([Lr({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String]),Er("design:returntype",void 0)],e.prototype,"updateUsername",null),wr([Lr({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[]),Er("design:returntype",Promise)],e.prototype,"refresh",null),wr([Lr({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().linkWithPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String,String]),Er("design:returntype",Promise)],e.prototype,"linkWithPhoneNumber",null),wr([Lr({title:"更新手机号失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String,String]),Er("design:returntype",Promise)],e.prototype,"updatePhoneNumber",null),e}(),Dr=function(){function e(e){var t=e.envId,n=e.cache,r=e.request;t||Tr(Pr.INVALID_PARAMS,"envId is not defined"),this._cache=n,this.user=new kr({cache:n,request:r})}return e.prototype.checkLocalState=function(){return Sr(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Ir(this,(function(a){return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,o=this._cache.getStore(t),i=this._cache.getStore(n),s=this._cache.getStore(r),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},this._loginType=this._cache.getStore(this._cache.keys.loginTypeKey),this.user.checkLocalInfo(),[2]}))}))},e.prototype.checkLocalStateAsync=function(){return Sr(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a;return Ir(this,(function(c){switch(c.label){case 0:return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,[4,this._cache.getStoreAsync(t)];case 1:return o=c.sent(),[4,this._cache.getStoreAsync(n)];case 2:return i=c.sent(),[4,this._cache.getStoreAsync(r)];case 3:return s=c.sent(),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},a=this,[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 4:return a._loginType=c.sent(),[4,this.user.checkLocalInfoAsync()];case 5:return c.sent(),[2]}}))}))},Object.defineProperty(e.prototype,"isAnonymousAuth",{get:function(){return this.loginType===Yt.ANONYMOUS},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCustomAuth",{get:function(){return this.loginType===Yt.CUSTOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isWeixinAuth",{get:function(){return this.loginType===Yt.WECHAT||this.loginType===Yt.WECHAT_OPEN||this.loginType===Yt.WECHAT_PUBLIC},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsernameAuth",{get:function(){return this.loginType===Yt.USERNAME},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loginType",{get:function(){return this._loginType},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPhoneAuth",{get:function(){return this.loginType===Yt.PHONE},enumerable:!1,configurable:!0}),e}(),jr=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request,this._runtime=e.runtime||Ar.WEB,Cr.on(Ur.LOGIN_TYPE_CHANGED,this._onLoginTypeChanged.bind(this))}return Object.defineProperty(e.prototype,"currentUser",{get:function(){if("async"!==this._cache.mode){var e=this.hasLoginState();return e&&e.user||null}Nr(Pr.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrenUser insteed")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loginType",{get:function(){return this._cache.getStore(this._cache.keys.loginTypeKey)},enumerable:!1,configurable:!0}),e.prototype.getCurrenUser=function(){return Sr(this,void 0,void 0,(function(){var e;return Ir(this,(function(t){switch(t.label){case 0:return[4,this.getLoginState()];case 1:return(e=t.sent())?[4,e.user.checkLocalInfoAsync()]:[3,3];case 2:return t.sent(),[2,e.user||null];case 3:return[2,null]}}))}))},e.prototype.getLoginType=function(){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(e){switch(e.label){case 0:return[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAccessToken=function(){return Sr(this,void 0,void 0,(function(){var e;return Ir(this,(function(t){switch(t.label){case 0:return e={},[4,this._request.getAccessToken()];case 1:return[2,(e.accessToken=t.sent().accessToken,e.env=this._config.env,e)]}}))}))},e.prototype.weixinAuthProvider=function(e){var t=e.appid,n=e.scope,r=e.state;return this._weixinAuthProvider||(this._weixinAuthProvider=new dn(br(br({},this._config),{cache:this._cache,request:this._request,runtime:this._runtime}),t,n,r)),this._weixinAuthProvider},e.prototype.anonymousAuthProvider=function(){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new Nn(br(br({},this._config),{cache:this._cache,request:this._request}))),this._anonymousAuthProvider},e.prototype.customAuthProvider=function(){return this._customAuthProvider||(this._customAuthProvider=new Un(br(br({},this._config),{cache:this._cache,request:this._request}))),this._customAuthProvider},e.prototype.emailAuthProvider=function(){return this._emailAuthProvider||(this._emailAuthProvider=new Jn(br(br({},this._config),{cache:this._cache,request:this._request}))),this._emailAuthProvider},e.prototype.usernameAuthProvider=function(){return this._usernameAuthProvider||(this._usernameAuthProvider=new or(br(br({},this._config),{cache:this._cache,request:this._request}))),this._usernameAuthProvider},e.prototype.phoneAuthProvider=function(){return this._phoneAuthProvider||(this._phoneAuthProvider=new _r(br(br({},this._config),{cache:this._cache,request:this._request}))),this._phoneAuthProvider},e.prototype.signInWithUsernameAndPassword=function(e,t){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(n){return[2,this.usernameAuthProvider().signIn(e,t)]}))}))},e.prototype.isUsernameRegistered=function(e){return Sr(this,void 0,void 0,(function(){var t;return Ir(this,(function(n){switch(n.label){case 0:return"string"!=typeof e&&Tr(Pr.INVALID_PARAMS,"username must be a string"),[4,this._request.send("auth.isUsernameRegistered",{username:e})];case 1:return[2,null==(t=n.sent().data)?void 0:t.isRegistered]}}))}))},e.prototype.signInWithEmailAndPassword=function(e,t){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(n){return[2,this.emailAuthProvider().signIn(e,t)]}))}))},e.prototype.signUpWithEmailAndPassword=function(e,t){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(n){return[2,this.emailAuthProvider().signUp(e,t)]}))}))},e.prototype.sendPasswordResetEmail=function(e){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(t){return[2,this.emailAuthProvider().resetPassword(e)]}))}))},e.prototype.signOut=function(){return Sr(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Ir(this,(function(a){switch(a.label){case 0:return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,o="auth.logout",[4,this._cache.getStoreAsync(t)];case 1:return(i=a.sent())?[4,this._request.send(o,{refresh_token:i})]:[2];case 2:return s=a.sent(),this._cache.removeStoreAsync(t),this._cache.removeStoreAsync(n),this._cache.removeStoreAsync(r),Cr.fire(Ur.LOGIN_STATE_CHANGED),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.NULL,persistence:this._config.persistence}),[2,s]}}))}))},e.prototype.onLoginStateChanged=function(e){return Sr(this,void 0,void 0,(function(){var t,n=this;return Ir(this,(function(r){switch(r.label){case 0:return Cr.on(Ur.LOGIN_STATE_CHANGED,(function(){return Sr(n,void 0,void 0,(function(){var t;return Ir(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return t=n.sent(),e.call(this,t),[2]}}))}))})),[4,this.getLoginState()];case 1:return t=r.sent(),e.call(this,t),[2]}}))}))},e.prototype.onLoginStateExpired=function(e){Cr.on(Ur.LOGIN_STATE_EXPIRED,e.bind(this))},e.prototype.onAccessTokenRefreshed=function(e){Cr.on(Ur.ACCESS_TOKEN_REFRESHD,e.bind(this))},e.prototype.onAnonymousConverted=function(e){Cr.on(Ur.ANONYMOUS_CONVERTED,e.bind(this))},e.prototype.onLoginTypeChanged=function(e){var t=this;Cr.on(Ur.LOGIN_TYPE_CHANGED,(function(){return Sr(t,void 0,void 0,(function(){var t;return Ir(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return t=n.sent(),e.call(this,t),[2]}}))}))}))},e.prototype.hasLoginState=function(){if("async"!==this._cache.mode){var e=this._cache.keys.refreshTokenKey;if(this._cache.getStore(e)){var t=new Dr({envId:this._config.env,cache:this._cache,request:this._request});return t.checkLocalState(),t}return null}Nr(Pr.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},e.prototype.getLoginState=function(){return Sr(this,void 0,void 0,(function(){var e,t;return Ir(this,(function(n){switch(n.label){case 0:return e=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(e)];case 1:return n.sent()?[4,(t=new Dr({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,3];case 2:return n.sent(),[2,t];case 3:return[2,null]}}))}))},e.prototype.shouldRefreshAccessToken=function(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)},e.prototype.getUserInfo=function(){return Sr(this,void 0,void 0,(function(){var e;return Ir(this,(function(t){switch(t.label){case 0:return"auth.getUserInfo",[4,this._request.send("auth.getUserInfo",{})];case 1:return(e=t.sent()).code?[2,e]:[2,br(br({},e.data),{requestId:e.seqId})]}}))}))},e.prototype.getAuthHeader=function(){var e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=this._cache.getStore(t);return{"x-cloudbase-credentials":this._cache.getStore(n)+"/@@/"+r}},e.prototype.getAuthHeaderAsync=function(){return Sr(this,void 0,void 0,(function(){var e,t,n,r;return Ir(this,(function(o){switch(o.label){case 0:return[4,this._request.refreshAccessToken()];case 1:return o.sent(),e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,[4,this._cache.getStoreAsync(t)];case 2:return r=o.sent(),[4,this._cache.getStoreAsync(n)];case 3:return[2,{"x-cloudbase-credentials":o.sent()+"/@@/"+r}]}}))}))},e.prototype.sendPhoneCode=function(e){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(t){switch(t.label){case 0:return[4,this._request.send("auth.sendPhoneCode",{phoneNumber:Rr(e)})];case 1:return[2,"Ok"===t.sent().data.SendStatus]}}))}))},e.prototype.signUpWithPhoneCode=function(e,t,n){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(r){return[2,this.phoneAuthProvider().signUp(e,t,n)]}))}))},e.prototype.signInWithPhoneCodeOrPassword=function(e){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(t){return[2,this.phoneAuthProvider().signIn(e)]}))}))},e.prototype.forceResetPwdByPhoneCode=function(e){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(t){return[2,this.phoneAuthProvider().signIn(br(br({},e),{signMethod:mr}))]}))}))},e.prototype._onLoginTypeChanged=function(e){return Sr(this,void 0,void 0,(function(){var t,n,r;return Ir(this,(function(o){switch(o.label){case 0:return t=e.data,n=t.loginType,r=t.persistence,t.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(r)];case 1:return o.sent(),[4,this._cache.setStoreAsync(this._cache.keys.loginTypeKey,n)];case 2:return o.sent(),[2]}}))}))},wr([Lr({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[]),Er("design:returntype",Promise)],e.prototype,"getCurrenUser",null),wr([Lr({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String]),Er("design:returntype",Promise)],e.prototype,"isUsernameRegistered",null),wr([Lr({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[]),Er("design:returntype",Promise)],e.prototype,"signOut",null),wr([Lr({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[]),Er("design:returntype",Promise)],e.prototype,"getLoginState",null),wr([Lr({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[]),Er("design:returntype",Promise)],e.prototype,"getUserInfo",null),wr([Lr({title:"发送短信验证码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String]),Er("design:returntype",Promise)],e.prototype,"sendPhoneCode",null),e}(),Ur={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRED:"loginStateExpire",LOGIN_TYPE_CHANGED:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",ACCESS_TOKEN_REFRESHD:"refreshAccessToken"},Mr={name:"auth",namespace:"auth",injectEvents:{bus:Cr,events:[Ur.LOGIN_TYPE_CHANGED,Ur.LOGIN_STATE_EXPIRED,Ur.LOGIN_STATE_CHANGED,Ur.ACCESS_TOKEN_REFRESHD,Ur.ANONYMOUS_CONVERTED]},entity:function(e){if(void 0===e&&(e={region:"",persistence:"local"}),this.authInstance)return Nr(Pr.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var t=this.platform,n=t.adapter,r=t.runtime,o=e.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=this.config,s=i.env,a=i.persistence,c=i.debug;return this.authInstance=new jr({env:s,region:e.region,persistence:a,debug:c,cache:this.cache,request:this.request,runtime:r}),this.authInstance}};try{cloudbase.registerComponent(Mr)}catch(e){}var qr=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Wr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Fr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Br=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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=Pe.getSdkName,Hr=Pe.ERRORS,Gr=Pe.COMMUNITY_SITE_URL,Kr=Me.execCallback,Vr=Te.catchErrorsDecorator,Jr="functions",Yr=function(){function e(){}return e.prototype.callFunction=function(e,t){return Fr(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u,f,l,h,p;return Br(this,(function(d){switch(d.label){case 0:if(n=e.name,r=e.data,o=e.query,i=e.parse,s=e.search,!n)throw new Error(JSON.stringify({code:Hr.INVALID_PARAMS,msg:"["+Jr+".callFunction] invalid function name"}));try{a=r?JSON.stringify(r):""}catch(e){throw new Error(JSON.stringify({code:Hr.INVALID_PARAMS,msg:"["+Jr+".callFunction] invalid data"}))}c="functions.invokeFunction",u={inQuery:o,parse:i,search:s,function_name:n,request_data:a},f=this.request,d.label=1;case 1:return d.trys.push([1,3,,4]),[4,f.send(c,u)];case 2:if((l=d.sent()).code)return[2,Kr(t,null,l)];if(h=l.data.response_data,i)return[2,Kr(t,null,{result:h,requestId:l.requestId})];try{return h=JSON.parse(l.data.response_data),[2,Kr(t,null,{result:h,requestId:l.requestId})]}catch(e){Kr(t,new Error("["+$r()+"]["+Hr.INVALID_PARAMS+"]["+Jr+".callFunction] response data must be json"))}return[3,4];case 3:return p=d.sent(),Kr(t,p),[3,4];case 4:return[2]}}))}))},qr([Vr({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Gr]}),Wr("design:type",Function),Wr("design:paramtypes",[Object,Function]),Wr("design:returntype",Promise)],e.prototype,"callFunction",null),e}(),Zr=new Yr,Xr={name:Jr,entity:{callFunction:Zr.callFunction}};try{cloudbase.registerComponent(Xr)}catch(e){}var zr=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Qr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},eo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},to=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},no=Pe.getSdkName,ro=Pe.ERRORS,oo=Pe.COMMUNITY_SITE_URL,io=Me.isArray,so=Me.isString,ao=Me.isPalinObject,co=Me.execCallback,uo=Te.catchErrorsDecorator,fo="storage",lo=function(){function e(){}return e.prototype.uploadFile=function(e,t){return eo(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u,f,l,h,p,d,y,g;return to(this,(function(v){switch(v.label){case 0:if(n=e.cloudPath,r=e.filePath,o=e.onUploadProgress,!so(n)||!r)throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".uploadFile] invalid params"}));return"storage.getUploadMetadata",[4,(i=this.request).send("storage.getUploadMetadata",{path:n})];case 1:return s=v.sent(),a=s.data,c=a.url,u=a.authorization,f=a.token,l=a.fileId,h=a.cosFileId,p=a.download_url,d=s.requestId,y={key:n,signature:u,"x-cos-meta-fileid":h,success_action_status:"201","x-cos-security-token":f},[4,i.upload({url:c,data:y,file:r,name:n,onUploadProgress:o})];case 2:return 201===(g=v.sent()).statusCode?[2,co(t,null,{fileID:l,download_url:p,requestId:d})]:[2,co(t,new Error("["+no()+"]["+ro.OPERATION_FAIL+"]["+fo+"]:"+g.data))]}}))}))},e.prototype.getUploadMetadata=function(e,t){return eo(this,void 0,void 0,(function(){var n,r,o,i,s;return to(this,(function(a){switch(a.label){case 0:if(n=e.cloudPath,!so(n))throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".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,co(t,null,i)];case 3:return s=a.sent(),[2,co(t,s)];case 4:return[2]}}))}))},e.prototype.deleteFile=function(e,t){return eo(this,void 0,void 0,(function(){var n,r,o,i,s,a;return to(this,(function(c){switch(c.label){case 0:if(!(n=e.fileList)||!io(n)||0===n.length)throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".deleteFile] fileList must not be empty"}));for(r=0,o=n;r<o.length;r++)if(!(i=o[r])||!so(i))throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".deleteFile] fileID must be string"}));return"storage.batchDeleteFile",[4,this.request.send("storage.batchDeleteFile",{fileid_list:n})];case 1:return(s=c.sent()).code?[2,co(t,null,s)]:(a={fileList:s.data.delete_list,requestId:s.requestId},[2,co(t,null,a)])}}))}))},e.prototype.getTempFileURL=function(e,t){return eo(this,void 0,void 0,(function(){var n,r,o,i,s,a;return to(this,(function(c){switch(c.label){case 0:if(!(n=e.fileList)||!io(n)||0===n.length)throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".getTempFileURL] fileList must not be empty"}));for(r=[],o=0,i=n;o<i.length;o++)if(s=i[o],ao(s)){if(!s.hasOwnProperty("fileID")||!s.hasOwnProperty("maxAge"))throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".getTempFileURL] file info must include fileID and maxAge"}));r.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!so(s))throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".getTempFileURL] invalid fileList"}));r.push({fileid:s})}return"storage.batchGetDownloadUrl",[4,this.request.send("storage.batchGetDownloadUrl",{file_list:r})];case 1:return(a=c.sent()).code?[2,co(t,null,a)]:[2,co(t,null,{fileList:a.data.download_list,requestId:a.requestId})]}}))}))},e.prototype.downloadFile=function(e,t){return eo(this,void 0,void 0,(function(){var n,r,o,i,s,a;return to(this,(function(c){switch(c.label){case 0:if(n=e.fileID,!so(n))throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".getTempFileURL] fileID must be string"}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}]})];case 1:return r=c.sent(),"SUCCESS"!==(o=r.fileList[0]).code?[2,co(t,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return a=c.sent(),[2,co(t,null,a)]}}))}))},zr([uo({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+oo]}),Qr("design:type",Function),Qr("design:paramtypes",[Object,Function]),Qr("design:returntype",Promise)],e.prototype,"uploadFile",null),zr([uo({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+oo]}),Qr("design:type",Function),Qr("design:paramtypes",[Object,Function]),Qr("design:returntype",Promise)],e.prototype,"getUploadMetadata",null),zr([uo({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+oo]}),Qr("design:type",Function),Qr("design:paramtypes",[Object,Function]),Qr("design:returntype",Promise)],e.prototype,"deleteFile",null),zr([uo({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+oo]}),Qr("design:type",Function),Qr("design:paramtypes",[Object,Function]),Qr("design:returntype",Promise)],e.prototype,"getTempFileURL",null),zr([uo({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+oo]}),Qr("design:type",Function),Qr("design:paramtypes",[Object,Function]),Qr("design:returntype",Promise)],e.prototype,"downloadFile",null),e}(),ho=new lo,po={name:fo,entity:{uploadFile:ho.uploadFile,deleteFile:ho.deleteFile,getTempFileURL:ho.getTempFileURL,downloadFile:ho.downloadFile,getUploadMetadata:ho.getUploadMetadata}};try{cloudbase.registerComponent(po)}catch(e){}var yo="__lodash_hash_undefined__",go=1/0,vo=9007199254740991,mo="[object Function]",_o="[object GeneratorFunction]",bo="[object Symbol]",wo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Eo=/^\w*$/,So=/^\./,Io=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Oo=/\\(\\)?/g,Ao=/^\[object .+?Constructor\]$/,No=/^(?:0|[1-9]\d*)$/,To="object"==typeof r&&r&&r.Object===Object&&r,Ro="object"==typeof self&&self&&self.Object===Object&&self,Po=To||Ro||Function("return this")();var xo,Lo=Array.prototype,Co=Function.prototype,ko=Object.prototype,Do=Po["__core-js_shared__"],jo=(xo=/[^.]+$/.exec(Do&&Do.keys&&Do.keys.IE_PROTO||""))?"Symbol(src)_1."+xo:"",Uo=Co.toString,Mo=ko.hasOwnProperty,qo=ko.toString,Wo=RegExp("^"+Uo.call(Mo).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Fo=Po.Symbol,Bo=Lo.splice,$o=ti(Po,"Map"),Ho=ti(Object,"create"),Go=Fo?Fo.prototype:void 0,Ko=Go?Go.toString:void 0;function Vo(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Jo(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Yo(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Zo(e,t,n){var r=e[t];Mo.call(e,t)&&si(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function Xo(e,t){for(var n=e.length;n--;)if(si(e[n][0],t))return n;return-1}function zo(e){if(!ci(e)||(t=e,jo&&jo in t))return!1;var t,n=function(e){var t=ci(e)?qo.call(e):"";return t==mo||t==_o}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Wo:Ao;return n.test(function(e){if(null!=e){try{return Uo.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function Qo(e,t,n,r){if(!ci(e))return e;t=function(e,t){if(ai(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||ui(e))return!0;return Eo.test(e)||!wo.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:function(e){return ai(e)?e:ri(e)}(t);for(var o=-1,i=t.length,s=i-1,a=e;null!=a&&++o<i;){var c=oi(t[o]),u=n;if(o!=s){var f=a[c];void 0===(u=r?r(f,c,a):void 0)&&(u=ci(f)?f:ni(t[o+1])?[]:{})}Zo(a,c,u),a=a[c]}return e}function ei(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function ti(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return zo(n)?n:void 0}function ni(e,t){return!!(t=null==t?vo:t)&&("number"==typeof e||No.test(e))&&e>-1&&e%1==0&&e<t}Vo.prototype.clear=function(){this.__data__=Ho?Ho(null):{}},Vo.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Vo.prototype.get=function(e){var t=this.__data__;if(Ho){var n=t[e];return n===yo?void 0:n}return Mo.call(t,e)?t[e]:void 0},Vo.prototype.has=function(e){var t=this.__data__;return Ho?void 0!==t[e]:Mo.call(t,e)},Vo.prototype.set=function(e,t){return this.__data__[e]=Ho&&void 0===t?yo:t,this},Jo.prototype.clear=function(){this.__data__=[]},Jo.prototype.delete=function(e){var t=this.__data__,n=Xo(t,e);return!(n<0)&&(n==t.length-1?t.pop():Bo.call(t,n,1),!0)},Jo.prototype.get=function(e){var t=this.__data__,n=Xo(t,e);return n<0?void 0:t[n][1]},Jo.prototype.has=function(e){return Xo(this.__data__,e)>-1},Jo.prototype.set=function(e,t){var n=this.__data__,r=Xo(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Yo.prototype.clear=function(){this.__data__={hash:new Vo,map:new($o||Jo),string:new Vo}},Yo.prototype.delete=function(e){return ei(this,e).delete(e)},Yo.prototype.get=function(e){return ei(this,e).get(e)},Yo.prototype.has=function(e){return ei(this,e).has(e)},Yo.prototype.set=function(e,t){return ei(this,e).set(e,t),this};var ri=ii((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(ui(e))return Ko?Ko.call(e):"";var t=e+"";return"0"==t&&1/e==-go?"-0":t}(t);var n=[];return So.test(e)&&n.push(""),e.replace(Io,(function(e,t,r,o){n.push(r?o.replace(Oo,"$1"):t||e)})),n}));function oi(e){if("string"==typeof e||ui(e))return e;var t=e+"";return"0"==t&&1/e==-go?"-0":t}function ii(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(ii.Cache||Yo),n}function si(e,t){return e===t||e!=e&&t!=t}ii.Cache=Yo;var ai=Array.isArray;function ci(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ui(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&qo.call(e)==bo}var fi=o((function(e,t,n){return null==e?e:Qo(e,t,n)})),li="__lodash_hash_undefined__",hi=1/0,pi="[object Function]",di="[object GeneratorFunction]",yi="[object Symbol]",gi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,vi=/^\w*$/,mi=/^\./,_i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bi=/\\(\\)?/g,wi=/^\[object .+?Constructor\]$/,Ei="object"==typeof r&&r&&r.Object===Object&&r,Si="object"==typeof self&&self&&self.Object===Object&&self,Ii=Ei||Si||Function("return this")();var Oi=Array.prototype,Ai=Function.prototype,Ni=Object.prototype,Ti=Ii["__core-js_shared__"],Ri=function(){var e=/[^.]+$/.exec(Ti&&Ti.keys&&Ti.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Pi=Ai.toString,xi=Ni.hasOwnProperty,Li=Ni.toString,Ci=RegExp("^"+Pi.call(xi).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ki=Ii.Symbol,Di=Oi.splice,ji=Ji(Ii,"Map"),Ui=Ji(Object,"create"),Mi=ki?ki.prototype:void 0,qi=Mi?Mi.toString:void 0;function Wi(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Fi(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Bi(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function $i(e,t){for(var n,r,o=e.length;o--;)if((n=e[o][0])===(r=t)||n!=n&&r!=r)return o;return-1}function Hi(e){if(!es(e)||(t=e,Ri&&Ri in t))return!1;var t,n=function(e){var t=es(e)?Li.call(e):"";return t==pi||t==di}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Ci:wi;return n.test(function(e){if(null!=e){try{return Pi.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function Gi(e,t){e=function(e,t){return 1==t.length?e:function(e,t){for(var n=0,r=(t=Yi(t,e)?[t]:Ki(t)).length;null!=e&&n<r;)e=e[Xi(t[n++])];return n&&n==r?e:void 0}(e,function(e,t,n){var r=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(o);++r<o;)i[r]=e[r+t];return i}(t,0,-1))}(e,t=Yi(t,e)?[t]:Ki(t));var n,r,o=Xi((r=(n=t)?n.length:0)?n[r-1]:void 0);return!(null!=e&&xi.call(e,o))||delete e[o]}function Ki(e){return Qi(e)?e:Zi(e)}function Vi(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function Ji(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Hi(n)?n:void 0}function Yi(e,t){if(Qi(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!ts(e))||(vi.test(e)||!gi.test(e)||null!=t&&e in Object(t))}Wi.prototype.clear=function(){this.__data__=Ui?Ui(null):{}},Wi.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Wi.prototype.get=function(e){var t=this.__data__;if(Ui){var n=t[e];return n===li?void 0:n}return xi.call(t,e)?t[e]:void 0},Wi.prototype.has=function(e){var t=this.__data__;return Ui?void 0!==t[e]:xi.call(t,e)},Wi.prototype.set=function(e,t){return this.__data__[e]=Ui&&void 0===t?li:t,this},Fi.prototype.clear=function(){this.__data__=[]},Fi.prototype.delete=function(e){var t=this.__data__,n=$i(t,e);return!(n<0)&&(n==t.length-1?t.pop():Di.call(t,n,1),!0)},Fi.prototype.get=function(e){var t=this.__data__,n=$i(t,e);return n<0?void 0:t[n][1]},Fi.prototype.has=function(e){return $i(this.__data__,e)>-1},Fi.prototype.set=function(e,t){var n=this.__data__,r=$i(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Bi.prototype.clear=function(){this.__data__={hash:new Wi,map:new(ji||Fi),string:new Wi}},Bi.prototype.delete=function(e){return Vi(this,e).delete(e)},Bi.prototype.get=function(e){return Vi(this,e).get(e)},Bi.prototype.has=function(e){return Vi(this,e).has(e)},Bi.prototype.set=function(e,t){return Vi(this,e).set(e,t),this};var Zi=zi((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(ts(e))return qi?qi.call(e):"";var t=e+"";return"0"==t&&1/e==-hi?"-0":t}(t);var n=[];return mi.test(e)&&n.push(""),e.replace(_i,(function(e,t,r,o){n.push(r?o.replace(bi,"$1"):t||e)})),n}));function Xi(e){if("string"==typeof e||ts(e))return e;var t=e+"";return"0"==t&&1/e==-hi?"-0":t}function zi(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(zi.Cache||Bi),n}zi.Cache=Bi;var Qi=Array.isArray;function es(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ts(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&Li.call(e)==yi}var ns=o((function(e,t){return null==e||Gi(e,t)})),rs={exports:{}};!function(e,t){var n="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",s="[object Boolean]",a="[object Date]",c="[object Function]",u="[object GeneratorFunction]",f="[object Map]",l="[object Number]",h="[object Object]",p="[object Promise]",d="[object RegExp]",y="[object Set]",g="[object String]",v="[object Symbol]",m="[object WeakMap]",_="[object ArrayBuffer]",b="[object DataView]",w="[object Float32Array]",E="[object Float64Array]",S="[object Int8Array]",I="[object Int16Array]",O="[object Int32Array]",A="[object Uint8Array]",N="[object Uint8ClampedArray]",T="[object Uint16Array]",R="[object Uint32Array]",P=/\w*$/,x=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,C={};C[i]=C["[object Array]"]=C[_]=C[b]=C[s]=C[a]=C[w]=C[E]=C[S]=C[I]=C[O]=C[f]=C[l]=C[h]=C[d]=C[y]=C[g]=C[v]=C[A]=C[N]=C[T]=C[R]=!0,C["[object Error]"]=C[c]=C[m]=!1;var k="object"==typeof r&&r&&r.Object===Object&&r,D="object"==typeof self&&self&&self.Object===Object&&self,j=k||D||Function("return this")(),U=t&&!t.nodeType&&t,M=U&&e&&!e.nodeType&&e,q=M&&M.exports===U;function W(e,t){return e.set(t[0],t[1]),e}function F(e,t){return e.add(t),e}function B(e,t,n,r){var o=-1,i=e?e.length:0;for(r&&i&&(n=e[++o]);++o<i;)n=t(n,e[o],o,e);return n}function $(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function H(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function G(e,t){return function(n){return e(t(n))}}function K(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var V=Array.prototype,J=Function.prototype,Y=Object.prototype,Z=j["__core-js_shared__"],X=function(){var e=/[^.]+$/.exec(Z&&Z.keys&&Z.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),z=J.toString,Q=Y.hasOwnProperty,ee=Y.toString,te=RegExp("^"+z.call(Q).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ne=q?j.Buffer:void 0,re=j.Symbol,oe=j.Uint8Array,ie=G(Object.getPrototypeOf,Object),se=Object.create,ae=Y.propertyIsEnumerable,ce=V.splice,ue=Object.getOwnPropertySymbols,fe=ne?ne.isBuffer:void 0,le=G(Object.keys,Object),he=Ue(j,"DataView"),pe=Ue(j,"Map"),de=Ue(j,"Promise"),ye=Ue(j,"Set"),ge=Ue(j,"WeakMap"),ve=Ue(Object,"create"),me=Be(he),_e=Be(pe),be=Be(de),we=Be(ye),Ee=Be(ge),Se=re?re.prototype:void 0,Ie=Se?Se.valueOf:void 0;function Oe(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Ae(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Ne(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Te(e){this.__data__=new Ae(e)}function Re(e,t){var n=He(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Ge(e)}(e)&&Q.call(e,"callee")&&(!ae.call(e,"callee")||ee.call(e)==i)}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,o=!!r;for(var s in e)!t&&!Q.call(e,s)||o&&("length"==s||We(s,r))||n.push(s);return n}function Pe(e,t,n){var r=e[t];Q.call(e,t)&&$e(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function xe(e,t){for(var n=e.length;n--;)if($e(e[n][0],t))return n;return-1}function Le(e,t,n,r,o,p,m){var x;if(r&&(x=p?r(e,o,p,m):r(e)),void 0!==x)return x;if(!Je(e))return e;var L=He(e);if(L){if(x=function(e){var t=e.length,n=e.constructor(t);t&&"string"==typeof e[0]&&Q.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!t)return function(e,t){var n=-1,r=e.length;t||(t=Array(r));for(;++n<r;)t[n]=e[n];return t}(e,x)}else{var k=qe(e),D=k==c||k==u;if(Ke(e))return function(e,t){if(t)return e.slice();var n=new e.constructor(e.length);return e.copy(n),n}(e,t);if(k==h||k==i||D&&!p){if($(e))return p?e:{};if(x=function(e){return"function"!=typeof e.constructor||Fe(e)?{}:(t=ie(e),Je(t)?se(t):{});var t}(D?{}:e),!t)return function(e,t){return De(e,Me(e),t)}(e,function(e,t){return e&&De(t,Ye(t),e)}(x,e))}else{if(!C[k])return p?e:{};x=function(e,t,n,r){var o=e.constructor;switch(t){case _:return ke(e);case s:case a:return new o(+e);case b:return function(e,t){var n=t?ke(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,r);case w:case E:case S:case I:case O:case A:case N:case T:case R:return function(e,t){var n=t?ke(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}(e,r);case f:return function(e,t,n){var r=t?n(H(e),!0):H(e);return B(r,W,new e.constructor)}(e,r,n);case l:case g:return new o(e);case d:return function(e){var t=new e.constructor(e.source,P.exec(e));return t.lastIndex=e.lastIndex,t}(e);case y:return function(e,t,n){var r=t?n(K(e),!0):K(e);return B(r,F,new e.constructor)}(e,r,n);case v:return i=e,Ie?Object(Ie.call(i)):{}}var i}(e,k,Le,t)}}m||(m=new Te);var j=m.get(e);if(j)return j;if(m.set(e,x),!L)var U=n?function(e){return function(e,t,n){var r=t(e);return He(e)?r:function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}(r,n(e))}(e,Ye,Me)}(e):Ye(e);return function(e,t){for(var n=-1,r=e?e.length:0;++n<r&&!1!==t(e[n],n,e););}(U||e,(function(o,i){U&&(o=e[i=o]),Pe(x,i,Le(o,t,n,r,i,e,m))})),x}function Ce(e){return!(!Je(e)||(t=e,X&&X in t))&&(Ve(e)||$(e)?te:x).test(Be(e));var t}function ke(e){var t=new e.constructor(e.byteLength);return new oe(t).set(new oe(e)),t}function De(e,t,n,r){n||(n={});for(var o=-1,i=t.length;++o<i;){var s=t[o],a=r?r(n[s],e[s],s,n,e):void 0;Pe(n,s,void 0===a?e[s]:a)}return n}function je(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function Ue(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Ce(n)?n:void 0}Oe.prototype.clear=function(){this.__data__=ve?ve(null):{}},Oe.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Oe.prototype.get=function(e){var t=this.__data__;if(ve){var r=t[e];return r===n?void 0:r}return Q.call(t,e)?t[e]:void 0},Oe.prototype.has=function(e){var t=this.__data__;return ve?void 0!==t[e]:Q.call(t,e)},Oe.prototype.set=function(e,t){return this.__data__[e]=ve&&void 0===t?n:t,this},Ae.prototype.clear=function(){this.__data__=[]},Ae.prototype.delete=function(e){var t=this.__data__,n=xe(t,e);return!(n<0)&&(n==t.length-1?t.pop():ce.call(t,n,1),!0)},Ae.prototype.get=function(e){var t=this.__data__,n=xe(t,e);return n<0?void 0:t[n][1]},Ae.prototype.has=function(e){return xe(this.__data__,e)>-1},Ae.prototype.set=function(e,t){var n=this.__data__,r=xe(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Ne.prototype.clear=function(){this.__data__={hash:new Oe,map:new(pe||Ae),string:new Oe}},Ne.prototype.delete=function(e){return je(this,e).delete(e)},Ne.prototype.get=function(e){return je(this,e).get(e)},Ne.prototype.has=function(e){return je(this,e).has(e)},Ne.prototype.set=function(e,t){return je(this,e).set(e,t),this},Te.prototype.clear=function(){this.__data__=new Ae},Te.prototype.delete=function(e){return this.__data__.delete(e)},Te.prototype.get=function(e){return this.__data__.get(e)},Te.prototype.has=function(e){return this.__data__.has(e)},Te.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Ae){var r=n.__data__;if(!pe||r.length<199)return r.push([e,t]),this;n=this.__data__=new Ne(r)}return n.set(e,t),this};var Me=ue?G(ue,Object):function(){return[]},qe=function(e){return ee.call(e)};function We(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||L.test(e))&&e>-1&&e%1==0&&e<t}function Fe(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Y)}function Be(e){if(null!=e){try{return z.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function $e(e,t){return e===t||e!=e&&t!=t}(he&&qe(new he(new ArrayBuffer(1)))!=b||pe&&qe(new pe)!=f||de&&qe(de.resolve())!=p||ye&&qe(new ye)!=y||ge&&qe(new ge)!=m)&&(qe=function(e){var t=ee.call(e),n=t==h?e.constructor:void 0,r=n?Be(n):void 0;if(r)switch(r){case me:return b;case _e:return f;case be:return p;case we:return y;case Ee:return m}return t});var He=Array.isArray;function Ge(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=o}(e.length)&&!Ve(e)}var Ke=fe||function(){return!1};function Ve(e){var t=Je(e)?ee.call(e):"";return t==c||t==u}function Je(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ye(e){return Ge(e)?Re(e):function(e){if(!Fe(e))return le(e);var t=[];for(var n in Object(e))Q.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return Le(e,!0,!0)}}(rs,rs.exports);var os=o(rs.exports);function is(e){return void 0===e&&(e=""),(e?e+"_":"")+ +new Date+"_"+Math.random()}var ss,as=function(e){this.close=e.close,this.onChange=e.onChange,this.onError=e.onError,e.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return e.virtualClient}})},cs=function(e){var t,n,r=e.id,o=e.docChanges,i=e.docs,s=e.msgType,a=e.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return t||(t=JSON.parse(JSON.stringify(o))),t},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}})},us=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),fs=function(e){function t(t){var n=e.call(this,"Watch Error "+JSON.stringify(t.msgData)+" (requestid: "+t.requestId+")")||this;return n.isRealtimeErrorMessageError=!0,n.payload=t,n}return us(t,e),t}(Error),ls=function(e){return null==e?void 0:e.isRealtimeErrorMessageError},hs=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="timeout",t.payload=null,t.generic=!0,t}return us(t,e),t}(Error),ps=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="cancelled",t.payload=null,t.generic=!0,t}return us(t,e),t}(Error),ds=function(e){function t(t){var n=e.call(this,t.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: "+this.errCode+" "+(ys[this.errCode]||"")+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e}}}),n.errCode=t.errCode||"UNKNOWN_ERROR",n.errMsg=t.errMsg,n}return us(t,e),Object.defineProperty(t.prototype,"message",{get:function(){return"errCode: "+this.errCode+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e},enumerable:!1,configurable:!0}),t}(Error),ys={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"},gs=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},vs=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},ms=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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 e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};!function(e){e.LOGGINGIN="LOGGINGIN",e.INITING="INITING",e.REBUILDING="REBUILDING",e.ACTIVE="ACTIVE",e.ERRORED="ERRORED",e.CLOSING="CLOSING",e.CLOSED="CLOSED",e.PAUSED="PAUSED",e.RESUMING="RESUMING"}(ss||(ss={}));var bs=function(){function e(e){var t=this;this.watchStatus=ss.INITING,this._login=function(e,n){return vs(t,void 0,void 0,(function(){var t;return ms(this,(function(r){switch(r.label){case 0:return this.watchStatus=ss.LOGGINGIN,[4,this.login(e,n)];case 1:return t=r.sent(),this.envId||(this.envId=t.envId),[2,t]}}))}))},this.initWatch=function(e){return vs(t,void 0,void 0,(function(){var t,n=this;return ms(this,(function(r){switch(r.label){case 0:if(this._initWatchPromise)return[2,this._initWatchPromise];this._initWatchPromise=new Promise((function(t,r){return vs(n,void 0,void 0,(function(){var n,o,i,s,a,c,u,f,l,h;return ms(this,(function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),this.watchStatus===ss.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):[4,this._login(this.envId,e)];case 1:return n=p.sent().envId,this.watchStatus===ss.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(this.watchStatus=ss.INITING,o={watchId:this.watchId,requestId:is(),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=p.sent(),s=i.msgData,a=s.events,c=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:c-1,currentDocs:[]},a.length>0){for(u=0,f=a;u<f.length;u++)f[u].ID=c;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=c,l=new cs({id:c,docChanges:[],docs:[],type:"init"}),this.listener.onChange(l),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=ss.ACTIVE,this._availableRetries.INIT_WATCH=2,t(),[3,4];case 3:return h=p.sent(),this.handleWatchEstablishmentError(h,{operationName:"INIT_WATCH",resolve:t,reject:r}),[3,4];case 4:return[2]}}))}))})),t=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._initWatchPromise];case 2:return r.sent(),t=!0,[3,4];case 3:return this._initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch "+(t?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(e){return vs(t,void 0,void 0,(function(){var t,n=this;return ms(this,(function(r){switch(r.label){case 0:if(this._rebuildWatchPromise)return[2,this._rebuildWatchPromise];this._rebuildWatchPromise=new Promise((function(t,r){return vs(n,void 0,void 0,(function(){var n,o,i,s;return ms(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===ss.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):[4,this._login(this.envId,e)];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===ss.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):(this.watchStatus=ss.REBUILDING,o={watchId:this.watchId,requestId:is(),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=ss.ACTIVE,this._availableRetries.REBUILD_WATCH=2,t(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:t,reject:r}),[3,4];case 4:return[2]}}))}))})),t=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._rebuildWatchPromise];case 2:return r.sent(),t=!0,[3,4];case 3:return this._rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch "+(t?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(e,n){return vs(t,void 0,void 0,(function(){var t,r,o,i=this;return ms(this,(function(s){return t="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new ds({errCode:t?ys.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:ys.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),n.reject(e)},o=function(e){i.useRetryTicket(n.operationName)?t?(i._initWatchPromise=void 0,n.resolve(i.initWatch(e))):(i._rebuildWatchPromise=void 0,n.resolve(i.rebuildWatch(e))):r()},this.handleCommonError(e,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){return vs(i,void 0,void 0,(function(){var e,t=this;return ms(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),e=function(){return vs(t,void 0,void 0,(function(){return ms(this,(function(e){switch(e.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return e.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,e()];case 1:return r.sent(),[3,7];case 2:return[4,gs(100)];case 3:return r.sent(),this.watchStatus!==ss.PAUSED?[3,4]:(n.reject(new ps(n.operationName+" cancelled due to pause after unknownError")),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,e()];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 vs(t,void 0,void 0,(function(){var e,t,n;return ms(this,(function(r){switch(r.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==ss.ACTIVE)return this.watchStatus=ss.CLOSED,this.onWatchClose(this,e),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=ss.CLOSING,t={watchId:this.watchId,requestId:is(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=ss.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,e),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){t.clearACKSchedule(),t._ackTimeoutId=setTimeout((function(){t._waitExpectedTimeoutId?t.scheduleSendACK():t.sendACK()}),1e4)},this.clearACKSchedule=function(){t._ackTimeoutId&&clearTimeout(t._ackTimeoutId)},this.sendACK=function(){return vs(t,void 0,void 0,(function(){var e,t,n;return ms(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==ss.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(e={watchId:this.watchId,requestId:is(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:e})]):(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(t=r.sent(),ls(t))switch((n=t.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 ds({errCode:ys.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--,this.scheduleSendACK()):this.closeWithError(new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if(ls(e)){switch(e.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void t.onSignError(e);default:return void t.onNotRetryableError(e)}}else{if(function(e){return"timeout"===e.type}(e))return void t.onTimeoutError(e);if(function(e){return"cancelled"===e.type}(e))return void t.onCancelledError(e)}t.onUnknownError(e)},this.watchId="watchid_"+ +new Date+"_"+Math.random(),this.envId=e.envId,this.collectionName=e.collectionName,this.query=e.query,this.limit=e.limit,this.orderBy=e.orderBy,this.send=e.send,this.login=e.login,this.isWSConnected=e.isWSConnected,this.onceWSConnected=e.onceWSConnected,this.getWaitExpectedTimeoutLength=e.getWaitExpectedTimeoutLength,this.onWatchStart=e.onWatchStart,this.onWatchClose=e.onWatchClose,this.debug=e.debug,this._availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new as({close:this.closeWatch,onChange:e.onChange,onError:e.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return e.prototype.onMessage=function(e){var t=this;switch(this.watchStatus){case ss.PAUSED:if("ERROR"!==e.msgType)return;break;case ss.LOGGINGIN:case ss.INITING:case ss.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while "+this.watchStatus);case ss.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case ss.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(),e.msgType){case"NEXT_EVENT":console.warn("nextevent "+e.msgData.currEvent+" ignored",e),this.handleServerEvents(e);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<e.msgData.currEvent&&(this.sessionInfo.expectEventId=e.msgData.currEvent,this.clearWaitExpectedEvent(),this._waitExpectedTimeoutId=setTimeout((function(){t.rebuildWatch()}),this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength "+this.getWaitExpectedTimeoutLength()));break;case"ERROR":this.closeWithError(new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:e.msgData.code+" - "+e.msgData.message}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg "+e.msgType+": ",e)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},e.prototype.closeWithError=function(e){this.watchStatus=ss.ERRORED,this.clearACKSchedule(),this.listener.onError(e),this.onWatchClose(this,this.sessionInfo&&this.sessionInfo.queryID||""),console.log("[realtime] client closed ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.pause=function(){this.watchStatus=ss.PAUSED,console.log("[realtime] client paused ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.resume=function(){return vs(this,void 0,void 0,(function(){var e;return ms(this,(function(t){switch(t.label){case 0:this.watchStatus=ss.RESUMING,console.log("[realtime] client resuming with "+(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH")+" ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return t.sent(),console.log("[realtime] client successfully resumed ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),[3,4];case 3:return e=t.sent(),console.error("[realtime] client resume failed ("+this.collectionName+" "+this.query+") ("+this.watchId+")",e),[3,4];case 4:return[2]}}))}))},e.prototype.useRetryTicket=function(e){return!!(this._availableRetries[e]&&this._availableRetries[e]>0)&&(this._availableRetries[e]--,console.log("[realtime] "+e+" use a retry ticket, now only "+this._availableRetries[e]+" retry left"),!0)},e.prototype.handleServerEvents=function(e){return vs(this,void 0,void 0,(function(){var t;return ms(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this._handleServerEvents(e)];case 1:return n.sent(),this._postHandleServerEventsValidityCheck(e),[3,3];case 2:throw t=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",t),t;case 3:return[2]}}))}))},e.prototype._handleServerEvents=function(e){return vs(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,u,f,l,h;return ms(this,(function(p){switch(p.label){case 0:if(t=e.requestId,n=e.msgData.events,r=e.msgType,!n.length||!this.sessionInfo)return[2];o=this.sessionInfo;try{i=n.map(ws)}catch(e){return this.closeWithError(new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}s=_s(o.currentDocs),a=!1,c=function(n,c){var f,l,h,p,d,y,g,v,m,_,b;return ms(this,(function(w){switch(w.label){case 0:return f=i[n],o.currentEventId>=f.id?(!i[n-1]||f.id>i[n-1].id?console.warn("[realtime] duplicate event received, cur "+o.currentEventId+" but got "+f.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 "+t+")"),[2,"continue"]):[3,1];case 1:if(o.currentEventId!==f.id-1)return[3,2];switch(f.dataType){case"update":if(!f.doc)switch(f.queueType){case"update":case"dequeue":if(l=s.find((function(e){return e._id===f.docId})),l){if(y=os(l),f.updatedFields)for(d in f.updatedFields)fi(y,d,f.updatedFields[d]);if(f.removedFields)for(h=0,p=f.removedFields;h<p.length;h++)d=p[h],ns(y,d);f.doc=y}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw g=new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '+e.requestId+")"}),u.closeWithError(g),g}break;case"replace":if(!f.doc)throw g=new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '+e.requestId+")"}),u.closeWithError(g),g;break;case"remove":(y=s.find((function(e){return e._id===f.docId})))?f.doc=y:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!f.doc)switch(f.queueType){case"dequeue":(y=s.find((function(e){return e._id===f.docId})))?f.doc=y:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw g=new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '+e.requestId+")"}),u.closeWithError(g),g}}switch(f.queueType){case"init":a?s.push(f.doc):(a=!0,s=[f.doc]);break;case"enqueue":s.push(f.doc);break;case"dequeue":v=s.findIndex((function(e){return e._id===f.docId})),v>-1?s.splice(v,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":v=s.findIndex((function(e){return e._id===f.docId})),v>-1?s[v]=f.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===c-1||i[n+1]&&i[n+1].id!==f.id)&&(m=_s(s),_=i.slice(0,n+1).filter((function(e){return e.id===f.id})),u.sessionInfo.currentEventId=f.id,u.sessionInfo.currentDocs=s,b=new cs({id:f.id,docChanges:_,docs:m,msgType:r}),u.listener.onChange(b)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur "+u.sessionInfo.currentEventId+" but got "+f.id),[4,u.rebuildWatch()];case 3:return w.sent(),[2,{value:void 0}];case 4:return[2]}}))},u=this,f=0,l=i.length,p.label=1;case 1:return f<l?[5,c(f,l)]:[3,4];case 2:if("object"==typeof(h=p.sent()))return[2,h.value];p.label=3;case 3:return f++,[3,1];case 4:return[2]}}))}))},e.prototype._postHandleServerEventsValidityCheck=function(e){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<e.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")},e.prototype.clearWaitExpectedEvent=function(){this._waitExpectedTimeoutId&&(clearTimeout(this._waitExpectedTimeoutId),this._waitExpectedTimeoutId=void 0)},e}();function ws(e){var t={id:e.ID,dataType:e.DataType,queueType:e.QueueType,docId:e.DocID,doc:e.Doc&&"{}"!==e.Doc?JSON.parse(e.Doc):void 0};return"update"===e.DataType&&(e.UpdatedFields&&(t.updatedFields=JSON.parse(e.UpdatedFields)),(e.removedFields||e.RemovedFields)&&(t.removedFields=JSON.parse(e.removedFields))),t}var Es,Ss={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(e){e[e.NormalClosure=1e3]="NormalClosure",e[e.GoingAway=1001]="GoingAway",e[e.ProtocolError=1002]="ProtocolError",e[e.UnsupportedData=1003]="UnsupportedData",e[e.NoStatusReceived=1005]="NoStatusReceived",e[e.AbnormalClosure=1006]="AbnormalClosure",e[e.InvalidFramePayloadData=1007]="InvalidFramePayloadData",e[e.PolicyViolation=1008]="PolicyViolation",e[e.MessageTooBig=1009]="MessageTooBig",e[e.MissingExtension=1010]="MissingExtension",e[e.InternalError=1011]="InternalError",e[e.ServiceRestart=1012]="ServiceRestart",e[e.TryAgainLater=1013]="TryAgainLater",e[e.BadGateway=1014]="BadGateway",e[e.TLSHandshake=1015]="TLSHandshake",e[e.ReconnectWebSocket=3e3]="ReconnectWebSocket",e[e.NoRealtimeListeners=3001]="NoRealtimeListeners",e[e.HeartbeatPingError=3002]="HeartbeatPingError",e[e.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",e[e.NoAuthentication=3050]="NoAuthentication"}(Es||(Es={}));var Is=function(e,t){var n=Ss[e],r=n?n.name+", code "+e+", reason "+(t||n.description):"code "+e;return new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},Os=null,As="web";function Ns(){return Os}function Ts(){return As}function Rs(e){As=e}var Ps=function(){return Ps=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ps.apply(this,arguments)},xs=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Ls=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},Cs=1,ks=function(){function e(e){var t=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(e){return xs(t,void 0,void 0,(function(){var t=this;return Ls(this,(function(n){return[2,new Promise((function(n,r){return xs(t,void 0,void 0,(function(){var t,o,i,s,a,c,u,f=this;return Ls(this,(function(l){switch(l.label){case 0:o=!1,i=!1,s=function(e){o=!0,t&&clearTimeout(t),n(e)},a=function(e){i=!0,t&&clearTimeout(t),r(e)},e.timeout&&(t=setTimeout((function(){return xs(f,void 0,void 0,(function(){return Ls(this,(function(e){switch(e.label){case 0:return o&&i?[3,2]:[4,gs(0)];case 1:e.sent(),o&&i||a(new hs("wsclient.send timedout")),e.label=2;case 2:return[2]}}))}))}),e.timeout)),l.label=1;case 1:return l.trys.push([1,8,,9]),this._wsInitPromise?[4,this._wsInitPromise]:[3,3];case 2:l.sent(),l.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!==Cs)return a(new Error("ws readyState invalid: "+this._ws.readyState+", can not send message")),[2];e.waitResponse&&this._wsResponseWait.set(e.msg.requestId,{resolve:s,reject:a,skipOnMessage:e.skipOnMessage}),l.label=4;case 4:return l.trys.push([4,6,,7]),[4,this._ws.send(JSON.stringify(e.msg))];case 5:return l.sent(),e.waitResponse||s(),[3,7];case 6:return(c=l.sent())&&(a(c),e.waitResponse&&this._wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return u=l.sent(),a(u),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(e){t._virtualWSClient.forEach((function(t){t.closeWithError(e)}))},this.pauseClients=function(e){(e||t._virtualWSClient).forEach((function(e){e.pause()}))},this.resumeClients=function(e){(e||t._virtualWSClient).forEach((function(e){e.resume()}))},this.initWebSocketConnection=function(e,n){return void 0===n&&(n=t._maxReconnect),xs(t,void 0,void 0,(function(){var t=this;return Ls(this,(function(r){switch(r.label){case 0:if(e&&this._reconnectState)return[2];if(e&&(this._reconnectState=!0),this._wsInitPromise)return[2,this._wsInitPromise];e&&this.pauseClients(),this.close(Es.ReconnectWebSocket),this._wsInitPromise=new Promise((function(r,o){return xs(t,void 0,void 0,(function(){var t,i,s=this;return Ls(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return t=a.sent(),[4,new Promise((function(e){var n=t.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=Ns();s._ws=r?new r(n):new WebSocket(n),e()}))];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(),e&&(this.resumeClients(),this._reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),n>0?(!0,this._wsInitPromise=void 0,[4,gs(this._reconnectInterval)]):[3,9];case 7:a.sent(),e&&(this._reconnectState=!1),a.label=8;case 8:return r(this.initWebSocketConnection(e,n-1)),[3,10];case 9:o(i),e&&this.closeAllClients(new ds({errCode:ys.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(e){return(0,e.resolve)()})),[3,5];case 3:return r.sent(),this._wsReadySubsribers.forEach((function(e){return(0,e.reject)()})),[3,5];case 4:return this._wsInitPromise=void 0,this._wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(e,n){if(!t._ws)throw new Error("can not initWebSocketEvent, ws not exists");var r=!1;t._ws.onopen=function(t){console.warn("[realtime] ws event: open",t),r=!0,e()},t._ws.onerror=function(e){t._logins=new Map,r?(console.error("[realtime] ws event: error",e),t.clearHeartbeat(),t._virtualWSClient.forEach((function(t){return t.closeWithError(new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:e}))}))):(console.error("[realtime] ws open failed with ws event: error",e),n(e))},t._ws.onclose=function(e){switch(console.warn("[realtime] ws event: close",e),t._logins=new Map,t.clearHeartbeat(),e.code){case Es.ReconnectWebSocket:case Es.NoRealtimeListeners:break;case Es.HeartbeatPingError:case Es.HeartbeatPongTimeoutError:case Es.NormalClosure:case Es.AbnormalClosure:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(Is(e.code));break;case Es.NoAuthentication:t.closeAllClients(Is(e.code,e.reason));break;default:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(Is(e.code))}},t._ws.onmessage=function(e){var n,r=e.data;t.heartbeat();try{n=JSON.parse(r)}catch(e){throw new Error("[realtime] onMessage parse res.data error: "+e)}if("ERROR"===n.msgType){var o=null;t._virtualWSClient.forEach((function(e){e.watchId===n.watchId&&(o=e)})),o&&o.listener.onError(n)}var i=t._wsResponseWait.get(n.requestId);if(i){try{"ERROR"===n.msgType?i.reject(new fs(n)):i.resolve(n)}catch(e){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",e)}finally{t._wsResponseWait.delete(n.requestId)}if(i.skipOnMessage)return}if("PONG"!==n.msgType){var s=n.watchId&&t._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=t._queryIdClientMap.get(n.msgData.queryID))&&s.onMessage(n);break;default:for(var a=0,c=Array.from(t._watchIdClientMap.entries());a<c.length;a++){c[a][1].onMessage(n);break}}}else if(t._lastPingSendTS){var u=Date.now()-t._lastPingSendTS;if(u>1e4)return void console.warn("[realtime] untrusted rtt observed: "+u);t._rttObserved.length>=3&&t._rttObserved.splice(0,t._rttObserved.length-3+1),t._rttObserved.push(u)}},t.heartbeat()}))},this.isWSConnected=function(){return Boolean(t._ws&&t._ws.readyState===Cs)},this.onceWSConnected=function(){return xs(t,void 0,void 0,(function(){var e=this;return Ls(this,(function(t){return this.isWSConnected()?[2]:this._wsInitPromise?[2,this._wsInitPromise]:[2,new Promise((function(t,n){e._wsReadySubsribers.push({resolve:t,reject:n})}))]}))}))},this.webLogin=function(e,n){return xs(t,void 0,void 0,(function(){var t,r,o,i,s,a,c,u,f=this;return Ls(this,(function(l){switch(l.label){case 0:if(!n)if(e){if(t=this._logins.get(e)){if(t.loggedIn&&t.loginResult)return[2,t.loginResult];if(t.loggingInPromise)return[2,t.loggingInPromise]}}else if(null==(r=this._logins.get(""))?void 0:r.loggingInPromise)return[2,r.loggingInPromise];o=new Promise((function(e,t){return xs(f,void 0,void 0,(function(){var n,r,o,i,s;return Ls(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:is(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:Ts(),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?t(new Error(i.msgData.code+" "+i.msgData.message)):e({envId:n.envId}),[3,4];case 3:return s=a.sent(),t(s),[3,4];case 4:return[2]}}))}))})),i=e&&this._logins.get(e),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this._logins.set(e||"",i)),l.label=1;case 1:return l.trys.push([1,3,,4]),[4,o];case 2:if(a=l.sent(),(c=e&&this._logins.get(e))&&c===i&&c.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(c){if(c.loggedIn&&c.loginResult)return[2,c.loginResult];if(c.loggingInPromise)return[2,c.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw u=l.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,u;case 4:return[2]}}))}))},this.getWsSign=function(){return xs(t,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Ls(this,(function(a){switch(a.label){case 0:return this._wsSign&&this._wsSign.expiredTs>Date.now()?[2,this._wsSign]:(e=Date.now()+6e4,[4,this._context.appConfig.request.send("auth.wsWebSign",{runtime:Ts()})]);case 1:if((t=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: "+t.code);if(t.data)return n=t.data,r=n.signStr,o=n.wsUrl,i=n.secretVersion,s=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:i,envId:s,expiredTs:e}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return t._rttObserved.length?t._rttObserved.reduce((function(e,t){return e+t}))/t._rttObserved.length*1.5:5e3},this.ping=function(){return xs(t,void 0,void 0,(function(){var e;return Ls(this,(function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:is(),msgType:"PING",msgData:null},[4,this.send({msg:e})];case 1:return t.sent(),[2]}}))}))},this.onWatchStart=function(e,n){t._queryIdClientMap.set(n,e)},this.onWatchClose=function(e,n){n&&t._queryIdClientMap.delete(n),t._watchIdClientMap.delete(e.watchId),t._virtualWSClient.delete(e),t._virtualWSClient.size||t.close(Es.NoRealtimeListeners)},this._maxReconnect=e.maxReconnect||5,this._reconnectInterval=e.reconnectInterval||1e4,this._context=e.context}return e.prototype.clearHeartbeat=function(){this._pingTimeoutId&&clearTimeout(this._pingTimeoutId),this._pongTimeoutId&&clearTimeout(this._pongTimeoutId)},e.prototype.close=function(e){this.clearHeartbeat(),this._ws&&(this._ws.close(e,Ss[e].name),this._ws=void 0)},e.prototype.watch=function(e){this._ws||this._wsInitPromise||this.initWebSocketConnection(!1);var t=new bs(Ps(Ps({},e),{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(t),this._watchIdClientMap.set(t.watchId,t),t.listener},e.prototype.heartbeat=function(e){var t=this;this.clearHeartbeat(),this._pingTimeoutId=setTimeout((function(){return xs(t,void 0,void 0,(function(){var e=this;return Ls(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this._ws&&this._ws.readyState===Cs?(this._lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return t.sent(),this._pingFailed=0,this._pongTimeoutId=setTimeout((function(){console.error("pong timed out"),e._pongMissed<2?(e._pongMissed++,e.heartbeat(!0)):e.initWebSocketConnection(!0)}),this._context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return t.sent(),this._pingFailed<2?(this._pingFailed++,this.heartbeat()):this.close(Es.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),e?0:this._context.appConfig.realtimePingInterval)},e}(),Ds={target:"database",entity:function(){var e,t=this.platform,n=t.adapter,r=t.runtime;e=n.wsClass,Os=e,Rs(r)}},js={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=ks}};try{cloudbase.registerComponent(js),cloudbase.registerHook(Ds)}catch(e){}var Us=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Ms=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},qs=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Ws=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},Fs=Pe.ERRORS,Bs=Pe.COMMUNITY_SITE_URL,$s=Te.catchErrorsDecorator,Hs="analytics",Gs=["mall"];var Ks,Vs,Js=new(function(){function e(){}return e.prototype.analytics=function(e){return qs(this,void 0,void 0,(function(){var t,n,r;return Ws(this,(function(o){if(!function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))return!1;var t=e.report_data,n=e.report_type;return!1!==Gs.includes(n)&&"Object"===Object.prototype.toString.call(t).slice(8,-1)&&!(void 0!==t.action_time&&!Number.isInteger(t.action_time))&&"string"==typeof t.action_type}(e))throw new Error(JSON.stringify({code:Fs.INVALID_PARAMS,msg:"["+Hs+".analytics] invalid report data"}));return"analytics.report",t=void 0===e.report_data.action_time?Math.floor(Date.now()/1e3):e.report_data.action_time,n={analytics_scene:e.report_type,analytics_data:Object.assign({},e.report_data,{action_time:t})},r={requestData:n},this.request.send("analytics.report",r),[2]}))}))},Us([$s({customInfo:{className:"Cloudbase",methodName:"analytics"},title:"上报调用失败",messages:["请确认以下各项:"," 1 - 调用 analytics() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Bs]}),Ms("design:type",Function),Ms("design:paramtypes",[Object]),Ms("design:returntype",Promise)],e.prototype,"analytics",null),e}()),Ys={name:Hs,entity:{analytics:Js.analytics}};try{cloudbase.registerComponent(Ys)}catch(e){}!function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined"}(Vs||(Vs={}));var Zs,Xs,zs="Number",Qs="Object",ea="Array",ta="GeoPoint",na="GeoLineString",ra="GeoPolygon",oa="GeoMultiPoint",ia="GeoMultiLineString",sa="GeoMultiPolygon",aa="Date",ca="ServerDate",ua="BsonDate",fa=["desc","asc"],la=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(Zs||(Zs={})),(Ks={})[Zs.eq]="$eq",Ks[Zs.lt]="$lt",Ks[Zs.lte]="$lte",Ks[Zs.gt]="$gt",Ks[Zs.gte]="$gte",function(e){e.WHERE="WHERE",e.DOC="DOC"}(Xs||(Xs={}));var ha=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),pa=[],da={},ya=function(e){function t(t,n){if(n!==da)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return ha(t,e),t.for=function(e){for(var n=0,r=pa.length;n<r;n++)if(pa[n].target===e)return pa[n].instance;var o=new t(e,da);return pa.push({target:e,instance:o}),o},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),ga=ya,va=ga.for("UNSET_FIELD_NAME"),ma=ga.for("UPDATE_COMMAND"),_a=ga.for("QUERY_COMMAND"),ba=ga.for("LOGIC_COMMAND"),wa=ga.for("GEO_POINT"),Ea=ga.for("SYMBOL_GEO_LINE_STRING"),Sa=ga.for("SYMBOL_GEO_POLYGON"),Ia=ga.for("SYMBOL_GEO_MULTI_POINT"),Oa=ga.for("SYMBOL_GEO_MULTI_LINE_STRING"),Aa=ga.for("SYMBOL_GEO_MULTI_POLYGON"),Na=ga.for("SERVER_DATE"),Ta=ga.for("REGEXP"),Ra=function(){function e(e){var t=(void 0===e?{}:e).offset,n=void 0===t?0:t;this.offset=n}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return Na},enumerable:!0,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function Pa(e){return new Ra(e)}var xa,La=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},Ca=function(){function e(){}return e.formatResDocumentData=function(t){return t.map((function(t){return e.formatField(t)}))},e.formatField=function(t){var n=Object.keys(t),r={};return Array.isArray(t)&&(r=[]),n.forEach((function(n){var o,i=t[n];switch(e.whichType(i)){case ta:o=new Ba(i.coordinates[0],i.coordinates[1]);break;case na:o=new Ha(i.coordinates.map((function(e){return new Ba(e[0],e[1])})));break;case ra:o=new Ka(i.coordinates.map((function(e){return new Ha(e.map((function(e){var t=La(e,2),n=t[0],r=t[1];return new Ba(n,r)})))})));break;case oa:o=new Ja(i.coordinates.map((function(e){return new Ba(e[0],e[1])})));break;case ia:o=new Za(i.coordinates.map((function(e){return new Ha(e.map((function(e){var t=La(e,2),n=t[0],r=t[1];return new Ba(n,r)})))})));break;case sa:o=new za(i.coordinates.map((function(e){return new Ka(e.map((function(e){return new Ha(e.map((function(e){var t=La(e,2),n=t[0],r=t[1];return new Ba(n,r)})))})))})));break;case aa:o=new Date(1e3*i.$timestamp);break;case Qs:case ea:o=e.formatField(i);break;case ca:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o})),r},e.whichType=function(e){var t=Object.prototype.toString.call(e).slice(8,-1);if(t===aa)return ua;if(t===Qs){if(e instanceof Ba)return ta;if(e instanceof Date)return aa;if(e instanceof Ra)return ca;e.$timestamp?t=aa:e.$date?t=ca:Ba.validate(e)?t=ta:Ha.validate(e)?t=na:Ka.validate(e)?t=ra:Ja.validate(e)?t=oa:Za.validate(e)?t=ia:za.validate(e)&&(t=sa)}return t},e.generateDocId=function(){for(var e="ABCDEFabcdef0123456789",t="",n=0;n<24;n++)t+=e.charAt(Math.floor(22*Math.random()));return t},e}(),ka=function(){function e(){}return e.isGeopoint=function(e,t){if(Ca.whichType(t)!==zs)throw new Error("Geo Point must be number type");var n=Math.abs(t);if("latitude"===e&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===e&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},e.isInteger=function(e,t){if(!Number.isInteger(t))throw new Error(e+Vs.IntergerError);return!0},e.isFieldOrder=function(e){if(-1===fa.indexOf(e))throw new Error(Vs.DirectionError);return!0},e.isFieldPath=function(e){if(!/^[a-zA-Z0-9-_\.]/.test(e))throw new Error;return!0},e.isOperator=function(e){if(-1===la.indexOf(e))throw new Error(Vs.OpStrError);return!0},e.isCollName=function(e){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e))throw new Error(Vs.CollNameError);return!0},e.isDocID=function(e){if(!/^([a-fA-F0-9]){24}$/.test(e))throw new Error(Vs.DocIDError);return!0},e}(),Da=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},ja=function(e){return"object"===Da(e)},Ua=function(e){return"number"===Da(e)},Ma=function(e){return Array.isArray(e)},qa=function(e){return"date"===Da(e)},Wa=function(e){return"regexp"===Da(e)},Fa=function(e){return e&&e._internalType instanceof ya},Ba=function(){function e(e,t){ka.isGeopoint("longitude",e),ka.isGeopoint("latitude",t),this.longitude=e,this.latitude=t}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Point",coordinates:[this.longitude,this.latitude]},t},e.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},e.prototype.toReadableString=function(){return"["+this.longitude+","+this.latitude+"]"},e.validate=function(e){return"Point"===e.type&&Ma(e.coordinates)&&ka.isGeopoint("longitude",e.coordinates[0])&&ka.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return wa},enumerable:!0,configurable:!0}),e}(),$a=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ha=function(){function e(e){if(!Ma(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(e.length<2)throw new Error('"points" must contain 2 points at least');e.forEach((function(e){if(!(e instanceof Ba))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e+"[]")})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,n;if("LineString"!==e.type||!Ma(e.coordinates))return!1;try{for(var r=$a(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!Ua(i[0])||!Ua(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},e.isClosed=function(e){var t=e.points[0],n=e.points[e.points.length-1];if(t.latitude===n.latitude&&t.longitude===n.longitude)return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Ea},enumerable:!0,configurable:!0}),e}(),Ga=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ka=function(){function e(e){if(!Ma(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof Ha))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]");if(!Ha.isClosed(e))throw new Error("LineString "+e.points.map((function(e){return e.toReadableString()}))+" is not a closed cycle")})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,n,r,o;if("Polygon"!==e.type||!Ma(e.coordinates))return!1;try{for(var i=Ga(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var c=(r=void 0,Ga(a)),u=c.next();!u.done;u=c.next()){var f=u.value;if(!Ua(f[0])||!Ua(f[1]))return!1}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return!0},e.isCloseLineString=function(e){var t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Aa},enumerable:!0,configurable:!0}),e}(),Va=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ja=function(){function e(e){if(!Ma(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(0===e.length)throw new Error('"points" must contain 1 point at least');e.forEach((function(e){if(!(e instanceof Ba))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e+"[]")})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,n;if("MultiPoint"!==e.type||!Ma(e.coordinates))return!1;try{for(var r=Va(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!Ua(i[0])||!Ua(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Ia},enumerable:!0,configurable:!0}),e}(),Ya=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Za=function(){function e(e){if(!Ma(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof Ha))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]")})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,n,r,o;if("MultiLineString"!==e.type||!Ma(e.coordinates))return!1;try{for(var i=Ya(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var c=(r=void 0,Ya(a)),u=c.next();!u.done;u=c.next()){var f=u.value;if(!Ua(f[0])||!Ua(f[1]))return!1}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Oa},enumerable:!0,configurable:!0}),e}(),Xa=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},za=function(){function e(e){var t,n;if(!Ma(e))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof e);if(0===e.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=Xa(e),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof Ka))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof i+"[]")}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.polygons=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))},t},e.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))}},e.validate=function(e){var t,n,r,o,i,s;if("MultiPolygon"!==e.type||!Ma(e.coordinates))return!1;try{for(var a=Xa(e.coordinates),c=a.next();!c.done;c=a.next()){var u=c.value;try{for(var f=(r=void 0,Xa(u)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,Xa(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!Ua(y[0])||!Ua(y[1]))return!1}}catch(e){i={error:e}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Sa},enumerable:!0,configurable:!0}),e}(),Qa=Object.freeze({__proto__:null,LineString:Ha,MultiLineString:Za,MultiPoint:Ja,MultiPolygon:za,Point:Ba,Polygon:Ka}),ec=function(){var e;if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e};!function(e){e.SET="set",e.REMOVE="remove",e.INC="inc",e.MUL="mul",e.PUSH="push",e.PULL="pull",e.PULL_ALL="pullAll",e.POP="pop",e.SHIFT="shift",e.UNSHIFT="unshift",e.ADD_TO_SET="addToSet",e.BIT="bit",e.RENAME="rename",e.MAX="max",e.MIN="min"}(xa||(xa={}));var tc,nc=function(){function e(e,t,n){this._internalType=ma,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||va}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function rc(e){return e&&e instanceof nc&&e._internalType===ma}!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(tc||(tc={}));var oc=function(){function e(e,t,n){if(this._internalType=ba,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||va,this.fieldName!==va)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var r=0,o=t.length;r<o;r++){(ic(i=t[r])||uc(i))&&(t[r]=i._setFieldName(this.fieldName))}}else{var i;(ic(i=t)||uc(i))&&(t=i._setFieldName(this.fieldName))}}return e.prototype._setFieldName=function(t){var n=this.operands.map((function(n){return n instanceof e?n._setFieldName(t):n}));return new e(this.operator,n,t)},e.prototype.and=function(){var t=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return t.unshift(this),new e(tc.AND,t,this.fieldName)},e.prototype.or=function(){var t=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return t.unshift(this),new e(tc.OR,t,this.fieldName)},e}();function ic(e){return e&&e instanceof oc&&e._internalType===ba}var sc,ac=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){e.EQ="eq",e.NEQ="neq",e.GT="gt",e.GTE="gte",e.LT="lt",e.LTE="lte",e.IN="in",e.NIN="nin",e.ALL="all",e.ELEM_MATCH="elemMatch",e.EXISTS="exists",e.SIZE="size",e.MOD="mod",e.GEO_NEAR="geoNear",e.GEO_WITHIN="geoWithin",e.GEO_INTERSECTS="geoIntersects"}(sc||(sc={}));var cc=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.operator=t,o._internalType=_a,o}return ac(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case sc.IN:case sc.NIN:return(e={})["$"+this.operator]=this.operands,e;default:return(t={})["$"+this.operator]=this.operands[0],t}},t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t.prototype.eq=function(e){var n=new t(sc.EQ,[e],this.fieldName);return this.and(n)},t.prototype.neq=function(e){var n=new t(sc.NEQ,[e],this.fieldName);return this.and(n)},t.prototype.gt=function(e){var n=new t(sc.GT,[e],this.fieldName);return this.and(n)},t.prototype.gte=function(e){var n=new t(sc.GTE,[e],this.fieldName);return this.and(n)},t.prototype.lt=function(e){var n=new t(sc.LT,[e],this.fieldName);return this.and(n)},t.prototype.lte=function(e){var n=new t(sc.LTE,[e],this.fieldName);return this.and(n)},t.prototype.in=function(e){var n=new t(sc.IN,e,this.fieldName);return this.and(n)},t.prototype.nin=function(e){var n=new t(sc.NIN,e,this.fieldName);return this.and(n)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof Ba))throw new TypeError('"geometry" must be of type Point. Received type '+typeof e.geometry);if(void 0!==e.maxDistance&&!Ua(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof e.maxDistance);if(void 0!==e.minDistance&&!Ua(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof e.minDistance);var n=new t(sc.GEO_NEAR,[e],this.fieldName);return this.and(n)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof za||e.geometry instanceof Ka))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof e.geometry);var n=new t(sc.GEO_WITHIN,[e],this.fieldName);return this.and(n)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof Ba||e.geometry instanceof Ha||e.geometry instanceof Ka||e.geometry instanceof Ja||e.geometry instanceof Za||e.geometry instanceof za))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof e.geometry);var n=new t(sc.GEO_INTERSECTS,[e],this.fieldName);return this.and(n)},t}(oc);function uc(e){return e&&e instanceof cc&&e._internalType===_a}function fc(e){return uc(e)}var lc={};for(var hc in sc)lc[hc]="$"+hc;for(var hc in tc)lc[hc]="$"+hc;for(var hc in xa)lc[hc]="$"+hc;function pc(e){return lc[e]||"$"+e}lc[sc.NEQ]="$ne",lc[xa.REMOVE]="$unset",lc[xa.SHIFT]="$pop",lc[xa.UNSHIFT]="$push";var dc=function(){return dc=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},dc.apply(this,arguments)},yc=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},gc=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(yc(arguments[t]));return e};function vc(e){return mc(e,[e])}function mc(e,t){if(!Fa(e)){if(qa(e))return{$date:+e};if(Wa(e))return{$regex:e.source,$options:e.flags};if(Ma(e))return e.map((function(e){if(t.indexOf(e)>-1)throw new Error("Cannot convert circular structure to JSON");return mc(e,gc(t,[e]))}));if(ja(e)){var n=dc({},e);for(var r in n){if(t.indexOf(n[r])>-1)throw new Error("Cannot convert circular structure to JSON");n[r]=mc(n[r],gc(t,[n[r]]))}return n}return e}switch(e._internalType){case wa:return e.toJSON();case Na:case Ta:return e.parse();default:return e.toJSON?e.toJSON():e}}var _c=function(){return _c=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},_c.apply(this,arguments)},bc=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},wc=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(bc(arguments[t]));return e};function Ec(e,t,n,r){var o=_c({},e);for(var i in e)if(!/^\$/.test(i)){var s=e[i];if(s&&ja(s)&&!t(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Ec(s,t,wc(n,[i]),wc(r,[s]));o[i]=a;var c=!1;for(var u in a)/^\$/.test(u)?c=!0:(o[i+"."+u]=a[u],delete o[i][u]);c||delete o[i]}}return o}function Sc(e){return Ec(e,Oc,[],[e])}function Ic(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Ma(e[r])?e[r].push(t[r]):ja(e[r])?ja(t[r])?Object.assign(e[r],t[r]):(console.warn("unmergable condition, query is object but condition is "+Da(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+Da(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]}function Oc(e){return Fa(e)||qa(e)||Wa(e)}function Ac(e){return vc(e)}var Nc=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.prototype.encodeUpdate=function(e){return rc(e)?this.encodeUpdateCommand(e):"object"===Da(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===va)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case xa.PUSH:case xa.PULL:case xa.PULL_ALL:case xa.POP:case xa.SHIFT:case xa.UNSHIFT:case xa.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,n,r,o,i=pc(e.operator);return e.operator===xa.REMOVE?((t={})[i]=((n={})[e.fieldName]="",n),t):((r={})[i]=((o={})[e.fieldName]=e.operands[0],o),r)},e.prototype.encodeArrayUpdateCommand=function(e){var t,n,r,o,i,s,a,c,u,f,l=pc(e.operator);switch(e.operator){case xa.PUSH:var h=void 0;return h=Ma(e.operands)?{$each:e.operands.map(Ac)}:e.operands,(t={})[l]=((n={})[e.fieldName]=h,n),t;case xa.UNSHIFT:h={$each:e.operands.map(Ac),$position:0};return(r={})[l]=((o={})[e.fieldName]=h,o),r;case xa.POP:return(i={})[l]=((s={})[e.fieldName]=1,s),i;case xa.SHIFT:return(a={})[l]=((c={})[e.fieldName]=-1,c),a;default:return(u={})[l]=((f={})[e.fieldName]=Ac(e.operands),f),u}},e.prototype.encodeUpdateObject=function(e){var t=Sc(e);for(var n in t)if(!/^\$/.test(n)){var r=t[n];if(rc(r)){t[n]=r._setFieldName(n),Ic(t,this.encodeUpdateCommand(t[n]),n)}else{t[n]=r=Ac(r);var o=new nc(xa.SET,[r],n);Ic(t,this.encodeUpdateCommand(o),n)}}return t},e}(),Tc={};function Rc(e){if(!bf.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return Tc[t]||(Tc[t]=new bf.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new bf.reqClass(e.config)}}})),Tc[t]}var Pc=function(){return Pc=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Pc.apply(this,arguments)},xc=function(){function e(e,t,n,r){var o=this;void 0===r&&(r={}),this.watch=function(e){return Rc(o._db).watch(Pc(Pc({},e),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=e,this._coll=t,this.id=n,this.request=new bf.reqClass(this._db.config),this.projection=r}return e.prototype.create=function(e,t){t=t||ec();var n={collectionName:this._coll,data:vc(e)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(e){e.code?t(0,e):t(0,{id:e.data._id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.set=function(e,t){if(t=t||ec(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(e){if("object"==typeof e)for(var t in e)e[t]instanceof nc?n=!0:"object"==typeof e[t]&&r(e[t])};if(r(e),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:Xs.DOC,data:vc(e),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.update=function(e,t){if(t=t||ec(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:Nc.encode(e),query:n,queryType:Xs.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.remove=function(e){e=e||ec();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:Xs.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(t){t.code?e(0,t):e(0,{deleted:t.data.deleted,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},e.prototype.get=function(e){e=e||ec();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:Xs.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n=Ca.formatResDocumentData(t.data.list);e(0,{data:n,requestId:t.requestId,total:t.TotalCount,limit:t.Limit,offset:t.Offset})}})).catch((function(t){e(t)})),e.promise},e.prototype.field=function(t){for(var n in t)t[n]?t[n]=1:t[n]=0;return new e(this._db,this._coll,this.id,t)},e}(),Lc=function(){function e(){}return e.encode=function(e){return(new Cc).encodeQuery(e)},e}(),Cc=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var n;return Oc(e)?ic(e)?this.encodeLogicCommand(e):uc(e)?this.encodeQueryCommand(e):((n={})[t]=this.encodeQueryObject(e),n):ja(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regex:e.source,$options:e.flags}},e.prototype.encodeLogicCommand=function(e){var t,n,r,o,i,s,a,c=this;switch(e.operator){case tc.NOR:case tc.AND:case tc.OR:var u=pc(e.operator),f=e.operands.map((function(t){return c.encodeQuery(t,e.fieldName)}));return(t={})[u]=f,t;case tc.NOT:u=pc(e.operator);var l=e.operands[0];if(Wa(l))return(n={})[e.fieldName]=((r={})[u]=this.encodeRegExp(l),r),n;f=this.encodeQuery(l)[e.fieldName];return(o={})[e.fieldName]=((i={})[u]=f,i),o;default:u=pc(e.operator);if(1===e.operands.length){var h=this.encodeQuery(e.operands[0]);return(s={})[u]=h,s}f=e.operands.map(this.encodeQuery.bind(this));return(a={})[u]=f,a}},e.prototype.encodeQueryCommand=function(e){return fc(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,n,r,o,i,s,a,c,u;if(e.fieldName===va)throw new Error("Cannot encode a comparison command with unset field name");var f=pc(e.operator);switch(e.operator){case sc.EQ:case sc.NEQ:case sc.LT:case sc.LTE:case sc.GT:case sc.GTE:case sc.ELEM_MATCH:case sc.EXISTS:case sc.SIZE:case sc.MOD:return(t={})[e.fieldName]=((n={})[f]=Ac(e.operands[0]),n),t;case sc.IN:case sc.NIN:case sc.ALL:return(r={})[e.fieldName]=((o={})[f]=Ac(e.operands),o),r;case sc.GEO_NEAR:var l=e.operands[0];return(i={})[e.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case sc.GEO_WITHIN:l=e.operands[0];return(s={})[e.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case sc.GEO_INTERSECTS:l=e.operands[0];return(a={})[e.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(c={})[e.fieldName]=((u={})[f]=Ac(e.operands[0]),u),c}},e.prototype.encodeQueryObject=function(e){var t=Sc(e);for(var n in t){var r=t[n];if(ic(r)){t[n]=r._setFieldName(n);var o=this.encodeLogicCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else if(fc(r)){t[n]=r._setFieldName(n);o=this.encodeComparisonCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else Oc(r)&&(t[n]=Ac(r))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Ma(e[r])?e[r]=e[r].concat(t[r]):ja(e[r])?ja(t[r])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is "+Da(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+Da(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]},e}(),kc=function(){return kc=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},kc.apply(this,arguments)},Dc=function(){function e(e,t,n,r,o){var i=this;this.watch=function(e){return Rc(i._db).watch(kc(kc({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(e,t){return e[t.field]=t.direction,e}),{}):void 0}))},this._db=e,this._coll=t,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=new bf.reqClass(this._db.config)}return e.prototype.get=function(e){e=e||ec();var t=[];this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)}));var n={collectionName:this._coll,queryType:Xs.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),t.length>0&&(n.order=t),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n={data:Ca.formatResDocumentData(t.data.list),requestId:t.requestId};t.TotalCount&&(n.total=t.TotalCount),t.Limit&&(n.limit=t.Limit),t.Offset&&(n.offset=t.Offset),e(0,n)}})).catch((function(t){e(t)})),e.promise},e.prototype.count=function(e){e=e||ec();var t={collectionName:this._coll,queryType:Xs.WHERE};return this._fieldFilters&&(t.query=this._fieldFilters),this._request.send("database.countDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,total:t.data.total})})).catch((function(t){e(t)})),e.promise},e.prototype.where=function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))throw Error(Vs.QueryParamTypeError);var n=Object.keys(t),r=n.some((function(e){return void 0!==t[e]}));if(n.length&&!r)throw Error(Vs.QueryParamValueError);return new e(this._db,this._coll,Lc.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,n){ka.isFieldPath(t),ka.isFieldOrder(n);var r={field:t,direction:n},o=this._fieldOrders.concat(r);return new e(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},e.prototype.limit=function(t){ka.isInteger("limit",t);var n=kc({},this._queryOptions);return n.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.skip=function(t){ka.isInteger("offset",t);var n=kc({},this._queryOptions);return n.offset=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.update=function(e,t){if(t=t||ec(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:Xs.WHERE,multi:!0,merge:!0,upsert:!1,data:Nc.encode(e)};return this._request.send("database.updateDocument",n).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,updated:e.data.updated,upsertId:e.data.upsert_id})})).catch((function(e){t(e)})),t.promise},e.prototype.field=function(t){for(var n in t)t[n]?"object"!=typeof t[n]&&(t[n]=1):t[n]=0;var r=kc({},this._queryOptions);return r.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.remove=function(e){e=e||ec(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var t={collectionName:this._coll,query:Lc.encode(this._fieldFilters),queryType:Xs.WHERE,multi:!0};return this._request.send("database.deleteDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,deleted:t.data.deleted})})).catch((function(t){e(t)})),e.promise},e}(),jc=function(e,t){return jc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},jc(e,t)};function Uc(e,t){function n(){this.constructor=e}jc(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Mc=function(e){function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return Uc(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),t}(Error),qc=function(e){function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return Uc(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),t}(TypeError);function Wc(e){return e&&e.Math==Math&&e}function Fc(){return Wc("object"==typeof globalThis&&globalThis)||Wc("object"==typeof window&&window)||Wc("object"==typeof self&&self)||Wc("object"==typeof global&&global)||Function("return this")()}var Bc=function(t){var n,r="object"==typeof(n=Fc()).navigator&&"ReactNative"===n.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(r);for(var o=e.alloc(t),i=0;i<t;++i)o[i]=Math.floor(256*Math.random());return o},$c=function(){var e=void 0;try{e=require("crypto").randomBytes}catch(e){}return e||Bc}();function Hc(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)}function Gc(e){return"object"==typeof e&&null!==e}function Kc(e,t){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return n||(console.warn(t),n=!0),e.apply(this,r)}}function Vc(t){if(ArrayBuffer.isView(t))return e.from(t.buffer,t.byteOffset,t.byteLength);if(n=t,["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(n)))return e.from(t);var n;throw new qc("Must use either Buffer or TypedArray")}var Jc=/^(?:[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,Yc=function(e){return"string"==typeof e&&Jc.test(e)},Zc=function(t){if(!Yc(t))throw new qc('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var n=t.replace(/-/g,"");return e.from(n,"hex")},Xc=function(e,t){return void 0===t&&(t=!0),t?e.toString("hex",0,4)+"-"+e.toString("hex",4,6)+"-"+e.toString("hex",6,8)+"-"+e.toString("hex",8,10)+"-"+e.toString("hex",10,16):e.toString("hex")},zc=Math.pow(2,53),Qc=-Math.pow(2,53),eu=function(){function t(n,r){if(!(this instanceof t))return new t(n,r);if(!(null==n||"string"==typeof n||ArrayBuffer.isView(n)||n instanceof ArrayBuffer||Array.isArray(n)))throw new qc("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=r?r:t.BSON_BINARY_SUBTYPE_DEFAULT,null==n?(this.buffer=e.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof n?this.buffer=e.from(n,"binary"):Array.isArray(n)?this.buffer=e.from(n):this.buffer=Vc(n),this.position=this.buffer.byteLength)}return t.prototype.put=function(n){if("string"==typeof n&&1!==n.length)throw new qc("only accepts single character String");if("number"!=typeof n&&1!==n.length)throw new qc("only accepts single character Uint8Array or Array");var r;if((r="string"==typeof n?n.charCodeAt(0):"number"==typeof n?n:n[0])<0||r>255)throw new qc("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=r;else{var o=e.alloc(t.BUFFER_SIZE+this.buffer.length);this.buffer.copy(o,0,0,this.buffer.length),this.buffer=o,this.buffer[this.position++]=r}},t.prototype.write=function(t,n){if(n="number"==typeof n?n:this.position,this.buffer.length<n+t.length){var r=e.alloc(this.buffer.length+t.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r}ArrayBuffer.isView(t)?(this.buffer.set(Vc(t),n),this.position=n+t.byteLength>this.position?n+t.length:this.position):"string"==typeof t&&(this.buffer.write(t,n,t.length,"binary"),this.position=n+t.length>this.position?n+t.length:this.position)},t.prototype.read=function(e,t){return t=t&&t>0?t:this.position,this.buffer.slice(e,e+t)},t.prototype.value=function(e){return(e=!!e)&&this.buffer.length===this.position?this.buffer:e?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(e){return this.buffer.toString(e)},t.prototype.toExtendedJSON=function(e){e=e||{};var t=this.buffer.toString("base64"),n=Number(this.sub_type).toString(16);return e.legacy?{$binary:t,$type:1===n.length?"0"+n:n}:{$binary:{base64:t,subType:1===n.length?"0"+n:n}}},t.prototype.toUUID=function(){if(this.sub_type===t.SUBTYPE_UUID)return new tu(this.buffer.slice(0,this.position));throw new Mc('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(n,r){var o,i;if(r=r||{},"$binary"in n?r.legacy&&"string"==typeof n.$binary&&"$type"in n?(i=n.$type?parseInt(n.$type,16):0,o=e.from(n.$binary,"base64")):"string"!=typeof n.$binary&&(i=n.$binary.subType?parseInt(n.$binary.subType,16):0,o=e.from(n.$binary.base64,"base64")):"$uuid"in n&&(i=4,o=Zc(n.$uuid)),!o)throw new qc("Unexpected Binary Extended JSON format ".concat(JSON.stringify(n)));return 4===i?new tu(o):new t(o,i)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var e=this.value(!0);return'new Binary(Buffer.from("'.concat(e.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(eu.prototype,"_bsontype",{value:"Binary"});var tu=function(t){function n(r){var o,i,s=this;if(null==r)o=n.generate();else if(r instanceof n)o=e.from(r.buffer),i=r.__id;else if(ArrayBuffer.isView(r)&&16===r.byteLength)o=Vc(r);else{if("string"!=typeof r)throw new qc("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).");o=Zc(r)}return(s=t.call(this,o,4)||this).__id=i,s}return Uc(n,t),Object.defineProperty(n.prototype,"id",{get:function(){return this.buffer},set:function(e){this.buffer=e,n.cacheHexString&&(this.__id=Xc(e))},enumerable:!1,configurable:!0}),n.prototype.toHexString=function(e){if(void 0===e&&(e=!0),n.cacheHexString&&this.__id)return this.__id;var t=Xc(this.id,e);return n.cacheHexString&&(this.__id=t),t},n.prototype.toString=function(e){return e?this.id.toString(e):this.toHexString()},n.prototype.toJSON=function(){return this.toHexString()},n.prototype.equals=function(e){if(!e)return!1;if(e instanceof n)return e.id.equals(this.id);try{return new n(e).id.equals(this.id)}catch(e){return!1}},n.prototype.toBinary=function(){return new eu(this.id,eu.SUBTYPE_UUID)},n.generate=function(){var t=$c(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,e.from(t)},n.isValid=function(e){return!!e&&(e instanceof n||("string"==typeof e?Yc(e):!!Hc(e)&&(16===e.length&&(64==(240&e[6])&&128==(128&e[8])))))},n.createFromHexString=function(e){return new n(Zc(e))},n.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},n.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},n}(eu),nu=function(){function e(t,n){if(!(this instanceof e))return new e(t,n);this.code=t,this.scope=n}return e.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},e.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},e.fromExtendedJSON=function(t){return new e(t.$code,t.$scope)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var e=this.toJSON();return'new Code("'.concat(String(e.code),'"').concat(e.scope?", ".concat(JSON.stringify(e.scope)):"",")")},e}();Object.defineProperty(nu.prototype,"_bsontype",{value:"Code"});var ru=function(){function e(t,n,r,o){if(!(this instanceof e))return new e(t,n,r,o);var i=t.split(".");2===i.length&&(r=i.shift(),t=i.shift()),this.collection=t,this.oid=n,this.db=r,this.fields=o||{}}return Object.defineProperty(e.prototype,"namespace",{get:function(){return this.collection},set:function(e){this.collection=e},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){var e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(e.$db=this.db),e},e.prototype.toExtendedJSON=function(e){e=e||{};var t={$ref:this.collection,$id:this.oid};return e.legacy?t:(this.db&&(t.$db=this.db),t=Object.assign(t,this.fields))},e.fromExtendedJSON=function(t){var n=Object.assign({},t);return delete n.$ref,delete n.$id,delete n.$db,new e(t.$ref,t.$id,t.$db,n)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var e=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return'new DBRef("'.concat(this.namespace,'", new ObjectId("').concat(String(e),'")').concat(this.db?', "'.concat(this.db,'"'):"",")")},e}();Object.defineProperty(ru.prototype,"_bsontype",{value:"DBRef"});var ou=void 0;try{ou=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(Ks){}var iu=4294967296,su=0x10000000000000000,au=su/2,cu={},uu={},fu=function(){function e(t,n,r){if(void 0===t&&(t=0),!(this instanceof e))return new e(t,n,r);"bigint"==typeof t?Object.assign(this,e.fromBigInt(t,!!n)):"string"==typeof t?Object.assign(this,e.fromString(t,!!n)):(this.low=0|t,this.high=0|n,this.unsigned=!!r),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return e.fromBits=function(t,n,r){return new e(t,n,r)},e.fromInt=function(t,n){var r,o,i;return n?(i=0<=(t>>>=0)&&t<256)&&(o=uu[t])?o:(r=e.fromBits(t,(0|t)<0?-1:0,!0),i&&(uu[t]=r),r):(i=-128<=(t|=0)&&t<128)&&(o=cu[t])?o:(r=e.fromBits(t,t<0?-1:0,!1),i&&(cu[t]=r),r)},e.fromNumber=function(t,n){if(isNaN(t))return n?e.UZERO:e.ZERO;if(n){if(t<0)return e.UZERO;if(t>=su)return e.MAX_UNSIGNED_VALUE}else{if(t<=-au)return e.MIN_VALUE;if(t+1>=au)return e.MAX_VALUE}return t<0?e.fromNumber(-t,n).neg():e.fromBits(t%iu|0,t/iu|0,n)},e.fromBigInt=function(t,n){return e.fromString(t.toString(),n)},e.fromString=function(t,n,r){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return e.ZERO;if("number"==typeof n?(r=n,n=!1):n=!!n,(r=r||10)<2||36<r)throw RangeError("radix");var o;if((o=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===o)return e.fromString(t.substring(1),n,r).neg();for(var i=e.fromNumber(Math.pow(r,8)),s=e.ZERO,a=0;a<t.length;a+=8){var c=Math.min(8,t.length-a),u=parseInt(t.substring(a,a+c),r);if(c<8){var f=e.fromNumber(Math.pow(r,c));s=s.mul(f).add(e.fromNumber(u))}else s=(s=s.mul(i)).add(e.fromNumber(u))}return s.unsigned=n,s},e.fromBytes=function(t,n,r){return r?e.fromBytesLE(t,n):e.fromBytesBE(t,n)},e.fromBytesLE=function(t,n){return new e(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,n)},e.fromBytesBE=function(t,n){return new e(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],n)},e.isLong=function(e){return Gc(e)&&!0===e.__isLong__},e.fromValue=function(t,n){return"number"==typeof t?e.fromNumber(t,n):"string"==typeof t?e.fromString(t,n):e.fromBits(t.low,t.high,"boolean"==typeof n?n:t.unsigned)},e.prototype.add=function(t){e.isLong(t)||(t=e.fromValue(t));var n=this.high>>>16,r=65535&this.high,o=this.low>>>16,i=65535&this.low,s=t.high>>>16,a=65535&t.high,c=t.low>>>16,u=0,f=0,l=0,h=0;return l+=(h+=i+(65535&t.low))>>>16,h&=65535,f+=(l+=o+c)>>>16,l&=65535,u+=(f+=r+a)>>>16,f&=65535,u+=n+s,u&=65535,e.fromBits(l<<16|h,u<<16|f,this.unsigned)},e.prototype.and=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)},e.prototype.compare=function(t){if(e.isLong(t)||(t=e.fromValue(t)),this.eq(t))return 0;var n=this.isNegative(),r=t.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},e.prototype.comp=function(e){return this.compare(e)},e.prototype.divide=function(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw Error("division by zero");if(ou){if(!this.unsigned&&-2147483648===this.high&&-1===t.low&&-1===t.high)return this;var n=(this.unsigned?ou.div_u:ou.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(n,ou.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;var r,o,i;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return e.UZERO;if(t.gt(this.shru(1)))return e.UONE;i=e.UZERO}else{if(this.eq(e.MIN_VALUE))return t.eq(e.ONE)||t.eq(e.NEG_ONE)?e.MIN_VALUE:t.eq(e.MIN_VALUE)?e.ONE:(r=this.shr(1).div(t).shl(1)).eq(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(o=this.sub(t.mul(r)),i=r.add(o.div(t)));if(t.eq(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();i=e.ZERO}for(o=this;o.gte(t);){r=Math.max(1,Math.floor(o.toNumber()/t.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),a=s<=48?1:Math.pow(2,s-48),c=e.fromNumber(r),u=c.mul(t);u.isNegative()||u.gt(o);)r-=a,u=(c=e.fromNumber(r,this.unsigned)).mul(t);c.isZero()&&(c=e.ONE),i=i.add(c),o=o.sub(u)}return i},e.prototype.div=function(e){return this.divide(e)},e.prototype.equals=function(t){return e.isLong(t)||(t=e.fromValue(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},e.prototype.eq=function(e){return this.equals(e)},e.prototype.getHighBits=function(){return this.high},e.prototype.getHighBitsUnsigned=function(){return this.high>>>0},e.prototype.getLowBits=function(){return this.low},e.prototype.getLowBitsUnsigned=function(){return this.low>>>0},e.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(e.MIN_VALUE)?64:this.neg().getNumBitsAbs();var t,n=0!==this.high?this.high:this.low;for(t=31;t>0&&0==(n&1<<t);t--);return 0!==this.high?t+33:t+1},e.prototype.greaterThan=function(e){return this.comp(e)>0},e.prototype.gt=function(e){return this.greaterThan(e)},e.prototype.greaterThanOrEqual=function(e){return this.comp(e)>=0},e.prototype.gte=function(e){return this.greaterThanOrEqual(e)},e.prototype.ge=function(e){return this.greaterThanOrEqual(e)},e.prototype.isEven=function(){return 0==(1&this.low)},e.prototype.isNegative=function(){return!this.unsigned&&this.high<0},e.prototype.isOdd=function(){return 1==(1&this.low)},e.prototype.isPositive=function(){return this.unsigned||this.high>=0},e.prototype.isZero=function(){return 0===this.high&&0===this.low},e.prototype.lessThan=function(e){return this.comp(e)<0},e.prototype.lt=function(e){return this.lessThan(e)},e.prototype.lessThanOrEqual=function(e){return this.comp(e)<=0},e.prototype.lte=function(e){return this.lessThanOrEqual(e)},e.prototype.modulo=function(t){if(e.isLong(t)||(t=e.fromValue(t)),ou){var n=(this.unsigned?ou.rem_u:ou.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(n,ou.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))},e.prototype.mod=function(e){return this.modulo(e)},e.prototype.rem=function(e){return this.modulo(e)},e.prototype.multiply=function(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),ou){var n=ou.mul(this.low,this.high,t.low,t.high);return e.fromBits(n,ou.get_high(),this.unsigned)}if(t.isZero())return e.ZERO;if(this.eq(e.MIN_VALUE))return t.isOdd()?e.MIN_VALUE:e.ZERO;if(t.eq(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(e.TWO_PWR_24)&&t.lt(e.TWO_PWR_24))return e.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);var r=this.high>>>16,o=65535&this.high,i=this.low>>>16,s=65535&this.low,a=t.high>>>16,c=65535&t.high,u=t.low>>>16,f=65535&t.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*u)>>>16,p&=65535,l+=(h+=o*f)>>>16,h&=65535,l+=(h+=i*u)>>>16,h&=65535,l+=(h+=s*c)>>>16,h&=65535,l+=r*f+o*u+i*c+s*a,l&=65535,e.fromBits(p<<16|d,l<<16|h,this.unsigned)},e.prototype.mul=function(e){return this.multiply(e)},e.prototype.negate=function(){return!this.unsigned&&this.eq(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)},e.prototype.neg=function(){return this.negate()},e.prototype.not=function(){return e.fromBits(~this.low,~this.high,this.unsigned)},e.prototype.notEquals=function(e){return!this.equals(e)},e.prototype.neq=function(e){return this.notEquals(e)},e.prototype.ne=function(e){return this.notEquals(e)},e.prototype.or=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)},e.prototype.shiftLeft=function(t){return e.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?e.fromBits(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):e.fromBits(0,this.low<<t-32,this.unsigned)},e.prototype.shl=function(e){return this.shiftLeft(e)},e.prototype.shiftRight=function(t){return e.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?e.fromBits(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):e.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},e.prototype.shr=function(e){return this.shiftRight(e)},e.prototype.shiftRightUnsigned=function(t){if(e.isLong(t)&&(t=t.toInt()),0===(t&=63))return this;var n=this.high;if(t<32){var r=this.low;return e.fromBits(r>>>t|n<<32-t,n>>>t,this.unsigned)}return 32===t?e.fromBits(n,0,this.unsigned):e.fromBits(n>>>t-32,0,this.unsigned)},e.prototype.shr_u=function(e){return this.shiftRightUnsigned(e)},e.prototype.shru=function(e){return this.shiftRightUnsigned(e)},e.prototype.subtract=function(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.neg())},e.prototype.sub=function(e){return this.subtract(e)},e.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},e.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*iu+(this.low>>>0):this.high*iu+(this.low>>>0)},e.prototype.toBigInt=function(){return BigInt(this.toString())},e.prototype.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},e.prototype.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},e.prototype.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},e.prototype.toSigned=function(){return this.unsigned?e.fromBits(this.low,this.high,!1):this},e.prototype.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(e.MIN_VALUE)){var n=e.fromNumber(t),r=this.div(n),o=r.mul(n).sub(this);return r.toString(t)+o.toInt().toString(t)}return"-"+this.neg().toString(t)}for(var i=e.fromNumber(Math.pow(t,6),this.unsigned),s=this,a="";;){var c=s.div(i),u=(s.sub(c.mul(i)).toInt()>>>0).toString(t);if((s=c).isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}},e.prototype.toUnsigned=function(){return this.unsigned?this:e.fromBits(this.low,this.high,!0)},e.prototype.xor=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low^t.low,this.high^t.high,this.unsigned)},e.prototype.eqz=function(){return this.isZero()},e.prototype.le=function(e){return this.lessThanOrEqual(e)},e.prototype.toExtendedJSON=function(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}},e.fromExtendedJSON=function(t,n){var r=e.fromString(t.$numberLong);return n&&n.relaxed?r.toNumber():r},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new Long("'.concat(this.toString(),'"').concat(this.unsigned?", true":"",")")},e.TWO_PWR_24=e.fromInt(16777216),e.MAX_UNSIGNED_VALUE=e.fromBits(-1,-1,!0),e.ZERO=e.fromInt(0),e.UZERO=e.fromInt(0,!0),e.ONE=e.fromInt(1),e.UONE=e.fromInt(1,!0),e.NEG_ONE=e.fromInt(-1),e.MAX_VALUE=e.fromBits(-1,2147483647,!1),e.MIN_VALUE=e.fromBits(0,-2147483648,!1),e}();Object.defineProperty(fu.prototype,"__isLong__",{value:!0}),Object.defineProperty(fu.prototype,"_bsontype",{value:"Long"});var lu=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,hu=/^(\+|-)?(Infinity|inf)$/i,pu=/^(\+|-)?NaN$/i,du=6111,yu=-6176,gu=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),vu=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),mu=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),_u=/^([-+])?(\d+)?$/;function bu(e){return!isNaN(parseInt(e,10))}function wu(e){var t=fu.fromNumber(1e9),n=fu.fromNumber(0);if(!(e.parts[0]||e.parts[1]||e.parts[2]||e.parts[3]))return{quotient:e,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new fu(e.parts[r],0)),e.parts[r]=n.div(t).low,n=n.modulo(t);return{quotient:e,rem:n}}function Eu(e,t){throw new qc('"'.concat(e,'" is not a valid Decimal128 string - ').concat(t))}var Su=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!Hc(e))throw new qc("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new qc("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(n){var r,o=!1,i=!1,s=!1,a=0,c=0,u=0,f=0,l=0,h=[0],p=0,d=0,y=0,g=0,v=0,m=0,_=new fu(0,0),b=new fu(0,0),w=0;if(n.length>=7e3)throw new qc(n+" not a valid Decimal128 string");var E=n.match(lu),S=n.match(hu),I=n.match(pu);if(!E&&!S&&!I||0===n.length)throw new qc(n+" not a valid Decimal128 string");if(E){var O=E[2],A=E[4],N=E[5],T=E[6];A&&void 0===T&&Eu(n,"missing exponent power"),A&&void 0===O&&Eu(n,"missing exponent base"),void 0===A&&(N||T)&&Eu(n,"missing e before exponent")}if("+"!==n[w]&&"-"!==n[w]||(o="-"===n[w++]),!bu(n[w])&&"."!==n[w]){if("i"===n[w]||"I"===n[w])return new t(e.from(o?vu:mu));if("N"===n[w])return new t(e.from(gu))}for(;bu(n[w])||"."===n[w];)"."!==n[w]?(p<34&&("0"!==n[w]||s)&&(s||(l=c),s=!0,h[d++]=parseInt(n[w],10),p+=1),s&&(u+=1),i&&(f+=1),c+=1,w+=1):(i&&Eu(n,"contains multiple periods"),i=!0,w+=1);if(i&&!c)throw new qc(n+" not a valid Decimal128 string");if("e"===n[w]||"E"===n[w]){var R=n.substr(++w).match(_u);if(!R||!R[2])return new t(e.from(gu));v=parseInt(R[0],10),w+=R[0].length}if(n[w])return new t(e.from(gu));if(y=0,p){if(g=p-1,1!==(a=u))for(;0===h[l+a-1];)a-=1}else y=0,g=0,h[0]=0,u=1,p=1,a=0;for(v<=f&&f-v>16384?v=yu:v-=f;v>du;){if((g+=1)-y>34){if(h.join("").match(/^0+$/)){v=du;break}Eu(n,"overflow")}v-=1}for(;v<yu||p<u;){if(0===g&&a<p){v=yu,a=0;break}if(p<u?u-=1:g-=1,v<du)v+=1;else{if(h.join("").match(/^0+$/)){v=du;break}Eu(n,"overflow")}}if(g-y+1<a){var P=c;i&&(l+=1,P+=1),o&&(l+=1,P+=1);var x=parseInt(n[l+g+1],10),L=0;if(x>=5&&(L=1,5===x))for(L=h[g]%2==1?1:0,m=l+g+2;m<P;m++)if(parseInt(n[m],10)){L=1;break}if(L)for(var C=g;C>=0;C--)if(++h[C]>9&&(h[C]=0,0===C)){if(!(v<du))return new t(e.from(o?vu:mu));v+=1,h[C]=1}}if(_=fu.fromNumber(0),b=fu.fromNumber(0),0===a)_=fu.fromNumber(0),b=fu.fromNumber(0);else if(g-y<17){C=y;for(b=fu.fromNumber(h[C++]),_=new fu(0,0);C<=g;C++)b=(b=b.multiply(fu.fromNumber(10))).add(fu.fromNumber(h[C]))}else{C=y;for(_=fu.fromNumber(h[C++]);C<=g-17;C++)_=(_=_.multiply(fu.fromNumber(10))).add(fu.fromNumber(h[C]));for(b=fu.fromNumber(h[C++]);C<=g;C++)b=(b=b.multiply(fu.fromNumber(10))).add(fu.fromNumber(h[C]))}var k,D,j,U,M=function(e,t){if(!e&&!t)return{high:fu.fromNumber(0),low:fu.fromNumber(0)};var n=e.shiftRightUnsigned(32),r=new fu(e.getLowBits(),0),o=t.shiftRightUnsigned(32),i=new fu(t.getLowBits(),0),s=n.multiply(o),a=n.multiply(i),c=r.multiply(o),u=r.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new fu(a.getLowBits(),0).add(c).add(u.shiftRightUnsigned(32)),{high:s=s.add(a.shiftRightUnsigned(32)),low:u=a.shiftLeft(32).add(new fu(u.getLowBits(),0))}}(_,fu.fromString("100000000000000000"));M.low=M.low.add(b),k=M.low,D=b,j=k.high>>>0,U=D.high>>>0,(j<U||j===U&&k.low>>>0<D.low>>>0)&&(M.high=M.high.add(fu.fromNumber(1))),r=v+6176;var q={low:fu.fromNumber(0),high:fu.fromNumber(0)};M.high.shiftRightUnsigned(49).and(fu.fromNumber(1)).equals(fu.fromNumber(1))?(q.high=q.high.or(fu.fromNumber(3).shiftLeft(61)),q.high=q.high.or(fu.fromNumber(r).and(fu.fromNumber(16383).shiftLeft(47))),q.high=q.high.or(M.high.and(fu.fromNumber(0x7fffffffffff)))):(q.high=q.high.or(fu.fromNumber(16383&r).shiftLeft(49)),q.high=q.high.or(M.high.and(fu.fromNumber(562949953421311)))),q.low=M.low,o&&(q.high=q.high.or(fu.fromString("9223372036854775808")));var W=e.alloc(16);return w=0,W[w++]=255&q.low.low,W[w++]=q.low.low>>8&255,W[w++]=q.low.low>>16&255,W[w++]=q.low.low>>24&255,W[w++]=255&q.low.high,W[w++]=q.low.high>>8&255,W[w++]=q.low.high>>16&255,W[w++]=q.low.high>>24&255,W[w++]=255&q.high.low,W[w++]=q.high.low>>8&255,W[w++]=q.high.low>>16&255,W[w++]=q.high.low>>24&255,W[w++]=255&q.high.high,W[w++]=q.high.high>>8&255,W[w++]=q.high.high>>16&255,W[w++]=q.high.high>>24&255,new t(W)},t.prototype.toString=function(){for(var e,t=0,n=new Array(36),r=0;r<n.length;r++)n[r]=0;var o,i,s,a=0,c=!1,u={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 fu(h,p),high:new fu(d,y)}.high.lessThan(fu.ZERO)&&f.push("-");var g=y>>26&31;if(g>>3==3){if(30===g)return f.join("")+"Infinity";if(31===g)return"NaN";e=y>>15&16383,o=8+(y>>14&1)}else o=y>>14&7,e=y>>17&16383;var v=e-6176;if(u.parts[0]=(16383&y)+((15&o)<<14),u.parts[1]=d,u.parts[2]=p,u.parts[3]=h,0===u.parts[0]&&0===u.parts[1]&&0===u.parts[2]&&0===u.parts[3])c=!0;else for(s=3;s>=0;s--){var m=0,_=wu(u);if(u=_.quotient,m=_.rem.low)for(i=8;i>=0;i--)n[9*s+i]=m%10,m=Math.floor(m/10)}if(c)t=1,n[a]=0;else for(t=36;!n[a];)t-=1,a+=1;var b=t-1+v;if(b>=34||b<=-7||v>0){if(t>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++])),(t-=1)&&f.push(".");for(r=0;r<t;r++)f.push("".concat(n[a++]));f.push("E"),b>0?f.push("+".concat(b)):f.push("".concat(b))}else if(v>=0)for(r=0;r<t;r++)f.push("".concat(n[a++]));else{var w=t+v;if(w>0)for(r=0;r<w;r++)f.push("".concat(n[a++]));else f.push("0");for(f.push(".");w++<0;)f.push("0");for(r=0;r<t-Math.max(w-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(Su.prototype,"_bsontype",{value:"Decimal128"});var Iu=function(){function e(t){if(!(this instanceof e))return new e(t);t instanceof Number&&(t=t.valueOf()),this.value=+t}return e.prototype.valueOf=function(){return this.value},e.prototype.toJSON=function(){return this.value},e.prototype.toString=function(e){return this.value.toString(e)},e.prototype.toExtendedJSON=function(e){return e&&(e.legacy||e.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-".concat(this.value.toFixed(1))}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}},e.fromExtendedJSON=function(t,n){var r=parseFloat(t.$numberDouble);return n&&n.relaxed?r:new e(r)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var e=this.toExtendedJSON();return"new Double(".concat(e.$numberDouble,")")},e}();Object.defineProperty(Iu.prototype,"_bsontype",{value:"Double"});var Ou=function(){function e(t){if(!(this instanceof e))return new e(t);t instanceof Number&&(t=t.valueOf()),this.value=0|+t}return e.prototype.valueOf=function(){return this.value},e.prototype.toString=function(e){return this.value.toString(e)},e.prototype.toJSON=function(){return this.value},e.prototype.toExtendedJSON=function(e){return e&&(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}},e.fromExtendedJSON=function(t,n){return n&&n.relaxed?parseInt(t.$numberInt,10):new e(t.$numberInt)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Int32(".concat(this.valueOf(),")")},e}();Object.defineProperty(Ou.prototype,"_bsontype",{value:"Int32"});var Au=function(){function e(){if(!(this instanceof e))return new e}return e.prototype.toExtendedJSON=function(){return{$maxKey:1}},e.fromExtendedJSON=function(){return new e},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new MaxKey()"},e}();Object.defineProperty(Au.prototype,"_bsontype",{value:"MaxKey"});var Nu=function(){function e(){if(!(this instanceof e))return new e}return e.prototype.toExtendedJSON=function(){return{$minKey:1}},e.fromExtendedJSON=function(){return new e},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new MinKey()"},e}();Object.defineProperty(Nu.prototype,"_bsontype",{value:"MinKey"});var Tu=new RegExp("^[0-9a-fA-F]{24}$"),Ru=null,Pu=Symbol("id"),xu=function(){function t(n){if(!(this instanceof t))return new t(n);var r;if("object"==typeof n&&n&&"id"in n){if("string"!=typeof n.id&&!ArrayBuffer.isView(n.id))throw new qc("Argument passed in must have an id that is of type string or Buffer");r="toHexString"in n&&"function"==typeof n.toHexString?e.from(n.toHexString(),"hex"):n.id}else r=n;if(null==r||"number"==typeof r)this[Pu]=t.generate("number"==typeof r?r:void 0);else if(ArrayBuffer.isView(r)&&12===r.byteLength)this[Pu]=r instanceof e?r:Vc(r);else{if("string"!=typeof r)throw new qc("Argument passed in does not match the accepted types");if(12===r.length){var o=e.from(r);if(12!==o.byteLength)throw new qc("Argument passed in must be a string of 12 bytes");this[Pu]=o}else{if(24!==r.length||!Tu.test(r))throw new qc("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[Pu]=e.from(r,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[Pu]},set:function(e){this[Pu]=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(e){this.id.writeUInt32BE(e,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(n){"number"!=typeof n&&(n=Math.floor(Date.now()/1e3));var r=t.getInc(),o=e.alloc(12);return o.writeUInt32BE(n,0),null===Ru&&(Ru=$c(5)),o[4]=Ru[0],o[5]=Ru[1],o[6]=Ru[2],o[7]=Ru[3],o[8]=Ru[4],o[11]=255&r,o[10]=r>>8&255,o[9]=r>>16&255,o},t.prototype.toString=function(e){return e?this.id.toString(e):this.toHexString()},t.prototype.toJSON=function(){return this.toHexString()},t.prototype.equals=function(n){if(null==n)return!1;if(n instanceof t)return this[Pu][11]===n[Pu][11]&&this[Pu].equals(n[Pu]);if("string"==typeof n&&t.isValid(n)&&12===n.length&&Hc(this.id))return n===e.prototype.toString.call(this.id,"latin1");if("string"==typeof n&&t.isValid(n)&&24===n.length)return n.toLowerCase()===this.toHexString();if("string"==typeof n&&t.isValid(n)&&12===n.length)return e.from(n).equals(this.id);if("object"==typeof n&&"toHexString"in n&&"function"==typeof n.toHexString){var r=n.toHexString(),o=this.toHexString().toLowerCase();return"string"==typeof r&&r.toLowerCase()===o}return!1},t.prototype.getTimestamp=function(){var e=new Date,t=this.id.readUInt32BE(0);return e.setTime(1e3*Math.floor(t)),e},t.createPk=function(){return new t},t.createFromTime=function(n){var r=e.from([0,0,0,0,0,0,0,0,0,0,0,0]);return r.writeUInt32BE(n,0),new t(r)},t.createFromHexString=function(n){if(void 0===n||null!=n&&24!==n.length)throw new qc("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(e.from(n,"hex"))},t.isValid=function(e){if(null==e)return!1;try{return new t(e),!0}catch(e){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(xu.prototype,"generate",{value:Kc((function(e){return xu.generate(e)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(xu.prototype,"getInc",{value:Kc((function(){return xu.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(xu.prototype,"get_inc",{value:Kc((function(){return xu.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(xu,"get_inc",{value:Kc((function(){return xu.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(xu.prototype,"_bsontype",{value:"ObjectID"});var Lu=function(){function e(t,n){if(!(this instanceof e))return new e(t,n);if(this.pattern=t,this.options=(null!=n?n:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new Mc("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new Mc("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 Mc("The regular expression option [".concat(this.options[r],"] is not supported"))}return e.parseOptions=function(e){return e?e.split("").sort().join(""):""},e.prototype.toExtendedJSON=function(e){return(e=e||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}},e.fromExtendedJSON=function(t){if("$regex"in t){if("string"==typeof t.$regex)return new e(t.$regex,e.parseOptions(t.$options));if("BSONRegExp"===t.$regex._bsontype)return t}if("$regularExpression"in t)return new e(t.$regularExpression.pattern,e.parseOptions(t.$regularExpression.options));throw new qc("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(t)))},e}();Object.defineProperty(Lu.prototype,"_bsontype",{value:"BSONRegExp"});var Cu=function(){function e(t){if(!(this instanceof e))return new e(t);this.value=t}return e.prototype.valueOf=function(){return this.value},e.prototype.toString=function(){return this.value},e.prototype.inspect=function(){return'new BSONSymbol("'.concat(this.value,'")')},e.prototype.toJSON=function(){return this.value},e.prototype.toExtendedJSON=function(){return{$symbol:this.value}},e.fromExtendedJSON=function(t){return new e(t.$symbol)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e}();Object.defineProperty(Cu.prototype,"_bsontype",{value:"Symbol"});var ku=function(e){function t(n,r){var o=this;return o instanceof t?(o=fu.isLong(n)?e.call(this,n.low,n.high,!0)||this:Gc(n)&&void 0!==n.t&&void 0!==n.i?e.call(this,n.i,n.t,!0)||this:e.call(this,n,r,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new t(n,r)}return Uc(t,e),t.prototype.toJSON=function(){return{$timestamp:this.toString()}},t.fromInt=function(e){return new t(fu.fromInt(e,!0))},t.fromNumber=function(e){return new t(fu.fromNumber(e,!0))},t.fromBits=function(e,n){return new t(e,n)},t.fromString=function(e,n){return new t(fu.fromString(e,!0,n))},t.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},t.fromExtendedJSON=function(e){return new t(e.$timestamp)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new Timestamp({ t: ".concat(this.getHighBits(),", i: ").concat(this.getLowBits()," })")},t.MAX_VALUE=fu.MAX_UNSIGNED_VALUE,t}(fu);var Du=2147483647,ju=-2147483648,Uu=0x8000000000000000,Mu=-0x8000000000000000,qu={$oid:xu,$binary:eu,$uuid:eu,$symbol:Cu,$numberInt:Ou,$numberDecimal:Su,$numberDouble:Iu,$numberLong:fu,$minKey:Nu,$maxKey:Au,$regex:Lu,$regularExpression:Lu,$timestamp:ku};function Wu(e,t){if(void 0===t&&(t={}),"number"==typeof e){if(t.relaxed||t.legacy)return e;if(Math.floor(e)===e){if(e>=ju&&e<=Du)return new Ou(e);if(e>=Mu&&e<=Uu)return fu.fromNumber(e)}return new Iu(e)}if(null==e||"object"!=typeof e)return e;if(e.$undefined)return null;for(var n=Object.keys(e).filter((function(t){return t.startsWith("$")&&null!=e[t]})),r=0;r<n.length;r++){var o=qu[n[r]];if(o)return o.fromExtendedJSON(e,t)}if(null!=e.$date){var i=e.$date,s=new Date;return t.legacy?"number"==typeof i?s.setTime(i):"string"==typeof i&&s.setTime(Date.parse(i)):"string"==typeof i?s.setTime(Date.parse(i)):fu.isLong(i)?s.setTime(i.toNumber()):"number"==typeof i&&t.relaxed&&s.setTime(i),s}if(null!=e.$code){var a=Object.assign({},e);return e.$scope&&(a.$scope=Wu(e.$scope)),nu.fromExtendedJSON(e)}if(function(e){return Gc(e)&&null!=e.$id&&"string"==typeof e.$ref&&(null==e.$db||"string"==typeof e.$db)}(e)||e.$dbPointer){var c=e.$ref?e:e.$dbPointer;if(c instanceof ru)return c;var u=Object.keys(c).filter((function(e){return e.startsWith("$")})),f=!0;if(u.forEach((function(e){-1===["$ref","$id","$db"].indexOf(e)&&(f=!1)})),f)return ru.fromExtendedJSON(c)}return e}function Fu(e){var t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function Bu(e,t){if(("object"==typeof e||"function"==typeof e)&&null!==e){var n=t.seenObjects.findIndex((function(t){return t.obj===e}));if(-1!==n){var r=t.seenObjects.map((function(e){return e.propertyName})),o=r.slice(0,n).map((function(e){return"".concat(e," -> ")})).join(""),i=r[n],s=" -> "+r.slice(n+1,r.length-1).map((function(e){return"".concat(e," -> ")})).join(""),a=r[r.length-1],c=" ".repeat(o.length+i.length/2),u="-".repeat(s.length+(i.length+a.length)/2-1);throw new qc("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(s).concat(a,"\n")+" ".concat(c,"\\").concat(u,"/"))}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return function(e,t){return e.map((function(e,n){t.seenObjects.push({propertyName:"index ".concat(n),obj:null});try{return Bu(e,t)}finally{t.seenObjects.pop()}}))}(e,t);if(void 0===e)return null;if(e instanceof Date||Gc(h=e)&&"[object Date]"===Object.prototype.toString.call(h)){var f=e.getTime(),l=f>-1&&f<2534023188e5;return t.legacy?t.relaxed&&l?{$date:e.getTime()}:{$date:Fu(e)}:t.relaxed&&l?{$date:Fu(e)}:{$date:{$numberLong:e.getTime().toString()}}}var h;if(!("number"!=typeof e||t.relaxed&&isFinite(e))){if(Math.floor(e)===e){var p=e>=Mu&&e<=Uu;if(e>=ju&&e<=Du)return{$numberInt:e.toString()};if(p)return{$numberLong:e.toString()}}return{$numberDouble:e.toString()}}if(e instanceof RegExp||function(e){return"[object RegExp]"===Object.prototype.toString.call(e)}(e)){var d=e.flags;if(void 0===d){var y=e.toString().match(/[gimuy]*$/);y&&(d=y[0])}return new Lu(e.source,d).toExtendedJSON(t)}return null!=e&&"object"==typeof e?function(e,t){if(null==e||"object"!=typeof e)throw new Mc("not an object instance");var n=e._bsontype;if(void 0===n){var r={};for(var o in e){t.seenObjects.push({propertyName:o,obj:null});try{var i=Bu(e[o],t);"__proto__"===o?Object.defineProperty(r,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):r[o]=i}finally{t.seenObjects.pop()}}return r}if(function(e){return Gc(e)&&Reflect.has(e,"_bsontype")&&"string"==typeof e._bsontype}(e)){var s=e;if("function"!=typeof s.toExtendedJSON){var a=Hu[e._bsontype];if(!a)throw new qc("Unrecognized or invalid _bsontype: "+e._bsontype);s=a(s)}return"Code"===n&&s.scope?s=new nu(s.code,Bu(s.scope,t)):"DBRef"===n&&s.oid&&(s=new ru(Bu(s.collection,t),Bu(s.oid,t),Bu(s.db,t),Bu(s.fields,t))),s.toExtendedJSON(t)}throw new Mc("_bsontype must be a string, but was: "+typeof n)}(e,t):e}var $u,Hu={Binary:function(e){return new eu(e.value(),e.sub_type)},Code:function(e){return new nu(e.code,e.scope)},DBRef:function(e){return new ru(e.collection||e.namespace,e.oid,e.db,e.fields)},Decimal128:function(e){return new Su(e.bytes)},Double:function(e){return new Iu(e.value)},Int32:function(e){return new Ou(e.value)},Long:function(e){return fu.fromBits(null!=e.low?e.low:e.low_,null!=e.low?e.high:e.high_,null!=e.low?e.unsigned:e.unsigned_)},MaxKey:function(){return new Au},MinKey:function(){return new Nu},ObjectID:function(e){return new xu(e)},ObjectId:function(e){return new xu(e)},BSONRegExp:function(e){return new Lu(e.pattern,e.options)},Symbol:function(e){return new Cu(e.value)},Timestamp:function(e){return ku.fromBits(e.low,e.high)}};!function(e){function t(e,t){var n=Object.assign({},{relaxed:!0,legacy:!1},t);return"boolean"==typeof n.relaxed&&(n.strict=!n.relaxed),"boolean"==typeof n.strict&&(n.relaxed=!n.strict),JSON.parse(e,(function(e,t){if(-1!==e.indexOf("\0"))throw new Mc("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(e)));return Wu(t,n)}))}function n(e,t,n,r){null!=n&&"object"==typeof n&&(r=n,n=0),null==t||"object"!=typeof t||Array.isArray(t)||(r=t,t=void 0,n=0);var o=Bu(e,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,t,n)}e.parse=t,e.stringify=n,e.serialize=function(e,t){return t=t||{},JSON.parse(n(e,t))},e.deserialize=function(e,n){return n=n||{},t(JSON.stringify(e),n)}}($u||($u={}));var Gu=Fc();Gu.Map?Gu.Map:function(){function e(e){void 0===e&&(e=[]),this._keys=[],this._values={};for(var t=0;t<e.length;t++)if(null!=e[t]){var n=e[t],r=n[0],o=n[1];this._keys.push(r),this._values[r]={v:o,i:this._keys.length-1}}}e.prototype.clear=function(){this._keys=[],this._values={}},e.prototype.delete=function(e){var t=this._values[e];return null!=t&&(delete this._values[e],this._keys.splice(t.i,1),!0)},e.prototype.entries=function(){var e=this,t=0;return{next:function(){var n=e._keys[t++];return{value:void 0!==n?[n,e._values[n].v]:void 0,done:void 0===n}}}},e.prototype.forEach=function(e,t){t=t||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];e.call(t,this._values[r].v,r,t)}},e.prototype.get=function(e){return this._values[e]?this._values[e].v:void 0},e.prototype.has=function(e){return null!=this._values[e]},e.prototype.keys=function(){var e=this,t=0;return{next:function(){var n=e._keys[t++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},e.prototype.set=function(e,t){return this._values[e]?(this._values[e].v=t,this):(this._keys.push(e),this._values[e]={v:t,i:this._keys.length-1},this)},e.prototype.values=function(){var e=this,t=0;return{next:function(){var n=e._keys[t++];return{value:void 0!==n?e._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0})}(),fu.fromNumber(zc),fu.fromNumber(Qc);var Ku=new Uint8Array(8);new DataView(Ku.buffer,Ku.byteOffset,Ku.byteLength);e.alloc(17825792);var Vu=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Ju=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},Yu=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=new bf.reqClass(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return Vu(this,void 0,void 0,(function(){var e;return Ju(this,(function(t){switch(t.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(e=t.sent())&&e.data&&e.data.list?[2,{requestId:e.requestId,data:JSON.parse(e.data.list).map($u.parse)}]:[2,e]}}))}))},e.prototype.unwrap=function(){return this._stages},e.prototype.done=function(){return this._stages.map((function(e){var t,n=e.stageKey,r=e.stageValue;return(t={})[n]=JSON.parse(r),t}))},e.prototype._pipe=function(e,t){return this._stages.push({stageKey:"$"+e,stageValue:JSON.stringify(t)}),this},e.prototype.addFields=function(e){return this._pipe("addFields",e)},e.prototype.bucket=function(e){return this._pipe("bucket",e)},e.prototype.bucketAuto=function(e){return this._pipe("bucketAuto",e)},e.prototype.count=function(e){return this._pipe("count",e)},e.prototype.geoNear=function(e){return this._pipe("geoNear",e)},e.prototype.group=function(e){return this._pipe("group",e)},e.prototype.limit=function(e){return this._pipe("limit",e)},e.prototype.match=function(e){return this._pipe("match",Lc.encode(e))},e.prototype.project=function(e){return this._pipe("project",e)},e.prototype.lookup=function(e){return this._pipe("lookup",e)},e.prototype.replaceRoot=function(e){return this._pipe("replaceRoot",e)},e.prototype.sample=function(e){return this._pipe("sample",e)},e.prototype.skip=function(e){return this._pipe("skip",e)},e.prototype.sort=function(e){return this._pipe("sort",e)},e.prototype.sortByCount=function(e){return this._pipe("sortByCount",e)},e.prototype.unwind=function(e){return this._pipe("unwind",e)},e}(),Zu=Yu,Xu=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),zu=function(e){function t(t,n){return e.call(this,t,n)||this}return Xu(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new xc(this._db,this._coll,e)},t.prototype.add=function(e,t){return new xc(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new Zu(this._db,this._coll)},t}(Dc),Qu={eq:function(e){return new cc(sc.EQ,[e])},neq:function(e){return new cc(sc.NEQ,[e])},lt:function(e){return new cc(sc.LT,[e])},lte:function(e){return new cc(sc.LTE,[e])},gt:function(e){return new cc(sc.GT,[e])},gte:function(e){return new cc(sc.GTE,[e])},in:function(e){return new cc(sc.IN,e)},nin:function(e){return new cc(sc.NIN,e)},all:function(e){return new cc(sc.ALL,e)},elemMatch:function(e){return new cc(sc.ELEM_MATCH,[e])},exists:function(e){return new cc(sc.EXISTS,[e])},size:function(e){return new cc(sc.SIZE,[e])},mod:function(e){return new cc(sc.MOD,[e])},geoNear:function(e){return new cc(sc.GEO_NEAR,[e])},geoWithin:function(e){return new cc(sc.GEO_WITHIN,[e])},geoIntersects:function(e){return new cc(sc.GEO_INTERSECTS,[e])},and:function(){var e=Ma(arguments[0])?arguments[0]:Array.from(arguments);return new oc(tc.AND,e)},nor:function(){var e=Ma(arguments[0])?arguments[0]:Array.from(arguments);return new oc(tc.NOR,e)},or:function(){var e=Ma(arguments[0])?arguments[0]:Array.from(arguments);return new oc(tc.OR,e)},not:function(){var e=Ma(arguments[0])?arguments[0]:Array.from(arguments);return new oc(tc.NOT,e)},set:function(e){return new nc(xa.SET,[e])},remove:function(){return new nc(xa.REMOVE,[])},inc:function(e){return new nc(xa.INC,[e])},mul:function(e){return new nc(xa.MUL,[e])},push:function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(ja(t[0])&&t[0].hasOwnProperty("each")){var r=t[0];e={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else e=Ma(t[0])?t[0]:Array.from(t);return new nc(xa.PUSH,e)},pull:function(e){return new nc(xa.PULL,e)},pullAll:function(e){return new nc(xa.PULL_ALL,e)},pop:function(){return new nc(xa.POP,[])},shift:function(){return new nc(xa.SHIFT,[])},unshift:function(){var e=Ma(arguments[0])?arguments[0]:Array.from(arguments);return new nc(xa.UNSHIFT,e)},addToSet:function(e){return new nc(xa.ADD_TO_SET,e)},rename:function(e){return new nc(xa.RENAME,[e])},bit:function(e){return new nc(xa.BIT,[e])},max:function(e){return new nc(xa.MAX,[e])},min:function(e){return new nc(xa.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===Da(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new Zu},abs:function(e){return new ef("abs",e)},add:function(e){return new ef("add",e)},ceil:function(e){return new ef("ceil",e)},divide:function(e){return new ef("divide",e)},exp:function(e){return new ef("exp",e)},floor:function(e){return new ef("floor",e)},ln:function(e){return new ef("ln",e)},log:function(e){return new ef("log",e)},log10:function(e){return new ef("log10",e)},mod:function(e){return new ef("mod",e)},multiply:function(e){return new ef("multiply",e)},pow:function(e){return new ef("pow",e)},sqrt:function(e){return new ef("sqrt",e)},subtract:function(e){return new ef("subtract",e)},trunc:function(e){return new ef("trunc",e)},arrayElemAt:function(e){return new ef("arrayElemAt",e)},arrayToObject:function(e){return new ef("arrayToObject",e)},concatArrays:function(e){return new ef("concatArrays",e)},filter:function(e){return new ef("filter",e)},in:function(e){return new ef("in",e)},indexOfArray:function(e){return new ef("indexOfArray",e)},isArray:function(e){return new ef("isArray",e)},map:function(e){return new ef("map",e)},range:function(e){return new ef("range",e)},reduce:function(e){return new ef("reduce",e)},reverseArray:function(e){return new ef("reverseArray",e)},size:function(e){return new ef("size",e)},slice:function(e){return new ef("slice",e)},zip:function(e){return new ef("zip",e)},and:function(e){return new ef("and",e)},not:function(e){return new ef("not",e)},or:function(e){return new ef("or",e)},cmp:function(e){return new ef("cmp",e)},eq:function(e){return new ef("eq",e)},gt:function(e){return new ef("gt",e)},gte:function(e){return new ef("gte",e)},lt:function(e){return new ef("lt",e)},lte:function(e){return new ef("lte",e)},neq:function(e){return new ef("ne",e)},cond:function(e){return new ef("cond",e)},ifNull:function(e){return new ef("ifNull",e)},switch:function(e){return new ef("switch",e)},dateFromParts:function(e){return new ef("dateFromParts",e)},dateFromString:function(e){return new ef("dateFromString",e)},dayOfMonth:function(e){return new ef("dayOfMonth",e)},dayOfWeek:function(e){return new ef("dayOfWeek",e)},dayOfYear:function(e){return new ef("dayOfYear",e)},isoDayOfWeek:function(e){return new ef("isoDayOfWeek",e)},isoWeek:function(e){return new ef("isoWeek",e)},isoWeekYear:function(e){return new ef("isoWeekYear",e)},millisecond:function(e){return new ef("millisecond",e)},minute:function(e){return new ef("minute",e)},month:function(e){return new ef("month",e)},second:function(e){return new ef("second",e)},hour:function(e){return new ef("hour",e)},week:function(e){return new ef("week",e)},year:function(e){return new ef("year",e)},literal:function(e){return new ef("literal",e)},mergeObjects:function(e){return new ef("mergeObjects",e)},objectToArray:function(e){return new ef("objectToArray",e)},allElementsTrue:function(e){return new ef("allElementsTrue",e)},anyElementTrue:function(e){return new ef("anyElementTrue",e)},setDifference:function(e){return new ef("setDifference",e)},setEquals:function(e){return new ef("setEquals",e)},setIntersection:function(e){return new ef("setIntersection",e)},setIsSubset:function(e){return new ef("setIsSubset",e)},setUnion:function(e){return new ef("setUnion",e)},concat:function(e){return new ef("concat",e)},dateToString:function(e){return new ef("dateToString",e)},indexOfBytes:function(e){return new ef("indexOfBytes",e)},indexOfCP:function(e){return new ef("indexOfCP",e)},split:function(e){return new ef("split",e)},strLenBytes:function(e){return new ef("strLenBytes",e)},strLenCP:function(e){return new ef("strLenCP",e)},strcasecmp:function(e){return new ef("strcasecmp",e)},substr:function(e){return new ef("substr",e)},substrBytes:function(e){return new ef("substrBytes",e)},substrCP:function(e){return new ef("substrCP",e)},toLower:function(e){return new ef("toLower",e)},toUpper:function(e){return new ef("toUpper",e)},meta:function(e){return new ef("meta",e)},addToSet:function(e){return new ef("addToSet",e)},avg:function(e){return new ef("avg",e)},first:function(e){return new ef("first",e)},last:function(e){return new ef("last",e)},max:function(e){return new ef("max",e)},min:function(e){return new ef("min",e)},push:function(e){return new ef("push",e)},stdDevPop:function(e){return new ef("stdDevPop",e)},stdDevSamp:function(e){return new ef("stdDevSamp",e)},sum:function(e){return new ef("sum",e)},let:function(e){return new ef("let",e)}},project:{slice:function(e){return new tf("slice",e)},elemMatch:function(e){return new tf("elemMatch",e)}}},ef=function(e,t){this["$"+e]=t},tf=function(e,t){this["$"+e]=t},nf=function(){function e(e){var t=e.regexp,n=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regex=t,this.$options=n}return e.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Ta},enumerable:!0,configurable:!0}),e}();function rf(e){return new nf(e)}var of={code:"INSERT_DOC_FAIL",message:"insert document failed"},sf={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},af=function(){return af=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},af.apply(this,arguments)},cf=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},uf=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},ff="database.updateDocInTransaction",lf=function(){function e(e,t,n){this._coll=t,this.id=n,this._transaction=e,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return e.prototype.create=function(e){return cf(this,void 0,void 0,(function(){var t,n,r,o;return uf(this,(function(i){switch(i.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:$u.stringify(vc(e),{relaxed:!1})},this.id&&(t._id=this.id),[4,this._request.send("database.insertDocInTransaction",t)];case 1:if((n=i.sent()).code)throw n;if(r=$u.parse(n.inserted),1==(o=$u.parse(n.ok))&&1==r)return[2,af(af({},n),{ok:o,inserted:r})];throw new Error(of.message)}}))}))},e.prototype.get=function(){return cf(this,void 0,void 0,(function(){var e,t;return uf(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,{data:"null"!==t.data?Ca.formatField($u.parse(t.data)):$u.parse(t.data),requestId:t.requestId}]}}))}))},e.prototype.set=function(e){return cf(this,void 0,void 0,(function(){var t,n;return uf(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:$u.stringify(vc(e),{relaxed:!1}),upsert:!0},[4,this._request.send(ff,t)];case 1:if((n=r.sent()).code)throw n;return[2,af(af({},n),{updated:$u.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},e.prototype.update=function(e){return cf(this,void 0,void 0,(function(){var t,n;return uf(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:$u.stringify(Nc.encode(e),{relaxed:!1})},[4,this._request.send(ff,t)];case 1:if((n=r.sent()).code)throw n;return[2,af(af({},n),{updated:$u.parse(n.updated)})]}}))}))},e.prototype.delete=function(){return cf(this,void 0,void 0,(function(){var e,t;return uf(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,af(af({},t),{deleted:$u.parse(t.deleted)})]}}))}))},e}(),hf=function(e,t){this._coll=t,this._transaction=e},pf=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),df=function(e){function t(t,n){return e.call(this,t,n)||this}return pf(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new lf(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new lf(this._transaction,this._coll,t).create(e)},t}(hf),yf=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},gf=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},vf=function(){function e(e){this._db=e,this._request=new bf.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return yf(this,void 0,void 0,(function(){var e;return gf(this,(function(t){switch(t.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((e=t.sent()).code)throw e;return this.inited=!0,this._id=e.transactionId,[2]}}))}))},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new df(this,e)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return yf(this,void 0,void 0,(function(){var e,t;return gf(this,(function(n){switch(n.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.commitTransaction",e)];case 1:if((t=n.sent()).code)throw t;return this.commited=!0,[2,t]}}))}))},e.prototype.rollback=function(e){return yf(this,void 0,void 0,(function(){var t,n;return gf(this,(function(r){switch(r.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.abortTransaction",t)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=e,[2,n]}}))}))},e}();function mf(){return yf(this,void 0,void 0,(function(){var e;return gf(this,(function(t){switch(t.label){case 0:return[4,(e=new vf(this)).init()];case 1:return t.sent(),[2,e]}}))}))}function _f(e,t){return void 0===t&&(t=3),yf(this,void 0,void 0,(function(){var n,r,o,i,s=this;return gf(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new vf(this)).init()];case 1:return a.sent(),[4,e(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(e){return yf(s,void 0,void 0,(function(){return gf(this,(function(t){switch(t.label){case 0:if(n.aborted||n.commited)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,n.rollback()];case 2:case 3:return t.sent(),[3,4];case 4:throw e;case 5:if(!0===n.aborted)throw n.abortReason;throw e}}))}))},t<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===sf.code?[4,_f.bind(this)(e,--t)]:[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 bf=function(){function e(e){this.config=e,this.Geo=Qa,this.serverDate=Pa,this.command=Qu,this.RegExp=rf,this.startTransaction=mf,this.runTransaction=_f,this.logicCommand=oc,this.updateCommand=nc,this.queryCommand=cc}return e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new zu(this,e)},e.prototype.createCollection=function(t){var n={collectionName:t};return new e.reqClass(this.config).send("database.addCollection",n)},e}(),wf=function(){return wf=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},wf.apply(this,arguments)};var Ef={name:"database",entity:{database:function(e){var t=this.platform,n=t.adapter,r=t.runtime;return bf.reqClass=this.request.constructor,bf.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},bf.runtime=r,this.wsClientClass&&(bf.wsClass=n.wsClass,bf.wsClientClass=this.wsClientClass),bf.ws||(bf.ws=null),new bf(wf(wf({},this.config),e))}}};try{cloudbase.registerComponent(Ef)}catch(e){}var Sf,If="1.7.2";Jt.registerVersion(If);try{!function(e){try{e.registerComponent(Mr)}catch(e){console.warn(e)}}(Jt),function(e){try{e.registerComponent(Xr)}catch(e){console.warn(e)}}(Jt),function(e){try{e.registerComponent(po)}catch(e){console.warn(e)}}(Jt),function(e){try{e.registerComponent(Ef)}catch(e){console.warn(e)}}(Jt),function(e){try{e.registerComponent(js),e.registerHook(Ds)}catch(e){console.warn(e)}}(Jt),function(e){try{e.registerComponent(Ys)}catch(e){console.warn(e)}}(Jt)}catch(e){}try{window.cloudbase=Jt}catch(e){}!function(e){e.development="dev-1gpp53ju3ceb46c7",e.production="release-7gvojkxi667a3f26"}(Sf||(Sf={}));var Of={ENV:Sf[process.env.NODE_ENV],REGION:"ap-shanghai"},Af={region:Of.REGION,env:Of.ENV},Nf=Jt.init(Af);function Tf(e){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return[4,Nf.callFunction(e)];case 1:return t=n.sent(),[2,new Promise((function(e,n){var r;console.log("import.meta",import.meta),(null===(r=t.result)||void 0===r?void 0:r.success)?e(t.result.data):n(t.result)}))]}}))}))}export{Tf as callFunction};
1
+ import{Buffer as e}from"buffer";function t(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){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(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function i(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];return n.push.apply(n,arguments),new(Function.bind.apply(t,n))}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var s={},a={},c={};Object.defineProperty(c,"__esModule",{value:!0}),c.COMMUNITY_SITE_URL=c.IS_DEBUG_MODE=c.getProtocol=c.setProtocol=c.getSdkName=c.setSdkName=void 0;var u="@cloudbase/js-sdk";c.setSdkName=function(e){u=e},c.getSdkName=function(){return u};var f="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";c.setProtocol=function(e){f=e},c.getProtocol=function(){return f},c.IS_DEBUG_MODE="development"===process.env.NODE_ENV,c.COMMUNITY_SITE_URL="https://support.qq.com/products/148793";var l={};Object.defineProperty(l,"__esModule",{value:!0}),l.ERRORS=void 0,l.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(e){var t=r&&r.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=r&&r.__exportStar||function(e,n){for(var r in e)"default"===r||n.hasOwnProperty(r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(c,e),n(l,e)}(a);var h,p={},d={};!function(e){e.local="local",e.none="none",e.session="session"}(h||(h={}));var y=function(){},g=function(){};function v(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}var m,_=i(Object.freeze({__proto__:null,AbstractSDKRequest:y,AbstractStorage:g,get StorageType(){return h},formatUrl:v})),b={},w={exports:{}},E={exports:{}};function S(){return m||(m=1,E.exports=(e=e||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),r={},o=r.lib={},i=o.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=o.WordArray=i.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[r+i>>>2]|=s<<24-(r+i)%4*8}else for(i=0;i<o;i+=4)t[r+i>>>2]=n[i>>>2];return this.sigBytes+=o,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],o=function(t){var n=987654321,r=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},i=0;i<t;i+=4){var a=o(4294967296*(n||e.random()));n=987654071*a(),r.push(4294967296*a()|0)}return new s.init(r,t)}}),a=r.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},f=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},l=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,a=o/(4*i),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*i,u=e.min(4*c,o);if(c){for(var f=0;f<c;f+=i)this._doProcessBlock(r,f);var l=r.splice(0,c);n.sigBytes-=u}return new s.init(l,u)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});o.Hasher=l.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=r.algo={};return r}(Math),e)),E.exports;var e}var I,O={exports:{}};function A(){return I?O.exports:(I=1,O.exports=(e=S(),function(t){var n=e,r=n.lib,o=r.WordArray,i=r.Hasher,s=n.algo,a=[],c=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,o=0;o<64;)e(r)&&(o<8&&(a[o]=n(t.pow(r,.5))),c[o]=n(t.pow(r,1/3)),o++),r++}();var u=[],f=s.SHA256=i.extend({_doReset:function(){this._hash=new o.init(a.slice(0))},_doProcessBlock:function(e,t){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)u[p]=0|e[t+p];else{var d=u[p-15],y=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=u[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;u[p]=y+u[p-7]+v+u[p-16]}var m=r&o^r&i^o&i,_=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&l)+c[p]+u[p];h=l,l=f,f=a,a=s+b|0,s=i,i=o,o=r,r=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 e=i.clone.call(this);return e._hash=this._hash.clone(),e}});n.SHA256=i._createHelper(f),n.HmacSHA256=i._createHmacHelper(f)}(Math),e.SHA256));var e}var N,T,R,P,x,L={exports:{}};w.exports=function(e){return e.HmacSHA256}(S(),A(),N||(N=1,L.exports=(T=S(),P=(R=T).lib.Base,x=R.enc.Utf8,void(R.algo.HMAC=P.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=x.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),s=o.words,a=i.words,c=0;c<n;c++)s[c]^=1549556828,a[c]^=909522486;o.sigBytes=i.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))));var C=w.exports,k={exports:{}};k.exports=function(e){return function(){var t=e,n=t.lib.WordArray;function r(e,t,r){for(var o=[],i=0,s=0;s<t;s++)if(s%4){var a=r[e.charCodeAt(s-1)]<<s%4*2,c=r[e.charCodeAt(s)]>>>6-s%4*2;o[i>>>2]|=(a|c)<<24-i%4*8,i++}return n.create(o,i)}t.enc.Base64={stringify:function(e){var t=e.words,n=e.sigBytes,r=this._map;e.clamp();for(var o=[],i=0;i<n;i+=3)for(var s=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[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 c=r.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(e){var t=e.length,n=this._map,o=this._reverseMap;if(!o){o=this._reverseMap=[];for(var i=0;i<n.length;i++)o[n.charCodeAt(i)]=i}var s=n.charAt(64);if(s){var a=e.indexOf(s);-1!==a&&(t=a)}return r(e,t,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64}(S());var D=k.exports,j={exports:{}};j.exports=function(e){return e.enc.Utf8}(S());var U=j.exports,M=r&&r.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(b,"__esModule",{value:!0}),b.transformPhone=b.sleep=b.printGroupLog=b.throwError=b.printInfo=b.printError=b.printWarn=b.execCallback=b.createPromiseCallback=b.removeParam=b.getHash=b.getQuery=b.toQueryString=b.createSign=b.formatUrl=b.genSeqId=b.isFormData=b.isInstanceOf=b.isNull=b.isPalinObject=b.isUndefined=b.isString=b.isArray=void 0;var q=M(C),W=M(D),F=M(U),B=a;function $(e){var t=W.default.stringify(e);return t=(t=(t=t.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}b.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},b.isString=function(e){return"string"==typeof e},b.isUndefined=function(e){return void 0===e},b.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},b.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},b.isInstanceOf=function(e,t){return e instanceof t},b.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},b.genSeqId=function(){return Math.random().toString(16).slice(2)},b.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t},b.createSign=function(e,t){var n=$(F.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+$(F.default.parse(JSON.stringify(e)));return n+"."+$(q.default(n,t))},b.toQueryString=function(e){void 0===e&&(e={});var t=[];for(var n in e)t.push(n+"="+encodeURIComponent(e[n]));return t.join("&")},b.getQuery=function(e,t){if("undefined"==typeof window)return!1;var n=t||window.location.search,r=new RegExp("(^|&)"+e+"=([^&]*)(&|$)"),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},b.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]"+e+"=([^&#]*)"));return t?t[1]:""},b.removeParam=function(e,t){var n=t.split("?")[0],r=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===e&&r.splice(i,1);n=n+"?"+r.join("&")}return n},b.createPromiseCallback=function(){var e;if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e},b.execCallback=function(e,t,n){if(void 0===n&&(n=null),e&&"function"==typeof e)return e(t,n);if(t)throw t;return n},b.printWarn=function(e,t){console.warn("["+B.getSdkName()+"]["+e+"]:"+t)},b.printError=function(e,t){console.error({code:e,msg:"["+B.getSdkName()+"]["+e+"]:"+t})},b.printInfo=function(e,t){console.log("["+B.getSdkName()+"]["+e+"]:"+t)},b.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"["+B.getSdkName()+"]["+e+"]:"+t}))},b.printGroupLog=function(e){var t=e.title,n=e.subtitle,r=void 0===n?"":n,o=e.content,i=void 0===o?[]:o,s=e.printTrace,a=void 0!==s&&s,c=e.collapsed;void 0!==c&&c?console.groupCollapsed(t,r):console.group(t,r);for(var u=0,f=i;u<f.length;u++){var l=f[u],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()},b.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},b.transformPhone=function(e){return"+86"+e};var H,G=r&&r.__extends||(H=function(e,t){return H=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},H(e,t)},function(e,t){function n(){this.constructor=e}H(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),K=r&&r.__assign||function(){return K=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},K.apply(this,arguments)},V=r&&r.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},J=r&&r.__generator||function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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(d,"__esModule",{value:!0}),d.WebRequest=d.genAdapter=void 0;var Y=b,Z=c,X=function(e){function t(t){var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return G(t,e),t.prototype.get=function(e){return this._request(K(K({},e),{method:"get"}),this._restrictedMethods.includes("get"))},t.prototype.post=function(e){return this._request(K(K({},e),{method:"post"}),this._restrictedMethods.includes("post"))},t.prototype.put=function(e){return this._request(K(K({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,n=e.file,r=e.name,o=new FormData;for(var i in t)o.append(i,t[i]);return o.append("key",r),o.append("file",n),this._request(K(K({},e),{data:o,method:"post"}),this._restrictedMethods.includes("upload"))},t.prototype.download=function(e){return V(this,void 0,void 0,(function(){var t,n,r,o;return J(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(K(K({},e),{headers:{},responseType:"blob"}))];case 1:return t=i.sent().data,n=window.URL.createObjectURL(new Blob([t])),r=decodeURIComponent(new URL(e.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 i.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype._request=function(e,t){var n=this;void 0===t&&(t=!1);var r=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=e.url,c=e.headers,u=void 0===c?{}:c,f=e.data,l=e.responseType,h=e.withCredentials,p=e.body,d=e.onUploadProgress,y=Y.formatUrl(Z.getProtocol(),a,"get"===r?f:{}),g=new XMLHttpRequest;for(var v in g.open(r,y),l&&(g.responseType=l),u)g.setRequestHeader(v,u[v]);d&&g.upload.addEventListener("progress",d),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};t.forEach((function(e){var t=e.split(": "),r=t.shift().toLowerCase(),o=t.join(": ");n[r]=o})),e.header=n,e.statusCode=g.status;try{e.data="blob"===l?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===l?g.response:g.responseText}clearTimeout(i),o(e)}},t&&n._timeout&&(i=setTimeout((function(){console.warn(n._timeoutMsg),g.abort()}),n._timeout)),s=Y.isFormData(f)?f:"application/x-www-form-urlencoded"===u["content-type"]?Y.toQueryString(f):p||(f?JSON.stringify(f):void 0),h&&(g.withCredentials=!0),g.send(s)}))},t}(_.AbstractSDKRequest);d.WebRequest=X,d.genAdapter=function(){return{root:window,reqClass:X,wsClass:WebSocket,localStorage:localStorage,sessionStorage:sessionStorage}},function(e){var t=r&&r.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=r&&r.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=r&&r.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var o in e)"default"!==o&&Object.hasOwnProperty.call(e,o)&&t(r,e,o);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var i,s=o(d),a=b;!function(e){e.WEB="web",e.WX_MP="wx_mp"}(i=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(e){for(var t=0,n=a.isArray(e)?e:[e];t<n.length;t++){var r=n[t],o=r.isMatch,i=r.genAdapter,s=r.runtime;if(o())return{adapter:i(),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:s.genAdapter(),runtime:i.WEB}}}(p);var z={},Q=r&&r.__extends||function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ee=r&&r.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},te=r&&r.__generator||function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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(z,"__esModule",{value:!0}),z.CloudbaseCache=void 0;var ne=b,re=a,oe=function(e){function t(t){var n=e.call(this)||this;return n._root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return Q(t,e),t.prototype.setItem=function(e,t){this._root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this._root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this._root.tcbCacheObject[e]},t.prototype.clear=function(){delete this._root.tcbCacheObject},t}(_.AbstractStorage);function ie(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:(ne.printWarn(re.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new oe(t.root));case"none":return new oe(t.root);case"session":return t.sessionStorage?t.sessionStorage:(ne.printWarn(re.ERRORS.INVALID_PARAMS,"sessionStorage is not supported on current platform"),new oe(t.root))}}var se=function(){function e(e){this.keys={};var t=e.persistence,n=e.platformInfo,r=void 0===n?{}:n,o=e.keys,i=void 0===o?{}:o,s=e.alwaysLocalKeys,a=void 0===s?[]:s;this._platformInfo=r,this._alwaysLocalKeys=a,this._storage||(this._persistence=r.adapter.primaryStorage||t,this._storage=ie(this._persistence,r.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._persistence},enumerable:!1,configurable:!0}),e.prototype.updatePersistence=function(e){if("async"!==this.mode){if(e!==this._persistence){var t="local"===this._persistence;this._persistence=e;var n=ie(e,this._platformInfo.adapter);for(var r in this.keys){var o=this.keys[r];if(!t||!this._alwaysLocalKeys.includes(r)){var i=this._storage.getItem(o);ne.isUndefined(i)||ne.isNull(i)||(n.setItem(o,i),this._storage.removeItem(o))}}this._storage=n}}else ne.printWarn(re.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use updatePersistenceAsync insteed")},e.prototype.updatePersistenceAsync=function(e){return ee(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c;return te(this,(function(u){switch(u.label){case 0:if(e===this._persistence)return[2];for(o in t="local"===this._persistence,this._persistence=e,n=ie(e,this._platformInfo.adapter),r=[],this.keys)r.push(o);i=0,u.label=1;case 1:return i<r.length?(s=r[i],a=this.keys[s],t&&this._alwaysLocalKeys.includes(s)?[3,4]:[4,this._storage.getItem(a)]):[3,5];case 2:return c=u.sent(),ne.isUndefined(c)||ne.isNull(c)?[3,4]:(n.setItem(a,c),[4,this._storage.removeItem(a)]);case 3:u.sent(),u.label=4;case 4:return i++,[3,1];case 5:return this._storage=n,[2]}}))}))},e.prototype.setStore=function(e,t,n){if("async"!==this.mode){if(this._storage)try{var r={version:n||"localCachev1",content:t};this._storage.setItem(e,JSON.stringify(r))}catch(e){throw new Error(JSON.stringify({code:re.ERRORS.OPERATION_FAIL,msg:"["+re.getSdkName()+"]["+re.ERRORS.OPERATION_FAIL+"]setStore failed",info:e}))}}else ne.printWarn(re.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,n){return ee(this,void 0,void 0,(function(){var r;return te(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:t},[4,this._storage.setItem(e,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,t){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.tcb_token))return process.env.tcb_token;if(!this._storage)return""}catch(e){return""}t=t||"localCachev1";var r=this._storage.getItem(e);return r&&r.indexOf(t)>=0?JSON.parse(r).content:""}ne.printWarn(re.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var n;return ee(this,void 0,void 0,(function(){var r;return te(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.tcb_token))return[2,process.env.tcb_token];if(!this._storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this._storage.getItem(e)];case 1:return(r=o.sent())&&r.indexOf(t)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this._storage.removeItem(e):ne.printWarn(re.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return ee(this,void 0,void 0,(function(){return te(this,(function(t){switch(t.label){case 0:return[4,this._storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}();z.CloudbaseCache=se;var ae={},ce=r&&r.__extends||function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ue=r&&r.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};Object.defineProperty(ae,"__esModule",{value:!0}),ae.removeEventListener=ae.activateEvent=ae.addEventListener=ae.CloudbaseEventEmitter=ae.IErrorEvent=ae.CloudbaseEvent=void 0;var fe=b;var le=function(e,t){this.data=t||null,this.name=e};ae.CloudbaseEvent=le;var he=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return ce(t,e),t}(le);ae.IErrorEvent=he;var pe=function(){function e(){this._listeners={}}return e.prototype.on=function(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this},e.prototype.off=function(e,t){return function(e,t,n){if(null==n?void 0:n[e]){var r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}(e,t,this._listeners),this},e.prototype.fire=function(e,t){if(fe.isInstanceOf(e,he))return console.error(e.error),this;var n=fe.isString(e)?new le(e,t||{}):e,r=n.name;if(this._listens(r)){n.target=this;for(var o=0,i=this._listeners[r]?ue(this._listeners[r]):[];o<i.length;o++){i[o].call(this,n)}}return this},e.prototype._listens=function(e){return this._listeners[e]&&this._listeners[e].length>0},e}();ae.CloudbaseEventEmitter=pe;var de=new pe;ae.addEventListener=function(e,t){de.on(e,t)},ae.activateEvent=function(e,t){void 0===t&&(t={}),de.fire(e,t)},ae.removeEventListener=function(e,t){de.off(e,t)};var ye={},ge={},ve=r&&r.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},me=r&&r.__generator||function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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(ge,"__esModule",{value:!0}),ge.catchErrorsDecorator=void 0;var _e=b,be=a,we=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(we=-1!==navigator.userAgent.indexOf("Firefox"));var Ee=we?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,Se=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function Ie(e){var t=e.err,n=e.className,r=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),a=we?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]\\s*\\(.*\\)$"),c=we?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]"),u=s.findIndex((function(e){return a.test(e)}));if(-1!==u){var f=s.filter((function(e,t){return t>u}));f.unshift(s[u].replace(c,n+"."+r).replace(Se,o)),(i=new Error).stack=(we?"@debugger":"Error")+"\n"+f.join("\n")}return i}ge.catchErrorsDecorator=function(e){var t=e.mode,n=void 0===t?"async":t,r=e.customInfo,o=void 0===r?{}:r,i=e.title,s=e.messages,a=void 0===s?[]:s;return function(e,t,r){if(be.IS_DEBUG_MODE){var s=o.className||e.constructor.name,c=o.methodName||t,u=r.value,f=function(e){var t="",n=e.stack.split("\n"),r=n.findIndex((function(e){return Ee.test(e)}));if(-1!==r){var o=Se.exec(n[r+1]||"");t=o?o[0]:""}return t}(new Error);r.value="sync"===n?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ie({err:new Error,className:s,methodName:c,sourceLink:f});try{return u.apply(this,e)}catch(e){var r=e,o=e.message,l={title:i||s+"."+c+" failed",content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var h=JSON.parse(o);l.subtitle=o,h.code&&(n?(n.code=h.code,n.msg=h.msg):(e.code=h.code,e.message=h.msg),r=n||e,l.content=a.map((function(e){return{type:"info",body:e}})))}throw _e.printGroupLog(l),r}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ve(this,void 0,void 0,(function(){var t,n,r,o,l,h;return me(this,(function(p){switch(p.label){case 0:t=Ie({err:new Error,className:s,methodName:c,sourceLink:f}),p.label=1;case 1:return p.trys.push([1,3,,4]),[4,u.apply(this,e)];case 2:return[2,p.sent()];case 3:throw n=p.sent(),r=n,o=n.message,l={title:i||s+"."+c+" failed",content:[{type:"error",body:n}]},o&&/^\{.*\}$/.test(o)&&(h=JSON.parse(o),l.subtitle=h,h.code&&(t?(t.code=h.code,t.message=h.msg):(n.code=h.code,n.message=h.msg),r=t||n,l.content=a.map((function(e){return{type:"info",body:e}})))),_e.printGroupLog(l),r;case 4:return[2]}}))}))}}}},function(e){var t=r&&r.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=r&&r.__exportStar||function(e,n){for(var r in e)"default"===r||n.hasOwnProperty(r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(ge,e)}(ye);var Oe=r&&r.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),Ae=r&&r.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ne=r&&r.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&Oe(t,e,n);return Ae(t,e),t};Object.defineProperty(s,"__esModule",{value:!0});var Te=s.helpers=s.utils=s.events=s.cache=s.adapters=s.constants=void 0,Re=Ne(a),Pe=s.constants=Re,xe=Ne(p),Le=s.adapters=xe,Ce=Ne(z),ke=s.cache=Ce,De=Ne(ae),je=s.events=De,Ue=Ne(b),Me=s.utils=Ue,qe=Ne(ye);Te=s.helpers=qe;var We=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Fe=function(){return Fe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Fe.apply(this,arguments)},Be=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},$e=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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 He=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return We(t,e),t.prototype.post=function(e){var t=this;return new Promise((function(n,r){var o=e.url,i=e.data,s=e.headers,a=wx.request({url:v("https:",o),data:i,timeout:t._timeout,method:"POST",header:s,success:function(e){n(e)},fail:function(e){r(e)},complete:function(e){if(e&&e.errMsg&&(t._timeout&&-1!==t._restrictedMethods.indexOf("post")&&"request:fail timeout"===e.errMsg)){console.warn(t._timeoutMsg);try{a.abort()}catch(e){}}}})}))},t.prototype.upload=function(e){var t=this,n=this;return new Promise((function(r){return Be(t,void 0,void 0,(function(){var t,o,i,s,a,c;return $e(this,(function(u){return t=e.url,o=e.file,i=e.data,s=e.headers,a=e.onUploadProgress,c=wx.uploadFile({url:t,filePath:o,name:"file",formData:Fe({},i),header:s,timeout:this._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(t.statusCode=parseInt(i.success_action_status,10)),r(t)},fail:function(e){r(e)},complete:function(e){if(e&&e.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg)){console.warn(n._timeoutMsg);try{c.abort()}catch(e){}}}}),a&&c.onProgressUpdate((function(e){a(e)})),[2]}))}))}))},t.prototype.download=function(e){var t=this,n=this;return new Promise((function(r,o){var i=e.url,s=e.headers,a=wx.downloadFile({url:v("https:",i),header:s,timeout:t._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?r({statusCode:200,tempFilePath:e.tempFilePath}):r(e)},fail:function(e){o(e)},complete:function(e){if(e&&e.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===e.errMsg)){console.warn(n._timeoutMsg);try{a.abort()}catch(e){}}}})}))},t}(y),Ge={setItem:function(e,t){wx.setStorageSync(e,t)},getItem:function(e){return wx.getStorageSync(e)},removeItem:function(e){wx.removeStorageSync(e)},clear:function(){wx.clearStorageSync()}},Ke=function(e,t){void 0===t&&(t={});var n=wx.connectSocket(Fe({url:e},t));return{set onopen(e){n.onOpen(e)},set onmessage(e){n.onMessage(e)},set onclose(e){n.onClose(e)},set onerror(e){n.onError(e)},send:function(e){return n.send({data:e})},close:function(e,t){return n.close({code:e,reason:t})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};var Ve={genAdapter:function(){return{root:{},reqClass:He,wsClass:Ke,localStorage:Ge,primaryStorage:h.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.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(e){return!1}return!0},runtime:"wx_mp"},Je=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r},Ye=Pe.ERRORS,Ze={};function Xe(e,t){var n=t.name,r=t.namespace,o=t.entity,i=t.injectEvents,s=t.IIFE,a=void 0!==s&&s;if(Ze[n]||r&&e[r])throw new Error(JSON.stringify({code:Ye.INVALID_OPERATION,msg:"Duplicate component "+n}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:Ye.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(e)}if(Ze[n]=t,r?e.prototype[r]=o:ze(e.prototype,o),i){var c=i.bus,u=i.events;if(!c||!u||0===u.length)return;var f=e.prototype.fire||function(){};e.prototype.events||(e.prototype.events={}),(e.prototype.events||{})[n]?e.prototype.events[n].events=Je(e.prototype.events[n].events,u):e.prototype.events[n]={bus:c,events:u},e.prototype.fire=function(e,t){for(var n in f(e,t),this.events){var r=this.events[n],o=r.bus;if(r.events.includes(e)){o.fire(e,t);break}}}}}function ze(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var n in t)t.hasOwnProperty(n)&&(e[n]=ze(e[n],t[n]));return e}var Qe={},et=function(){return et=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},et.apply(this,arguments)},tt=ke.CloudbaseCache,nt={},rt={};function ot(e){var t=e.env,n=e.persistence,r=e.platformInfo,o={accessTokenKey:"access_token_"+t,accessTokenExpireKey:"access_token_expire_"+t,refreshTokenKey:"refresh_token_"+t,anonymousUuidKey:"anonymous_uuid_"+t,loginTypeKey:"login_type_"+t,userInfoKey:"user_info_"+t};nt[t]?nt[t].updatePersistence(n):nt[t]=new tt(et(et({},e),{keys:o,platformInfo:r,alwaysLocalKeys:["anonymousUuidKey"]})),rt[t]=rt[t]||new tt(et(et({},e),{keys:o,platformInfo:r,persistence:"local"}))}function it(e){return nt[e]}function st(e){return rt[e]}var at=Pe.setSdkName,ct=Pe.setProtocol,ut="",ft="@cloudbase/js-sdk";var lt,ht="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",pt="undefined"!=typeof process&&"e2e"===process.env.NODE_ENV&&"pre"===process.env.END_POINT?"//tcb-pre.tencentcloudapi.com/web":"//tcb-api.tencentcloudapi.com/web";function dt(e,t){pt=e,t&&(ht=t,ct(t))}function yt(){return{BASE_URL:pt,PROTOCOL:ht}}!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.CUSTOM="CUSTOM",e.NULL="NULL"}(lt||(lt={}));var gt="loginStateExpire",vt="refreshAccessToken",mt=function(){return mt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},mt.apply(this,arguments)},_t=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},bt=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},wt=Pe.ERRORS,Et=Me.genSeqId,St=Me.isFormData,It=Me.formatUrl,Ot=Me.createSign,At=Le.RUNTIME,Nt=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function Tt(e,t,n){var r=e[t];e[t]=function(t){var o={},i={};n.forEach((function(n){var r=n.call(e,t),s=r.data,a=r.headers;Object.assign(o,s),Object.assign(i,a)}));var s=t.data;return s&&function(){if(St(s))for(var e in o)s.append(e,o[e]);else t.data=mt(mt({},s),o)}(),t.headers=mt(mt({},t.headers||{}),i),r.call(e,t)}}function Rt(){var e=Et();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+ut,"x-seqid":e}}}var Pt=function(){function e(e){this._throwWhenRequestFail=!1,this.config=e,this._reqClass=new Qe.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post"]}),this._throwWhenRequestFail=e.throw||!1,this._cache=it(this.config.env),this._localCache=st(this.config.env),Tt(this._reqClass,"post",[Rt]),Tt(this._reqClass,"upload",[Rt]),Tt(this._reqClass,"download",[Rt])}return e.prototype.post=function(e){return _t(this,void 0,void 0,(function(){return bt(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.post(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.upload=function(e){return _t(this,void 0,void 0,(function(){return bt(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.upload(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.download=function(e){return _t(this,void 0,void 0,(function(){return bt(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.download(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.refreshAccessToken=function(){return _t(this,void 0,void 0,(function(){var e,t,n;return bt(this,(function(r){switch(r.label){case 0:this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken()),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._refreshAccessTokenPromise];case 2:return e=r.sent(),[3,4];case 3:return n=r.sent(),t=n,[3,4];case 4:if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return[2,e]}}))}))},e.prototype.getAccessToken=function(){return _t(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a,c;return bt(this,(function(u){switch(u.label){case 0:return e=this._cache.keys,t=e.accessTokenKey,n=e.accessTokenExpireKey,r=e.refreshTokenKey,[4,this._cache.getStoreAsync(r)];case 1:if(!u.sent())throw new Error(JSON.stringify({code:wt.OPERATION_FAIL,msg:"refresh token is not exist, your local data might be messed up, please retry after clear localStorage or sessionStorage"}));return[4,this._cache.getStoreAsync(t)];case 2:return o=u.sent(),s=Number,[4,this._cache.getStoreAsync(n)];case 3:return i=s.apply(void 0,[u.sent()]),a=!0,(c=this._shouldRefreshAccessTokenHook)?[4,this._shouldRefreshAccessTokenHook(o,i)]:[3,5];case 4:c=!u.sent(),u.label=5;case 5:return c&&(a=!1),o&&i&&!(i<Date.now())||!a?[3,7]:[4,this.refreshAccessToken()];case 6:return[2,u.sent()];case 7:return[2,{accessToken:o,accessTokenExpire:i}]}}))}))},e.prototype.request=function(e,t,n){return _t(this,void 0,void 0,(function(){var r,o,i,s,a,c,u,f,l,h,p,d,y,g,v,m,_,b,w,E,S,I,O,A,N,T;return bt(this,(function(R){switch(R.label){case 0:return r="x-tcb-trace_"+this.config.env,o="application/x-www-form-urlencoded",i=mt({action:e,dataVersion:"2020-01-10",env:this.config.env},t),-1!==Nt.indexOf(e)?[3,3]:(s=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(s)]);case 1:return R.sent()?(a=i,[4,this.getAccessToken()]):[3,3];case 2:a.access_token=R.sent().accessToken,R.label=3;case 3:if("storage.uploadFile"===e){for(u in c=new FormData)c.hasOwnProperty(u)&&void 0!==c[u]&&c.append(u,i[u]);o="multipart/form-data"}else for(u in o="application/json;charset=UTF-8",c={},i)void 0!==i[u]&&(c[u]=i[u]);return f={headers:{"content-type":o}},(null==n?void 0:n.onUploadProgress)&&(f.onUploadProgress=n.onUploadProgress),this.config.region&&(f.headers["X-TCB-Region"]=this.config.region),(l=this._localCache.getStore(r))&&(f.headers["X-TCB-Trace"]=l),Qe.runtime!==At.WEB&&(h=this.config,p=h.appSign,d=h.appSecret,y=Date.now(),g=d.appAccessKey,v=d.appAccessKeyId,m=Ot({data:{},timestamp:y,appAccessKeyId:v,appSign:p},g),f.headers["X-TCB-App-Source"]="timestamp="+y+";appAccessKeyId="+v+";appSign="+p+";sign="+m),_=t.parse,b=t.inQuery,w=t.search,E={env:this.config.env},_&&(E.parse=!0),b&&(E=mt(mt({},b),E)),S=yt(),I=S.BASE_URL,O=S.PROTOCOL,A=It(O,I,E),w&&(A+=w),[4,this.post(mt({url:A,data:c},f))];case 4:if(N=R.sent(),(T=N.header&&N.header["x-tcb-trace"])&&this._localCache.setStore(r,T),200!==Number(N.status)&&200!==Number(N.statusCode)||!N.data)throw new Error("network request error");return[2,N]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t={}),_t(this,void 0,void 0,(function(){var n;return bt(this,(function(r){switch(r.label){case 0:return[4,this.request(e,t,{onUploadProgress:t.onUploadProgress})];case 1:return"ACCESS_TOKEN_EXPIRED"!==(n=r.sent()).data.code||-1!==Nt.indexOf(e)?[3,4]:[4,this.refreshAccessToken()];case 2:return r.sent(),[4,this.request(e,t,{onUploadProgress:t.onUploadProgress})];case 3:n=r.sent(),r.label=4;case 4:if(n.data.code&&this._throwWhenRequestFail)throw new Error(JSON.stringify({code:wt.OPERATION_FAIL,msg:"["+n.data.code+"] "+n.data.message}));return[2,n.data]}}))}))},e.prototype._refreshAccessToken=function(e){return void 0===e&&(e=1),_t(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,u,f,l,h,p;return bt(this,(function(d){switch(d.label){case 0:return t=this._cache.keys,n=t.accessTokenKey,r=t.accessTokenExpireKey,o=t.refreshTokenKey,i=t.loginTypeKey,s=t.anonymousUuidKey,[4,this._cache.removeStoreAsync(n)];case 1:return d.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return d.sent(),[4,this._cache.getStoreAsync(o)];case 3:if(!(a=d.sent()))throw new Error(JSON.stringify({code:wt.INVALID_OPERATION,msg:"not login"}));return c={refresh_token:a},[4,this.request("auth.fetchAccessTokenWithRefreshToken",c)];case 4:return(u=d.sent()).data.code?"SIGN_PARAM_INVALID"!==(f=u.data.code)&&"REFRESH_TOKEN_EXPIRED"!==f&&"INVALID_REFRESH_TOKEN"!==f?[3,11]:[4,this._cache.getStoreAsync(i)]:[3,12];case 5:return d.sent()===lt.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===f?[4,this._cache.getStoreAsync(s)]:[3,9];case 6:return l=d.sent(),[4,this._cache.getStoreAsync(o)];case 7:return h=d.sent(),[4,this.send("auth.signInAnonymously",{anonymous_uuid:l,refresh_token:h})];case 8:if(p=d.sent(),this._setRefreshToken(p.refresh_token),e>=1)return[2,this._refreshAccessToken(--e)];throw new Error(JSON.stringify({code:wt.OPERATION_FAIL,message:"重试获取 refresh token 失败"}));case 9:return Jt.fire(gt),[4,this._cache.removeStoreAsync(o)];case 10:d.sent(),d.label=11;case 11:throw new Error(JSON.stringify({code:wt.NETWORK_ERROR,msg:"refresh access_token failed:"+u.data.code}));case 12:return u.data.access_token?(Jt.fire(vt),[4,this._cache.setStoreAsync(n,u.data.access_token)]):[3,15];case 13:return d.sent(),[4,this._cache.setStoreAsync(r,u.data.access_token_expire+Date.now())];case 14:return d.sent(),[2,{accessToken:u.data.access_token,accessTokenExpire:u.data.access_token_expire}];case 15:return u.data.refresh_token?[4,this._cache.removeStoreAsync(o)]:[3,19];case 16:return d.sent(),[4,this._cache.setStoreAsync(o,u.data.refresh_token)];case 17:return d.sent(),[4,this._refreshAccessToken()];case 18:d.sent(),d.label=19;case 19:return[2]}}))}))},e.prototype._setRefreshToken=function(e){return _t(this,void 0,void 0,(function(){var t,n,r,o;return bt(this,(function(i){switch(i.label){case 0:return t=this._cache.keys,n=t.accessTokenKey,r=t.accessTokenExpireKey,o=t.refreshTokenKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,e)];case 3:return i.sent(),[2]}}))}))},e}(),xt={};var Lt=function(){return Lt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Lt.apply(this,arguments)},Ct=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},kt=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Dt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},jt=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},Ut=Le.useAdapters,Mt=Le.useDefaultAdapter,qt=Le.RUNTIME,Wt=Pe.ERRORS,Ft=Pe.COMMUNITY_SITE_URL,Bt=Me.printWarn,$t=Te.catchErrorsDecorator,Ht={timeout:15e3,persistence:"local"},Gt=6e5,Kt={},Vt=function(){function e(e){this._config=e||this._config,this.authInstance=null}return Object.defineProperty(e.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return Qe},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return it(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return st(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return e=this._config.env,xt[e];var e},enumerable:!1,configurable:!0}),e.prototype.init=function(t){if(!t.env)throw new Error(JSON.stringify({code:Wt.INVALID_PARAMS,msg:"env must not be specified"}));if(Qe.adapter||this._useDefaultAdapter(),this.requestClient=new Qe.adapter.reqClass({timeout:t.timeout||5e3,timeoutMsg:"["+ft+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+t.timeout/1e3+"s"}),Qe.runtime!==qt.WEB){if(!t.appSecret)throw new Error(JSON.stringify({code:Wt.INVALID_PARAMS,msg:"invalid appSecret"}));var n=Qe.adapter.getAppSign?Qe.adapter.getAppSign():"";if(t.appSign&&n&&t.appSign!==n)throw new Error(JSON.stringify({code:Wt.INVALID_PARAMS,msg:"invalid appSign"}));if(n&&(t.appSign=n),!t.appSign)throw new Error(JSON.stringify({code:Wt.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=Lt(Lt({},Ht),t),this._config.timeout=this._formatTimeout(this._config.timeout);var r=this._config,o=r.env,i=r.persistence,s=r.debug,a=r.timeout,c=r.appSecret,u=r.appSign;ot({env:o,persistence:i,debug:s,platformInfo:this.platform}),function(e){xt[e.env]=new Pt(mt(mt({},e),{throw:!0}))}({env:o,region:t.region||"",timeout:a,appSecret:c,appSign:u}),t.region&&function(e,t,n){dt(t?"//"+e+"."+t+".tcb-api.tencentcloudapi.com/web":"//"+e+".ap-shanghai.tcb-api.tencentcloudapi.com/web",n)}(o,t.region||"");var f=new e(this._config);return f.requestClient=this.requestClient,f},e.prototype.updateConfig=function(e){var t=e.persistence,n=e.debug;this._config.persistence=t,this._config.debug=n,ot({env:this._config.env,persistence:t,debug:n,platformInfo:this.platform})},e.prototype.registerExtension=function(e){Kt[e.name]=e},e.prototype.invokeExtension=function(e,t){return Dt(this,void 0,void 0,(function(){var n;return jt(this,(function(r){switch(r.label){case 0:if(!(n=Kt[e]))throw new Error(JSON.stringify({code:Wt.INVALID_PARAMS,msg:"extension:"+e+" must be registered before invoke"}));return[4,n.invoke(t,this)];case 1:return[2,r.sent()]}}))}))},e.prototype.useAdapters=function(e){var t=Ut(e)||{},n=t.adapter,r=t.runtime;n&&(Qe.adapter=n),r&&(Qe.runtime=r)},e.prototype.registerHook=function(t){!function(e,t){var n=t.entity,r=t.target;if(!e.prototype.hasOwnProperty(r))throw new Error(JSON.stringify({code:Ye.INVALID_OPERATION,msg:"target:"+r+" is not exist"}));var o=e.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:Ye.INVALID_OPERATION,msg:"target:"+r+" is not a function which is the only type supports hook"}));e.prototype[r]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.call.apply(n,Je([this],e)),o.call.apply(o,Je([this],e))}}(e,t)},e.prototype.registerComponent=function(t){Xe(e,t)},e.prototype.registerVersion=function(e){!function(e){ut=e}(e)},e.prototype.registerSdkName=function(e){!function(e){ft=e,at(e)}(e)},e.prototype.registerEndPoint=function(e,t){dt(e,t)},e.prototype._useDefaultAdapter=function(){var e=Mt(),t=e.adapter,n=e.runtime;Qe.adapter=t,Qe.runtime=n},e.prototype._formatTimeout=function(e){switch(!0){case e>Gt:return Bt(Wt.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),Gt;case e<100:return Bt(Wt.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},Ct([$t({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ft]}),kt("design:type",Function),kt("design:paramtypes",[Object]),kt("design:returntype",e)],e.prototype,"init",null),Ct([$t({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ft]}),kt("design:type",Function),kt("design:paramtypes",[String,Object]),kt("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}(),Jt=new Vt;Jt.useAdapters(Ve);var Yt,Zt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Xt=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},zt=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request}return e.prototype.checkLocalLoginState=function(){return Zt(this,void 0,void 0,(function(){var e,t,n,r,o,i;return Xt(this,(function(s){switch(s.label){case 0:return e=this._cache.keys,t=e.accessTokenKey,n=e.accessTokenExpireKey,[4,this._cache.getStoreAsync(t)];case 1:return r=s.sent(),[4,this._cache.getStoreAsync(n)];case 2:return o=s.sent(),r?o&&o>Date.now()?[4,(i=new Dr({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,4]:[3,7];case 3:return s.sent(),[2,i];case 4:return[4,this._cache.removeStoreAsync(t)];case 5:return s.sent(),[4,this._cache.removeStoreAsync(n)];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},e.prototype.setRefreshToken=function(e){return Zt(this,void 0,void 0,(function(){var t,n,r,o;return Xt(this,(function(i){switch(i.label){case 0:return t=this._cache.keys,n=t.accessTokenKey,r=t.accessTokenExpireKey,o=t.refreshTokenKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,e)];case 3:return i.sent(),[2]}}))}))},e.prototype.setAccessToken=function(e,t){return Zt(this,void 0,void 0,(function(){var n,r,o;return Xt(this,(function(i){switch(i.label){case 0:return n=this._cache.keys,r=n.accessTokenKey,o=n.accessTokenExpireKey,[4,this._cache.setStoreAsync(r,e)];case 1:return i.sent(),[4,this._cache.setStoreAsync(o,t)];case 2:return i.sent(),[2]}}))}))},e.prototype.refreshUserInfo=function(){return Zt(this,void 0,void 0,(function(){var e;return Xt(this,(function(t){switch(t.label){case 0:return"auth.getUserInfo",[4,this._request.send("auth.getUserInfo",{})];case 1:return e=t.sent().data,[4,this.setLocalUserInfo(e)];case 2:return t.sent(),[2,e]}}))}))},e.prototype.setLocalUserInfo=function(e){return Zt(this,void 0,void 0,(function(){var t;return Xt(this,(function(n){switch(n.label){case 0:return t=this._cache.keys.userInfoKey,[4,this._cache.setStoreAsync(t,e)];case 1:return n.sent(),[2]}}))}))},e}();!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL",e.PHONE="PHONE"}(Yt||(Yt={}));var Qt=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),en=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},tn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},nn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},rn=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},on=Pe.getSdkName,sn=Pe.ERRORS,an=Pe.COMMUNITY_SITE_URL,cn=Le.RUNTIME,un=Me.getQuery,fn=Me.getHash,ln=Me.removeParam,hn=Me.printWarn,pn=Te.catchErrorsDecorator,dn=function(e){function t(t,n,r,o){var i=e.call(this,t)||this;return i._runtime=t.runtime,i._appid=n,i._scope=r,i._state=o||"weixin",i}return Qt(t,e),t.prototype.signIn=function(){return nn(this,void 0,void 0,(function(){return rn(this,(function(e){return[2,hn(sn.OPERATION_FAIL,"API signIn has been deprecated, please use signInWithRedirect insteed")]}))}))},t.prototype.signInWithRedirect=function(){return nn(this,void 0,void 0,(function(){return rn(this,(function(e){return[2,this._redirect()]}))}))},t.prototype.getRedirectResult=function(e){return nn(this,void 0,void 0,(function(){var t;return rn(this,(function(n){return(t=yn())?[2,this._signInWithCode(t,e)]:[2,null]}))}))},t.prototype.getLinkRedirectResult=function(e){return void 0===e&&(e={}),nn(this,void 0,void 0,(function(){var t,n,r,o,i,s;return rn(this,(function(a){return t=e.withUnionId,n=void 0!==t&&t,(r=yn())?(o=this._appid,c=this._scope,i="snsapi_login"===c?"WECHAT-OPEN":"WECHAT-PUBLIC",s=this._runtime===cn.WX_MP?"1":"0",[2,this._request.send("auth.linkWithWeixinCode",{payload:{appid:o,loginType:i,code:r,hybridMiniapp:s,withUnionId:n}})]):[2,null];var c}))}))},t.prototype._redirect=function(){var e=ln("code",location.href);e=ln("state",e),e=encodeURIComponent(e);var t="//open.weixin.qq.com/connect/oauth2/authorize";"snsapi_login"===this._scope&&(t="//open.weixin.qq.com/connect/qrconnect");try{location.href=t+"?appid="+this._appid+"&redirect_uri="+e+"&response_type=code&scope="+this._scope+"&state="+this._state+"#wechat_redirect"}catch(e){throw new Error("["+on()+"]["+sn.UNKOWN_ERROR+"]"+e)}},t.prototype._signInWithCode=function(e,t){return nn(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u;return rn(this,(function(f){switch(f.label){case 0:return n=this._cache.keys,r=n.accessTokenKey,o=n.accessTokenExpireKey,i=n.refreshTokenKey,l=this._scope,s="snsapi_login"===l?"WECHAT-OPEN":"WECHAT-PUBLIC",[4,this._getRefreshTokenByWXCode(this._appid,s,e,t)];case 1:return a=f.sent(),c=a.refreshToken,[4,this._cache.setStoreAsync(i,c)];case 2:return f.sent(),a.accessToken?[4,this._cache.setStoreAsync(r,a.accessToken)]:[3,4];case 3:f.sent(),f.label=4;case 4:return a.accessTokenExpire?[4,this._cache.setStoreAsync(o,String(a.accessTokenExpire+Date.now()))]:[3,6];case 5:f.sent(),f.label=6;case 6:return Cr.fire(Ur.LOGIN_STATE_CHANGED),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.WECHAT,persistence:this._config.persistence}),[4,this.refreshUserInfo()];case 7:return f.sent(),[4,(u=new Dr({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return f.sent(),[2,u]}var l}))}))},t.prototype._getRefreshTokenByWXCode=function(e,t,n,r){return void 0===r&&(r={}),nn(this,void 0,void 0,(function(){var o,i,s,a,c,u;return rn(this,(function(f){return o=r.withUnionId,i=void 0!==o&&o,s=r.createUser,a=void 0===s||s,c="snsapi_base"!==this._scope&&(r.syncUserInfo||!1),"auth.signIn",u=this._runtime===cn.WX_MP?"1":"0",[2,this._request.send("auth.signIn",{appid:e,loginType:t,hybridMiniapp:u,syncUserInfo:c,loginCredential:n,withUnionId:i,createUser:a}).then((function(e){if(e.code)throw new Error("["+on()+"]["+sn.OPERATION_FAIL+"] failed login via wechat: "+e.code);if(e.refresh_token)return{refreshToken:e.refresh_token,accessToken:e.access_token,accessTokenExpire:e.access_token_expire};throw new Error("["+on()+"]["+sn.OPERATION_FAIL+"] action:getJwt not return refreshToken")}))]}))}))},en([pn({title:"跳转微信公众号授权失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().signInWithRedirect() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+an]}),tn("design:type",Function),tn("design:paramtypes",[]),tn("design:returntype",Promise)],t.prototype,"signInWithRedirect",null),en([pn({title:"微信公众号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+an]}),tn("design:type",Function),tn("design:paramtypes",[Object]),tn("design:returntype",Promise)],t.prototype,"getRedirectResult",null),en([pn({title:"获取微信重定向绑定结果",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getLinkRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+an]}),tn("design:type",Function),tn("design:paramtypes",[Object]),tn("design:returntype",Promise)],t.prototype,"getLinkRedirectResult",null),t}(zt);function yn(){return un("code")||fn("code")}var gn=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),vn=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},mn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},_n=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},bn=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},wn=Pe.ERRORS,En=Pe.COMMUNITY_SITE_URL,Sn=Me.throwError,In=Me.isString,On=je.addEventListener,An=Te.catchErrorsDecorator,Nn=function(e){function t(t){var n=e.call(this,t)||this;return n._onConverted=n._onConverted.bind(n),On(Ur.ANONYMOUS_CONVERTED,n._onConverted),n}return gn(t,e),t.prototype.signIn=function(){return _n(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return bn(this,(function(a){switch(a.label){case 0:return[4,this._cache.updatePersistenceAsync("local")];case 1:return a.sent(),e=this._cache.keys,t=e.anonymousUuidKey,n=e.refreshTokenKey,[4,this._cache.getStoreAsync(t)];case 2:return r=a.sent(),[4,this._cache.getStoreAsync(n)];case 3:return o=a.sent(),[4,this._request.send("auth.signInAnonymously",{anonymous_uuid:r,refresh_token:o})];case 4:return(i=a.sent()).uuid&&i.refresh_token?[4,this._setAnonymousUUID(i.uuid)]:[3,10];case 5:return a.sent(),[4,this.setRefreshToken(i.refresh_token)];case 6:return a.sent(),[4,this._request.refreshAccessToken()];case 7:return a.sent(),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.ANONYMOUS,persistence:"local"}),Cr.fire(Ur.LOGIN_STATE_CHANGED),[4,(s=new Dr({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return a.sent(),[4,s.user.refresh()];case 9:return a.sent(),[2,s];case 10:throw new Error(JSON.stringify({code:wn.OPERATION_FAIL,msg:JSON.stringify(i)||"anonymous signIn failed"}))}}))}))},t.prototype.linkAndRetrieveDataWithTicket=function(e){return _n(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return bn(this,(function(c){switch(c.label){case 0:return In(e)||Sn(wn.INVALID_PARAMS,"ticket must be a string"),t=this._cache.keys,n=t.anonymousUuidKey,r=t.refreshTokenKey,[4,this._cache.getStoreAsync(n)];case 1:return o=c.sent(),[4,this._cache.getStoreAsync(r)];case 2:return i=c.sent(),[4,this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:o,refresh_token:i,ticket:e})];case 3:return(s=c.sent()).refresh_token?[4,this._clearAnonymousUUID()]:[3,8];case 4:return c.sent(),[4,this.setRefreshToken(s.refresh_token)];case 5:return c.sent(),[4,this._request.refreshAccessToken()];case 6:return c.sent(),Cr.fire(Ur.ANONYMOUS_CONVERTED,{env:this._config.env}),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{loginType:Yt.CUSTOM,persistence:"local"}),[4,(a=new Dr({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 7:return c.sent(),[2,a];case 8:Sn(wn.OPERATION_FAIL,JSON.stringify(s)||"linkAndRetrieveDataWithTicket failed"),c.label=9;case 9:return[2]}}))}))},t.prototype._setAnonymousUUID=function(e){return _n(this,void 0,void 0,(function(){var t,n,r;return bn(this,(function(o){switch(o.label){case 0:return t=this._cache.keys,n=t.anonymousUuidKey,r=t.loginTypeKey,[4,this._cache.removeStoreAsync(n)];case 1:return o.sent(),[4,this._cache.setStoreAsync(n,e)];case 2:return o.sent(),[4,this._cache.setStoreAsync(r,Yt.ANONYMOUS)];case 3:return o.sent(),[2]}}))}))},t.prototype._clearAnonymousUUID=function(){return _n(this,void 0,void 0,(function(){return bn(this,(function(e){switch(e.label){case 0:return[4,this._cache.removeStoreAsync(this._cache.keys.anonymousUuidKey)];case 1:return e.sent(),[2]}}))}))},t.prototype._onConverted=function(e){return _n(this,void 0,void 0,(function(){return bn(this,(function(t){switch(t.label){case 0:return e.data.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(this._config.persistence)];case 1:return t.sent(),[2]}}))}))},vn([An({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().anonymouseProvider().signIn() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+En]}),mn("design:type",Function),mn("design:paramtypes",[]),mn("design:returntype",Promise)],t.prototype,"signIn",null),t}(zt),Tn=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Rn=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Pn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},xn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Ln=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},Cn=Pe.ERRORS,kn=Pe.COMMUNITY_SITE_URL,Dn=Me.isString,jn=Te.catchErrorsDecorator,Un=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Tn(t,e),t.prototype.signIn=function(e){return xn(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return Ln(this,(function(c){switch(c.label){case 0:if(!Dn(e))throw new Error(JSON.stringify({code:Cn.INVALID_PARAMS,msg:"ticket must be a string"}));return t=this._cache.keys.refreshTokenKey,o=(r=this._request).send,i=["auth.signInWithTicket"],s={ticket:e},[4,this._cache.getStoreAsync(t)];case 1:return[4,o.apply(r,i.concat([(s.refresh_token=c.sent()||"",s)]))];case 2:return(n=c.sent()).refresh_token?[4,this.setRefreshToken(n.refresh_token)]:[3,7];case 3:return c.sent(),[4,this._request.refreshAccessToken()];case 4:return c.sent(),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.CUSTOM,persistence:this._config.persistence}),Cr.fire(Ur.LOGIN_STATE_CHANGED),[4,this.refreshUserInfo()];case 5:return c.sent(),[4,(a=new Dr({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 6:return c.sent(),[2,a];case 7:throw new Error(JSON.stringify({code:Cn.OPERATION_FAIL,msg:"custom signIn failed"}))}}))}))},Rn([jn({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().customAuthProvider().signIn() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kn]}),Pn("design:type",Function),Pn("design:paramtypes",[String]),Pn("design:returntype",Promise)],t.prototype,"signIn",null),t}(zt),Mn=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),qn=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Wn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Fn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Bn=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},$n=Me.throwError,Hn=Me.isString,Gn=Pe.ERRORS,Kn=Pe.COMMUNITY_SITE_URL,Vn=Te.catchErrorsDecorator,Jn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Mn(t,e),t.prototype.signIn=function(e,t){return Fn(this,void 0,void 0,(function(){var n,r,o,i,s;return Bn(this,(function(a){switch(a.label){case 0:return Hn(e)||$n(Gn.INVALID_PARAMS,"email must be a string"),n=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(n)||""})];case 1:return r=a.sent(),o=r.refresh_token,i=r.access_token,s=r.access_token_expire,o?[4,this.setRefreshToken(o)]:[3,8];case 2:return a.sent(),i&&s?[4,this.setAccessToken(i,s)]:[3,4];case 3:return a.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:a.sent(),a.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return a.sent(),Cr.fire(Ur.LOGIN_STATE_CHANGED),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.EMAIL,persistence:this._config.persistence}),[2,new Dr({envId:this._config.env,cache:this._cache,request:this._request})];case 8:r.code?$n(Gn.OPERATION_FAIL,"Email login fail["+r.code+"] "+r.message):$n(Gn.OPERATION_FAIL,"Email login fail"),a.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t){return Fn(this,void 0,void 0,(function(){return Bn(this,(function(n){return[2,this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})]}))}))},t.prototype.resetPassword=function(e){return Fn(this,void 0,void 0,(function(){return Bn(this,(function(t){return[2,this._request.send("auth.sendPasswordResetEmail",{email:e})]}))}))},t.prototype.resetPasswordWithToken=function(e,t){return Fn(this,void 0,void 0,(function(){return Bn(this,(function(n){return[2,this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})]}))}))},t.prototype.activate=function(e){return Fn(this,void 0,void 0,(function(){return Bn(this,(function(t){return[2,this._request.send("auth.activateEndUserMail",{token:e})]}))}))},qn([Vn({title:"邮箱密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().emailAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 邮箱地址与密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Kn]}),Wn("design:type",Function),Wn("design:paramtypes",[String,String]),Wn("design:returntype",Promise)],t.prototype,"signIn",null),qn([Vn({title:"邮箱注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithEmailAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Kn]}),Wn("design:type",Function),Wn("design:paramtypes",[String,String]),Wn("design:returntype",Promise)],t.prototype,"signUp",null),qn([Vn({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用 auth().sendPasswordResetEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经与当前用户绑定"," 4 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Kn]}),Wn("design:type",Function),Wn("design:paramtypes",[String]),Wn("design:returntype",Promise)],t.prototype,"resetPassword",null),qn([Vn({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Kn]}),Wn("design:type",Function),Wn("design:paramtypes",[String,String]),Wn("design:returntype",Promise)],t.prototype,"resetPasswordWithToken",null),qn([Vn({title:"邮箱激活失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Kn]}),Wn("design:type",Function),Wn("design:paramtypes",[String]),Wn("design:returntype",Promise)],t.prototype,"activate",null),t}(zt),Yn=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Zn=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Xn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},zn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Qn=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},er=Me.printWarn,tr=Pe.ERRORS,nr=Pe.COMMUNITY_SITE_URL,rr=Te.catchErrorsDecorator,or=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Yn(t,e),t.prototype.signIn=function(e,t){return zn(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u,f;return Qn(this,(function(l){switch(l.label){case 0:if("string"!=typeof e)throw new Error(JSON.stringify({code:tr.INVALID_PARAMS,msg:"username must be a string"}));return"string"!=typeof t&&(t="",er(tr.INVALID_PARAMS,"password is empty")),n=this._cache.keys.refreshTokenKey,i=(o=this._request).send,s=["auth.signIn"],a={loginType:Yt.USERNAME,username:e,password:t},[4,this._cache.getStoreAsync(n)];case 1:return[4,i.apply(o,s.concat([(a.refresh_token=l.sent()||"",a)]))];case 2:return r=l.sent(),c=r.refresh_token,u=r.access_token_expire,f=r.access_token,c?[4,this.setRefreshToken(c)]:[3,9];case 3:return l.sent(),f&&u?[4,this.setAccessToken(f,u)]:[3,5];case 4:return l.sent(),[3,7];case 5:return[4,this._request.refreshAccessToken()];case 6:l.sent(),l.label=7;case 7:return[4,this.refreshUserInfo()];case 8:return l.sent(),Cr.fire(Ur.LOGIN_STATE_CHANGED),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.USERNAME,persistence:this._config.persistence}),[2,new Dr({envId:this._config.env,cache:this._cache,request:this._request})];case 9:throw r.code?new Error(JSON.stringify({code:tr.OPERATION_FAIL,msg:"login by username failed:["+r.code+"] "+r.message})):new Error(JSON.stringify({code:tr.OPERATION_FAIL,msg:"login by username failed"}));case 10:return[2]}}))}))},Zn([rr({title:"用户名密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().signInWithUsernameAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录"," 3 - 用户名密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+nr]}),Xn("design:type",Function),Xn("design:paramtypes",[String,String]),Xn("design:returntype",Promise)],t.prototype,"signIn",null),t}(zt),ir=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),sr=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},ar=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},cr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},ur=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},fr=Me.throwError,lr=Me.isString,hr=Me.transformPhone,pr=Pe.ERRORS,dr=Pe.COMMUNITY_SITE_URL,yr=Te.catchErrorsDecorator,gr="SIGNIN",vr="SIGNUP",mr="FORCERESETPWD",_r=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ir(t,e),t.prototype.signIn=function(e){return cr(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,u;return ur(this,(function(f){switch(f.label){case 0:return t=e.phoneNumber,n=e.phoneCode,r=e.password,o=e.signMethod,lr(t)||fr(pr.INVALID_PARAMS,"phoneNumber must be a string"),lr(n)||lr(r)||fr(pr.INVALID_PARAMS,"phoneCode or password must be a string"),o||(o=gr),i=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:Yt.PHONE,phoneNumber:hr(t),phoneCode:n,password:r,refresh_token:this._cache.getStore(i)||"",signMethod:o})];case 1:return s=f.sent(),a=s.refresh_token,c=s.access_token,u=s.access_token_expire,a?[4,this.setRefreshToken(a)]:[3,8];case 2:return f.sent(),c&&u?[4,this.setAccessToken(c,u)]:[3,4];case 3:return f.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:f.sent(),f.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return f.sent(),Cr.fire(Ur.LOGIN_STATE_CHANGED),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.PHONE,persistence:this._config.persistence}),[2,new Dr({envId:this._config.env,cache:this._cache,request:this._request})];case 8:s.code?fr(pr.OPERATION_FAIL,"Phone login fail["+s.code+"] "+s.message):fr(pr.OPERATION_FAIL,"Phone login fail"),f.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t,n){return cr(this,void 0,void 0,(function(){return ur(this,(function(r){return[2,this.signIn({phoneNumber:e,phoneCode:t,password:n,signMethod:vr})]}))}))},t.prototype.forceResetPwd=function(e,t,n){return cr(this,void 0,void 0,(function(){return ur(this,(function(r){return[2,this.signIn({phoneNumber:e,phoneCode:t,password:n,signMethod:mr})]}))}))},sr([yr({title:"手机号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().SmsAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录"," 3 - 短信验证码/密码是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+dr]}),ar("design:type",Function),ar("design:paramtypes",[Object]),ar("design:returntype",Promise)],t.prototype,"signIn",null),sr([yr({title:"手机短信注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithPhoneCode() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+dr]}),ar("design:type",Function),ar("design:paramtypes",[String,String,String]),ar("design:returntype",Promise)],t.prototype,"signUp",null),sr([yr({title:"手机密码重置失败",messages:["请确认以下各项:"," 1 - 调用 auth().forceResetPwd() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+dr]}),ar("design:type",Function),ar("design:paramtypes",[String,String,String]),ar("design:returntype",Promise)],t.prototype,"forceResetPwd",null),t}(zt),br=function(){return br=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},br.apply(this,arguments)},wr=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Er=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Sr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Ir=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},Or=je.CloudbaseEventEmitter,Ar=Le.RUNTIME,Nr=Me.printWarn,Tr=Me.throwError,Rr=Me.transformPhone,Pr=Pe.ERRORS,xr=Pe.COMMUNITY_SITE_URL,Lr=Te.catchErrorsDecorator,Cr=new Or,kr=function(){function e(e){var t=e.cache,n=e.request;this._cache=t,this._request=n,this._setUserInfo()}return e.prototype.checkLocalInfo=function(){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(e){return this.uid=this._getLocalUserInfo("uid"),this.loginType=this._getLocalUserInfo("loginType"),this.openid=this._getLocalUserInfo("wxOpenId"),this.wxOpenId=this._getLocalUserInfo("wxOpenId"),this.wxPublicId=this._getLocalUserInfo("wxPublicId"),this.unionId=this._getLocalUserInfo("wxUnionId"),this.qqMiniOpenId=this._getLocalUserInfo("qqMiniOpenId"),this.customUserId=this._getLocalUserInfo("customUserId"),this.nickName=this._getLocalUserInfo("nickName"),this.gender=this._getLocalUserInfo("gender"),this.avatarUrl=this._getLocalUserInfo("avatarUrl"),this.email=this._getLocalUserInfo("email"),this.hasPassword=Boolean(this._getLocalUserInfo("hasPassword")),this.phone=this._getLocalUserInfo("phone"),this.username=this._getLocalUserInfo("username"),this.location={country:this._getLocalUserInfo("country"),province:this._getLocalUserInfo("province"),city:this._getLocalUserInfo("city")},[2]}))}))},e.prototype.checkLocalInfoAsync=function(){return Sr(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a,c,u,f,l,h,p,d,y,g,v;return Ir(this,(function(m){switch(m.label){case 0:return e=this,[4,this._getLocalUserInfoAsync("uid")];case 1:return e.uid=m.sent(),t=this,[4,this._getLocalUserInfoAsync("loginType")];case 2:return t.loginType=m.sent(),n=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 3:return n.openid=m.sent(),r=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 4:return r.wxOpenId=m.sent(),o=this,[4,this._getLocalUserInfoAsync("wxPublicId")];case 5:return o.wxPublicId=m.sent(),i=this,[4,this._getLocalUserInfoAsync("wxUnionId")];case 6:return i.unionId=m.sent(),s=this,[4,this._getLocalUserInfoAsync("qqMiniOpenId")];case 7:return s.qqMiniOpenId=m.sent(),a=this,[4,this._getLocalUserInfoAsync("customUserId")];case 8:return a.customUserId=m.sent(),c=this,[4,this._getLocalUserInfoAsync("nickName")];case 9:return c.nickName=m.sent(),u=this,[4,this._getLocalUserInfoAsync("gender")];case 10:return u.gender=m.sent(),f=this,[4,this._getLocalUserInfoAsync("avatarUrl")];case 11:return f.avatarUrl=m.sent(),l=this,[4,this._getLocalUserInfoAsync("email")];case 12:return l.email=m.sent(),h=this,p=Boolean,[4,this._getLocalUserInfoAsync("hasPassword")];case 13:return h.hasPassword=p.apply(void 0,[m.sent()]),d=this,[4,this._getLocalUserInfoAsync("phone")];case 14:return d.phone=m.sent(),y=this,[4,this._getLocalUserInfoAsync("username")];case 15:return y.username=m.sent(),g=this,v={},[4,this._getLocalUserInfoAsync("country")];case 16:return v.country=m.sent(),[4,this._getLocalUserInfoAsync("province")];case 17:return v.province=m.sent(),[4,this._getLocalUserInfoAsync("city")];case 18:return g.location=(v.city=m.sent(),v),[2]}}))}))},e.prototype.linkWithTicket=function(e){if("string"!=typeof e)throw new Error("ticket must be string");return this._request.send("auth.linkWithTicket",{ticket:e})},e.prototype.linkWithRedirect=function(e){e.signInWithRedirect()},e.prototype.getLinkedUidList=function(){return Sr(this,void 0,void 0,(function(){var e,t,n,r,o,i;return Ir(this,(function(s){switch(s.label){case 0:return[4,this._request.send("auth.getLinkedUidList",{})];case 1:for(e=s.sent().data,t=!1,n=e.users,r=0,o=n;r<o.length;r++)if((i=o[r]).wxOpenId&&i.wxPublicId){t=!0;break}return[2,{users:n,hasPrimaryUid:t}]}}))}))},e.prototype.setPrimaryUid=function(e){return this._request.send("auth.setPrimaryUid",{uid:e})},e.prototype.unlink=function(e){return this._request.send("auth.unlink",{platform:e})},e.prototype.update=function(e){return Sr(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return Ir(this,(function(c){switch(c.label){case 0:return t=e.nickName,n=e.gender,r=e.avatarUrl,o=e.province,i=e.country,s=e.city,[4,this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:r,province:o,country:i,city:s})];case 1:return a=c.sent().data,this._setLocalUserInfo(a),[2]}}))}))},e.prototype.updatePassword=function(e,t){return this._request.send("auth.updatePassword",{oldPassword:t,newPassword:e})},e.prototype.updateEmail=function(e,t){return this._request.send("auth.updateEmail",{newEmail:e,password:t})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&Tr(Pr.INVALID_PARAMS,"username must be a string"),this._request.send("auth.updateUsername",{username:e})},e.prototype.refresh=function(){return Sr(this,void 0,void 0,(function(){var e;return Ir(this,(function(t){switch(t.label){case 0:return"auth.getUserInfo",[4,this._request.send("auth.getUserInfo",{})];case 1:return e=t.sent().data,this._setLocalUserInfo(e),[2,e]}}))}))},e.prototype.linkWithPhoneNumber=function(e,t){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:Rr(e),phoneCode:t})]}))}))},e.prototype.updatePhoneNumber=function(e,t){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:Rr(e),phoneCode:t})]}))}))},e.prototype._getLocalUserInfo=function(e){var t=this._cache.keys.userInfoKey;return this._cache.getStore(t)[e]},e.prototype._getLocalUserInfoAsync=function(e){return Sr(this,void 0,void 0,(function(){var t;return Ir(this,(function(n){switch(n.label){case 0:return t=this._cache.keys.userInfoKey,[4,this._cache.getStoreAsync(t)];case 1:return[2,n.sent()[e]]}}))}))},e.prototype._setUserInfo=function(){var e=this,t=this._cache.keys.userInfoKey,n=this._cache.getStore(t);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl","phone","username"].forEach((function(t){e[t]=n[t]})),this.location={country:n.country,province:n.province,city:n.city}},e.prototype._setLocalUserInfo=function(e){var t=this._cache.keys.userInfoKey;this._cache.setStore(t,e),this._setUserInfo()},wr([Lr({title:"绑定自定义登录失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithTicket() 的语法或参数是否正确"," 2 - 此账户是否已经绑定自定义登录"," 3 - ticket 参数是否归属当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String]),Er("design:returntype",Promise)],e.prototype,"linkWithTicket",null),wr([Lr({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithRedirect() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方"," 3 - 此第三方是否已经授权","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[Object]),Er("design:returntype",void 0)],e.prototype,"linkWithRedirect",null),wr([Lr({title:"获取账户列表失败",messages:["请确认以下各项:"," 1 - 调用 User.getLinkedUidList() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[]),Er("design:returntype",Promise)],e.prototype,"getLinkedUidList",null),wr([Lr({title:"设置微信主账号失败",messages:["请确认以下各项:"," 1 - 调用 User.setPrimaryUid() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String]),Er("design:returntype",void 0)],e.prototype,"setPrimaryUid",null),wr([Lr({title:"接触绑定失败",messages:["请确认以下各项:"," 1 - 调用 User.unlink() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String]),Er("design:returntype",void 0)],e.prototype,"unlink",null),wr([Lr({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[Object]),Er("design:returntype",Promise)],e.prototype,"update",null),wr([Lr({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String,String]),Er("design:returntype",void 0)],e.prototype,"updatePassword",null),wr([Lr({title:"更新邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 User.updateEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String,String]),Er("design:returntype",void 0)],e.prototype,"updateEmail",null),wr([Lr({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String]),Er("design:returntype",void 0)],e.prototype,"updateUsername",null),wr([Lr({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[]),Er("design:returntype",Promise)],e.prototype,"refresh",null),wr([Lr({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().linkWithPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String,String]),Er("design:returntype",Promise)],e.prototype,"linkWithPhoneNumber",null),wr([Lr({title:"更新手机号失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String,String]),Er("design:returntype",Promise)],e.prototype,"updatePhoneNumber",null),e}(),Dr=function(){function e(e){var t=e.envId,n=e.cache,r=e.request;t||Tr(Pr.INVALID_PARAMS,"envId is not defined"),this._cache=n,this.user=new kr({cache:n,request:r})}return e.prototype.checkLocalState=function(){return Sr(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Ir(this,(function(a){return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,o=this._cache.getStore(t),i=this._cache.getStore(n),s=this._cache.getStore(r),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},this._loginType=this._cache.getStore(this._cache.keys.loginTypeKey),this.user.checkLocalInfo(),[2]}))}))},e.prototype.checkLocalStateAsync=function(){return Sr(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a;return Ir(this,(function(c){switch(c.label){case 0:return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,[4,this._cache.getStoreAsync(t)];case 1:return o=c.sent(),[4,this._cache.getStoreAsync(n)];case 2:return i=c.sent(),[4,this._cache.getStoreAsync(r)];case 3:return s=c.sent(),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},a=this,[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 4:return a._loginType=c.sent(),[4,this.user.checkLocalInfoAsync()];case 5:return c.sent(),[2]}}))}))},Object.defineProperty(e.prototype,"isAnonymousAuth",{get:function(){return this.loginType===Yt.ANONYMOUS},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCustomAuth",{get:function(){return this.loginType===Yt.CUSTOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isWeixinAuth",{get:function(){return this.loginType===Yt.WECHAT||this.loginType===Yt.WECHAT_OPEN||this.loginType===Yt.WECHAT_PUBLIC},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsernameAuth",{get:function(){return this.loginType===Yt.USERNAME},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loginType",{get:function(){return this._loginType},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPhoneAuth",{get:function(){return this.loginType===Yt.PHONE},enumerable:!1,configurable:!0}),e}(),jr=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request,this._runtime=e.runtime||Ar.WEB,Cr.on(Ur.LOGIN_TYPE_CHANGED,this._onLoginTypeChanged.bind(this))}return Object.defineProperty(e.prototype,"currentUser",{get:function(){if("async"!==this._cache.mode){var e=this.hasLoginState();return e&&e.user||null}Nr(Pr.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrenUser insteed")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loginType",{get:function(){return this._cache.getStore(this._cache.keys.loginTypeKey)},enumerable:!1,configurable:!0}),e.prototype.getCurrenUser=function(){return Sr(this,void 0,void 0,(function(){var e;return Ir(this,(function(t){switch(t.label){case 0:return[4,this.getLoginState()];case 1:return(e=t.sent())?[4,e.user.checkLocalInfoAsync()]:[3,3];case 2:return t.sent(),[2,e.user||null];case 3:return[2,null]}}))}))},e.prototype.getLoginType=function(){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(e){switch(e.label){case 0:return[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAccessToken=function(){return Sr(this,void 0,void 0,(function(){var e;return Ir(this,(function(t){switch(t.label){case 0:return e={},[4,this._request.getAccessToken()];case 1:return[2,(e.accessToken=t.sent().accessToken,e.env=this._config.env,e)]}}))}))},e.prototype.weixinAuthProvider=function(e){var t=e.appid,n=e.scope,r=e.state;return this._weixinAuthProvider||(this._weixinAuthProvider=new dn(br(br({},this._config),{cache:this._cache,request:this._request,runtime:this._runtime}),t,n,r)),this._weixinAuthProvider},e.prototype.anonymousAuthProvider=function(){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new Nn(br(br({},this._config),{cache:this._cache,request:this._request}))),this._anonymousAuthProvider},e.prototype.customAuthProvider=function(){return this._customAuthProvider||(this._customAuthProvider=new Un(br(br({},this._config),{cache:this._cache,request:this._request}))),this._customAuthProvider},e.prototype.emailAuthProvider=function(){return this._emailAuthProvider||(this._emailAuthProvider=new Jn(br(br({},this._config),{cache:this._cache,request:this._request}))),this._emailAuthProvider},e.prototype.usernameAuthProvider=function(){return this._usernameAuthProvider||(this._usernameAuthProvider=new or(br(br({},this._config),{cache:this._cache,request:this._request}))),this._usernameAuthProvider},e.prototype.phoneAuthProvider=function(){return this._phoneAuthProvider||(this._phoneAuthProvider=new _r(br(br({},this._config),{cache:this._cache,request:this._request}))),this._phoneAuthProvider},e.prototype.signInWithUsernameAndPassword=function(e,t){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(n){return[2,this.usernameAuthProvider().signIn(e,t)]}))}))},e.prototype.isUsernameRegistered=function(e){return Sr(this,void 0,void 0,(function(){var t;return Ir(this,(function(n){switch(n.label){case 0:return"string"!=typeof e&&Tr(Pr.INVALID_PARAMS,"username must be a string"),[4,this._request.send("auth.isUsernameRegistered",{username:e})];case 1:return[2,null==(t=n.sent().data)?void 0:t.isRegistered]}}))}))},e.prototype.signInWithEmailAndPassword=function(e,t){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(n){return[2,this.emailAuthProvider().signIn(e,t)]}))}))},e.prototype.signUpWithEmailAndPassword=function(e,t){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(n){return[2,this.emailAuthProvider().signUp(e,t)]}))}))},e.prototype.sendPasswordResetEmail=function(e){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(t){return[2,this.emailAuthProvider().resetPassword(e)]}))}))},e.prototype.signOut=function(){return Sr(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Ir(this,(function(a){switch(a.label){case 0:return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,o="auth.logout",[4,this._cache.getStoreAsync(t)];case 1:return(i=a.sent())?[4,this._request.send(o,{refresh_token:i})]:[2];case 2:return s=a.sent(),this._cache.removeStoreAsync(t),this._cache.removeStoreAsync(n),this._cache.removeStoreAsync(r),Cr.fire(Ur.LOGIN_STATE_CHANGED),Cr.fire(Ur.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Yt.NULL,persistence:this._config.persistence}),[2,s]}}))}))},e.prototype.onLoginStateChanged=function(e){return Sr(this,void 0,void 0,(function(){var t,n=this;return Ir(this,(function(r){switch(r.label){case 0:return Cr.on(Ur.LOGIN_STATE_CHANGED,(function(){return Sr(n,void 0,void 0,(function(){var t;return Ir(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return t=n.sent(),e.call(this,t),[2]}}))}))})),[4,this.getLoginState()];case 1:return t=r.sent(),e.call(this,t),[2]}}))}))},e.prototype.onLoginStateExpired=function(e){Cr.on(Ur.LOGIN_STATE_EXPIRED,e.bind(this))},e.prototype.onAccessTokenRefreshed=function(e){Cr.on(Ur.ACCESS_TOKEN_REFRESHD,e.bind(this))},e.prototype.onAnonymousConverted=function(e){Cr.on(Ur.ANONYMOUS_CONVERTED,e.bind(this))},e.prototype.onLoginTypeChanged=function(e){var t=this;Cr.on(Ur.LOGIN_TYPE_CHANGED,(function(){return Sr(t,void 0,void 0,(function(){var t;return Ir(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return t=n.sent(),e.call(this,t),[2]}}))}))}))},e.prototype.hasLoginState=function(){if("async"!==this._cache.mode){var e=this._cache.keys.refreshTokenKey;if(this._cache.getStore(e)){var t=new Dr({envId:this._config.env,cache:this._cache,request:this._request});return t.checkLocalState(),t}return null}Nr(Pr.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},e.prototype.getLoginState=function(){return Sr(this,void 0,void 0,(function(){var e,t;return Ir(this,(function(n){switch(n.label){case 0:return e=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(e)];case 1:return n.sent()?[4,(t=new Dr({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,3];case 2:return n.sent(),[2,t];case 3:return[2,null]}}))}))},e.prototype.shouldRefreshAccessToken=function(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)},e.prototype.getUserInfo=function(){return Sr(this,void 0,void 0,(function(){var e;return Ir(this,(function(t){switch(t.label){case 0:return"auth.getUserInfo",[4,this._request.send("auth.getUserInfo",{})];case 1:return(e=t.sent()).code?[2,e]:[2,br(br({},e.data),{requestId:e.seqId})]}}))}))},e.prototype.getAuthHeader=function(){var e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=this._cache.getStore(t);return{"x-cloudbase-credentials":this._cache.getStore(n)+"/@@/"+r}},e.prototype.getAuthHeaderAsync=function(){return Sr(this,void 0,void 0,(function(){var e,t,n,r;return Ir(this,(function(o){switch(o.label){case 0:return[4,this._request.refreshAccessToken()];case 1:return o.sent(),e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,[4,this._cache.getStoreAsync(t)];case 2:return r=o.sent(),[4,this._cache.getStoreAsync(n)];case 3:return[2,{"x-cloudbase-credentials":o.sent()+"/@@/"+r}]}}))}))},e.prototype.sendPhoneCode=function(e){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(t){switch(t.label){case 0:return[4,this._request.send("auth.sendPhoneCode",{phoneNumber:Rr(e)})];case 1:return[2,"Ok"===t.sent().data.SendStatus]}}))}))},e.prototype.signUpWithPhoneCode=function(e,t,n){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(r){return[2,this.phoneAuthProvider().signUp(e,t,n)]}))}))},e.prototype.signInWithPhoneCodeOrPassword=function(e){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(t){return[2,this.phoneAuthProvider().signIn(e)]}))}))},e.prototype.forceResetPwdByPhoneCode=function(e){return Sr(this,void 0,void 0,(function(){return Ir(this,(function(t){return[2,this.phoneAuthProvider().signIn(br(br({},e),{signMethod:mr}))]}))}))},e.prototype._onLoginTypeChanged=function(e){return Sr(this,void 0,void 0,(function(){var t,n,r;return Ir(this,(function(o){switch(o.label){case 0:return t=e.data,n=t.loginType,r=t.persistence,t.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(r)];case 1:return o.sent(),[4,this._cache.setStoreAsync(this._cache.keys.loginTypeKey,n)];case 2:return o.sent(),[2]}}))}))},wr([Lr({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[]),Er("design:returntype",Promise)],e.prototype,"getCurrenUser",null),wr([Lr({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String]),Er("design:returntype",Promise)],e.prototype,"isUsernameRegistered",null),wr([Lr({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[]),Er("design:returntype",Promise)],e.prototype,"signOut",null),wr([Lr({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[]),Er("design:returntype",Promise)],e.prototype,"getLoginState",null),wr([Lr({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[]),Er("design:returntype",Promise)],e.prototype,"getUserInfo",null),wr([Lr({title:"发送短信验证码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+xr]}),Er("design:type",Function),Er("design:paramtypes",[String]),Er("design:returntype",Promise)],e.prototype,"sendPhoneCode",null),e}(),Ur={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRED:"loginStateExpire",LOGIN_TYPE_CHANGED:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",ACCESS_TOKEN_REFRESHD:"refreshAccessToken"},Mr={name:"auth",namespace:"auth",injectEvents:{bus:Cr,events:[Ur.LOGIN_TYPE_CHANGED,Ur.LOGIN_STATE_EXPIRED,Ur.LOGIN_STATE_CHANGED,Ur.ACCESS_TOKEN_REFRESHD,Ur.ANONYMOUS_CONVERTED]},entity:function(e){if(void 0===e&&(e={region:"",persistence:"local"}),this.authInstance)return Nr(Pr.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var t=this.platform,n=t.adapter,r=t.runtime,o=e.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=this.config,s=i.env,a=i.persistence,c=i.debug;return this.authInstance=new jr({env:s,region:e.region,persistence:a,debug:c,cache:this.cache,request:this.request,runtime:r}),this.authInstance}};try{cloudbase.registerComponent(Mr)}catch(e){}var qr=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Wr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Fr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Br=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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=Pe.getSdkName,Hr=Pe.ERRORS,Gr=Pe.COMMUNITY_SITE_URL,Kr=Me.execCallback,Vr=Te.catchErrorsDecorator,Jr="functions",Yr=function(){function e(){}return e.prototype.callFunction=function(e,t){return Fr(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u,f,l,h,p;return Br(this,(function(d){switch(d.label){case 0:if(n=e.name,r=e.data,o=e.query,i=e.parse,s=e.search,!n)throw new Error(JSON.stringify({code:Hr.INVALID_PARAMS,msg:"["+Jr+".callFunction] invalid function name"}));try{a=r?JSON.stringify(r):""}catch(e){throw new Error(JSON.stringify({code:Hr.INVALID_PARAMS,msg:"["+Jr+".callFunction] invalid data"}))}c="functions.invokeFunction",u={inQuery:o,parse:i,search:s,function_name:n,request_data:a},f=this.request,d.label=1;case 1:return d.trys.push([1,3,,4]),[4,f.send(c,u)];case 2:if((l=d.sent()).code)return[2,Kr(t,null,l)];if(h=l.data.response_data,i)return[2,Kr(t,null,{result:h,requestId:l.requestId})];try{return h=JSON.parse(l.data.response_data),[2,Kr(t,null,{result:h,requestId:l.requestId})]}catch(e){Kr(t,new Error("["+$r()+"]["+Hr.INVALID_PARAMS+"]["+Jr+".callFunction] response data must be json"))}return[3,4];case 3:return p=d.sent(),Kr(t,p),[3,4];case 4:return[2]}}))}))},qr([Vr({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Gr]}),Wr("design:type",Function),Wr("design:paramtypes",[Object,Function]),Wr("design:returntype",Promise)],e.prototype,"callFunction",null),e}(),Zr=new Yr,Xr={name:Jr,entity:{callFunction:Zr.callFunction}};try{cloudbase.registerComponent(Xr)}catch(e){}var zr=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Qr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},eo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},to=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},no=Pe.getSdkName,ro=Pe.ERRORS,oo=Pe.COMMUNITY_SITE_URL,io=Me.isArray,so=Me.isString,ao=Me.isPalinObject,co=Me.execCallback,uo=Te.catchErrorsDecorator,fo="storage",lo=function(){function e(){}return e.prototype.uploadFile=function(e,t){return eo(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u,f,l,h,p,d,y,g;return to(this,(function(v){switch(v.label){case 0:if(n=e.cloudPath,r=e.filePath,o=e.onUploadProgress,!so(n)||!r)throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".uploadFile] invalid params"}));return"storage.getUploadMetadata",[4,(i=this.request).send("storage.getUploadMetadata",{path:n})];case 1:return s=v.sent(),a=s.data,c=a.url,u=a.authorization,f=a.token,l=a.fileId,h=a.cosFileId,p=a.download_url,d=s.requestId,y={key:n,signature:u,"x-cos-meta-fileid":h,success_action_status:"201","x-cos-security-token":f},[4,i.upload({url:c,data:y,file:r,name:n,onUploadProgress:o})];case 2:return 201===(g=v.sent()).statusCode?[2,co(t,null,{fileID:l,download_url:p,requestId:d})]:[2,co(t,new Error("["+no()+"]["+ro.OPERATION_FAIL+"]["+fo+"]:"+g.data))]}}))}))},e.prototype.getUploadMetadata=function(e,t){return eo(this,void 0,void 0,(function(){var n,r,o,i,s;return to(this,(function(a){switch(a.label){case 0:if(n=e.cloudPath,!so(n))throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".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,co(t,null,i)];case 3:return s=a.sent(),[2,co(t,s)];case 4:return[2]}}))}))},e.prototype.deleteFile=function(e,t){return eo(this,void 0,void 0,(function(){var n,r,o,i,s,a;return to(this,(function(c){switch(c.label){case 0:if(!(n=e.fileList)||!io(n)||0===n.length)throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".deleteFile] fileList must not be empty"}));for(r=0,o=n;r<o.length;r++)if(!(i=o[r])||!so(i))throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".deleteFile] fileID must be string"}));return"storage.batchDeleteFile",[4,this.request.send("storage.batchDeleteFile",{fileid_list:n})];case 1:return(s=c.sent()).code?[2,co(t,null,s)]:(a={fileList:s.data.delete_list,requestId:s.requestId},[2,co(t,null,a)])}}))}))},e.prototype.getTempFileURL=function(e,t){return eo(this,void 0,void 0,(function(){var n,r,o,i,s,a;return to(this,(function(c){switch(c.label){case 0:if(!(n=e.fileList)||!io(n)||0===n.length)throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".getTempFileURL] fileList must not be empty"}));for(r=[],o=0,i=n;o<i.length;o++)if(s=i[o],ao(s)){if(!s.hasOwnProperty("fileID")||!s.hasOwnProperty("maxAge"))throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".getTempFileURL] file info must include fileID and maxAge"}));r.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!so(s))throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".getTempFileURL] invalid fileList"}));r.push({fileid:s})}return"storage.batchGetDownloadUrl",[4,this.request.send("storage.batchGetDownloadUrl",{file_list:r})];case 1:return(a=c.sent()).code?[2,co(t,null,a)]:[2,co(t,null,{fileList:a.data.download_list,requestId:a.requestId})]}}))}))},e.prototype.downloadFile=function(e,t){return eo(this,void 0,void 0,(function(){var n,r,o,i,s,a;return to(this,(function(c){switch(c.label){case 0:if(n=e.fileID,!so(n))throw new Error(JSON.stringify({code:ro.INVALID_PARAMS,msg:"["+fo+".getTempFileURL] fileID must be string"}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}]})];case 1:return r=c.sent(),"SUCCESS"!==(o=r.fileList[0]).code?[2,co(t,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return a=c.sent(),[2,co(t,null,a)]}}))}))},zr([uo({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+oo]}),Qr("design:type",Function),Qr("design:paramtypes",[Object,Function]),Qr("design:returntype",Promise)],e.prototype,"uploadFile",null),zr([uo({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+oo]}),Qr("design:type",Function),Qr("design:paramtypes",[Object,Function]),Qr("design:returntype",Promise)],e.prototype,"getUploadMetadata",null),zr([uo({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+oo]}),Qr("design:type",Function),Qr("design:paramtypes",[Object,Function]),Qr("design:returntype",Promise)],e.prototype,"deleteFile",null),zr([uo({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+oo]}),Qr("design:type",Function),Qr("design:paramtypes",[Object,Function]),Qr("design:returntype",Promise)],e.prototype,"getTempFileURL",null),zr([uo({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+oo]}),Qr("design:type",Function),Qr("design:paramtypes",[Object,Function]),Qr("design:returntype",Promise)],e.prototype,"downloadFile",null),e}(),ho=new lo,po={name:fo,entity:{uploadFile:ho.uploadFile,deleteFile:ho.deleteFile,getTempFileURL:ho.getTempFileURL,downloadFile:ho.downloadFile,getUploadMetadata:ho.getUploadMetadata}};try{cloudbase.registerComponent(po)}catch(e){}var yo="__lodash_hash_undefined__",go=1/0,vo=9007199254740991,mo="[object Function]",_o="[object GeneratorFunction]",bo="[object Symbol]",wo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Eo=/^\w*$/,So=/^\./,Io=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Oo=/\\(\\)?/g,Ao=/^\[object .+?Constructor\]$/,No=/^(?:0|[1-9]\d*)$/,To="object"==typeof r&&r&&r.Object===Object&&r,Ro="object"==typeof self&&self&&self.Object===Object&&self,Po=To||Ro||Function("return this")();var xo,Lo=Array.prototype,Co=Function.prototype,ko=Object.prototype,Do=Po["__core-js_shared__"],jo=(xo=/[^.]+$/.exec(Do&&Do.keys&&Do.keys.IE_PROTO||""))?"Symbol(src)_1."+xo:"",Uo=Co.toString,Mo=ko.hasOwnProperty,qo=ko.toString,Wo=RegExp("^"+Uo.call(Mo).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Fo=Po.Symbol,Bo=Lo.splice,$o=ti(Po,"Map"),Ho=ti(Object,"create"),Go=Fo?Fo.prototype:void 0,Ko=Go?Go.toString:void 0;function Vo(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Jo(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Yo(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Zo(e,t,n){var r=e[t];Mo.call(e,t)&&si(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function Xo(e,t){for(var n=e.length;n--;)if(si(e[n][0],t))return n;return-1}function zo(e){if(!ci(e)||(t=e,jo&&jo in t))return!1;var t,n=function(e){var t=ci(e)?qo.call(e):"";return t==mo||t==_o}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Wo:Ao;return n.test(function(e){if(null!=e){try{return Uo.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function Qo(e,t,n,r){if(!ci(e))return e;t=function(e,t){if(ai(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||ui(e))return!0;return Eo.test(e)||!wo.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:function(e){return ai(e)?e:ri(e)}(t);for(var o=-1,i=t.length,s=i-1,a=e;null!=a&&++o<i;){var c=oi(t[o]),u=n;if(o!=s){var f=a[c];void 0===(u=r?r(f,c,a):void 0)&&(u=ci(f)?f:ni(t[o+1])?[]:{})}Zo(a,c,u),a=a[c]}return e}function ei(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function ti(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return zo(n)?n:void 0}function ni(e,t){return!!(t=null==t?vo:t)&&("number"==typeof e||No.test(e))&&e>-1&&e%1==0&&e<t}Vo.prototype.clear=function(){this.__data__=Ho?Ho(null):{}},Vo.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Vo.prototype.get=function(e){var t=this.__data__;if(Ho){var n=t[e];return n===yo?void 0:n}return Mo.call(t,e)?t[e]:void 0},Vo.prototype.has=function(e){var t=this.__data__;return Ho?void 0!==t[e]:Mo.call(t,e)},Vo.prototype.set=function(e,t){return this.__data__[e]=Ho&&void 0===t?yo:t,this},Jo.prototype.clear=function(){this.__data__=[]},Jo.prototype.delete=function(e){var t=this.__data__,n=Xo(t,e);return!(n<0)&&(n==t.length-1?t.pop():Bo.call(t,n,1),!0)},Jo.prototype.get=function(e){var t=this.__data__,n=Xo(t,e);return n<0?void 0:t[n][1]},Jo.prototype.has=function(e){return Xo(this.__data__,e)>-1},Jo.prototype.set=function(e,t){var n=this.__data__,r=Xo(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Yo.prototype.clear=function(){this.__data__={hash:new Vo,map:new($o||Jo),string:new Vo}},Yo.prototype.delete=function(e){return ei(this,e).delete(e)},Yo.prototype.get=function(e){return ei(this,e).get(e)},Yo.prototype.has=function(e){return ei(this,e).has(e)},Yo.prototype.set=function(e,t){return ei(this,e).set(e,t),this};var ri=ii((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(ui(e))return Ko?Ko.call(e):"";var t=e+"";return"0"==t&&1/e==-go?"-0":t}(t);var n=[];return So.test(e)&&n.push(""),e.replace(Io,(function(e,t,r,o){n.push(r?o.replace(Oo,"$1"):t||e)})),n}));function oi(e){if("string"==typeof e||ui(e))return e;var t=e+"";return"0"==t&&1/e==-go?"-0":t}function ii(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(ii.Cache||Yo),n}function si(e,t){return e===t||e!=e&&t!=t}ii.Cache=Yo;var ai=Array.isArray;function ci(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ui(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&qo.call(e)==bo}var fi=o((function(e,t,n){return null==e?e:Qo(e,t,n)})),li="__lodash_hash_undefined__",hi=1/0,pi="[object Function]",di="[object GeneratorFunction]",yi="[object Symbol]",gi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,vi=/^\w*$/,mi=/^\./,_i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bi=/\\(\\)?/g,wi=/^\[object .+?Constructor\]$/,Ei="object"==typeof r&&r&&r.Object===Object&&r,Si="object"==typeof self&&self&&self.Object===Object&&self,Ii=Ei||Si||Function("return this")();var Oi=Array.prototype,Ai=Function.prototype,Ni=Object.prototype,Ti=Ii["__core-js_shared__"],Ri=function(){var e=/[^.]+$/.exec(Ti&&Ti.keys&&Ti.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Pi=Ai.toString,xi=Ni.hasOwnProperty,Li=Ni.toString,Ci=RegExp("^"+Pi.call(xi).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ki=Ii.Symbol,Di=Oi.splice,ji=Ji(Ii,"Map"),Ui=Ji(Object,"create"),Mi=ki?ki.prototype:void 0,qi=Mi?Mi.toString:void 0;function Wi(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Fi(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Bi(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function $i(e,t){for(var n,r,o=e.length;o--;)if((n=e[o][0])===(r=t)||n!=n&&r!=r)return o;return-1}function Hi(e){if(!es(e)||(t=e,Ri&&Ri in t))return!1;var t,n=function(e){var t=es(e)?Li.call(e):"";return t==pi||t==di}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Ci:wi;return n.test(function(e){if(null!=e){try{return Pi.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function Gi(e,t){e=function(e,t){return 1==t.length?e:function(e,t){for(var n=0,r=(t=Yi(t,e)?[t]:Ki(t)).length;null!=e&&n<r;)e=e[Xi(t[n++])];return n&&n==r?e:void 0}(e,function(e,t,n){var r=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(o);++r<o;)i[r]=e[r+t];return i}(t,0,-1))}(e,t=Yi(t,e)?[t]:Ki(t));var n,r,o=Xi((r=(n=t)?n.length:0)?n[r-1]:void 0);return!(null!=e&&xi.call(e,o))||delete e[o]}function Ki(e){return Qi(e)?e:Zi(e)}function Vi(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function Ji(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Hi(n)?n:void 0}function Yi(e,t){if(Qi(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!ts(e))||(vi.test(e)||!gi.test(e)||null!=t&&e in Object(t))}Wi.prototype.clear=function(){this.__data__=Ui?Ui(null):{}},Wi.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Wi.prototype.get=function(e){var t=this.__data__;if(Ui){var n=t[e];return n===li?void 0:n}return xi.call(t,e)?t[e]:void 0},Wi.prototype.has=function(e){var t=this.__data__;return Ui?void 0!==t[e]:xi.call(t,e)},Wi.prototype.set=function(e,t){return this.__data__[e]=Ui&&void 0===t?li:t,this},Fi.prototype.clear=function(){this.__data__=[]},Fi.prototype.delete=function(e){var t=this.__data__,n=$i(t,e);return!(n<0)&&(n==t.length-1?t.pop():Di.call(t,n,1),!0)},Fi.prototype.get=function(e){var t=this.__data__,n=$i(t,e);return n<0?void 0:t[n][1]},Fi.prototype.has=function(e){return $i(this.__data__,e)>-1},Fi.prototype.set=function(e,t){var n=this.__data__,r=$i(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Bi.prototype.clear=function(){this.__data__={hash:new Wi,map:new(ji||Fi),string:new Wi}},Bi.prototype.delete=function(e){return Vi(this,e).delete(e)},Bi.prototype.get=function(e){return Vi(this,e).get(e)},Bi.prototype.has=function(e){return Vi(this,e).has(e)},Bi.prototype.set=function(e,t){return Vi(this,e).set(e,t),this};var Zi=zi((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(ts(e))return qi?qi.call(e):"";var t=e+"";return"0"==t&&1/e==-hi?"-0":t}(t);var n=[];return mi.test(e)&&n.push(""),e.replace(_i,(function(e,t,r,o){n.push(r?o.replace(bi,"$1"):t||e)})),n}));function Xi(e){if("string"==typeof e||ts(e))return e;var t=e+"";return"0"==t&&1/e==-hi?"-0":t}function zi(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(zi.Cache||Bi),n}zi.Cache=Bi;var Qi=Array.isArray;function es(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ts(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&Li.call(e)==yi}var ns=o((function(e,t){return null==e||Gi(e,t)})),rs={exports:{}};!function(e,t){var n="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",s="[object Boolean]",a="[object Date]",c="[object Function]",u="[object GeneratorFunction]",f="[object Map]",l="[object Number]",h="[object Object]",p="[object Promise]",d="[object RegExp]",y="[object Set]",g="[object String]",v="[object Symbol]",m="[object WeakMap]",_="[object ArrayBuffer]",b="[object DataView]",w="[object Float32Array]",E="[object Float64Array]",S="[object Int8Array]",I="[object Int16Array]",O="[object Int32Array]",A="[object Uint8Array]",N="[object Uint8ClampedArray]",T="[object Uint16Array]",R="[object Uint32Array]",P=/\w*$/,x=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,C={};C[i]=C["[object Array]"]=C[_]=C[b]=C[s]=C[a]=C[w]=C[E]=C[S]=C[I]=C[O]=C[f]=C[l]=C[h]=C[d]=C[y]=C[g]=C[v]=C[A]=C[N]=C[T]=C[R]=!0,C["[object Error]"]=C[c]=C[m]=!1;var k="object"==typeof r&&r&&r.Object===Object&&r,D="object"==typeof self&&self&&self.Object===Object&&self,j=k||D||Function("return this")(),U=t&&!t.nodeType&&t,M=U&&e&&!e.nodeType&&e,q=M&&M.exports===U;function W(e,t){return e.set(t[0],t[1]),e}function F(e,t){return e.add(t),e}function B(e,t,n,r){var o=-1,i=e?e.length:0;for(r&&i&&(n=e[++o]);++o<i;)n=t(n,e[o],o,e);return n}function $(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function H(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function G(e,t){return function(n){return e(t(n))}}function K(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var V=Array.prototype,J=Function.prototype,Y=Object.prototype,Z=j["__core-js_shared__"],X=function(){var e=/[^.]+$/.exec(Z&&Z.keys&&Z.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),z=J.toString,Q=Y.hasOwnProperty,ee=Y.toString,te=RegExp("^"+z.call(Q).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ne=q?j.Buffer:void 0,re=j.Symbol,oe=j.Uint8Array,ie=G(Object.getPrototypeOf,Object),se=Object.create,ae=Y.propertyIsEnumerable,ce=V.splice,ue=Object.getOwnPropertySymbols,fe=ne?ne.isBuffer:void 0,le=G(Object.keys,Object),he=Ue(j,"DataView"),pe=Ue(j,"Map"),de=Ue(j,"Promise"),ye=Ue(j,"Set"),ge=Ue(j,"WeakMap"),ve=Ue(Object,"create"),me=Be(he),_e=Be(pe),be=Be(de),we=Be(ye),Ee=Be(ge),Se=re?re.prototype:void 0,Ie=Se?Se.valueOf:void 0;function Oe(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Ae(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Ne(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Te(e){this.__data__=new Ae(e)}function Re(e,t){var n=He(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Ge(e)}(e)&&Q.call(e,"callee")&&(!ae.call(e,"callee")||ee.call(e)==i)}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,o=!!r;for(var s in e)!t&&!Q.call(e,s)||o&&("length"==s||We(s,r))||n.push(s);return n}function Pe(e,t,n){var r=e[t];Q.call(e,t)&&$e(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function xe(e,t){for(var n=e.length;n--;)if($e(e[n][0],t))return n;return-1}function Le(e,t,n,r,o,p,m){var x;if(r&&(x=p?r(e,o,p,m):r(e)),void 0!==x)return x;if(!Je(e))return e;var L=He(e);if(L){if(x=function(e){var t=e.length,n=e.constructor(t);t&&"string"==typeof e[0]&&Q.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!t)return function(e,t){var n=-1,r=e.length;t||(t=Array(r));for(;++n<r;)t[n]=e[n];return t}(e,x)}else{var k=qe(e),D=k==c||k==u;if(Ke(e))return function(e,t){if(t)return e.slice();var n=new e.constructor(e.length);return e.copy(n),n}(e,t);if(k==h||k==i||D&&!p){if($(e))return p?e:{};if(x=function(e){return"function"!=typeof e.constructor||Fe(e)?{}:(t=ie(e),Je(t)?se(t):{});var t}(D?{}:e),!t)return function(e,t){return De(e,Me(e),t)}(e,function(e,t){return e&&De(t,Ye(t),e)}(x,e))}else{if(!C[k])return p?e:{};x=function(e,t,n,r){var o=e.constructor;switch(t){case _:return ke(e);case s:case a:return new o(+e);case b:return function(e,t){var n=t?ke(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,r);case w:case E:case S:case I:case O:case A:case N:case T:case R:return function(e,t){var n=t?ke(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}(e,r);case f:return function(e,t,n){var r=t?n(H(e),!0):H(e);return B(r,W,new e.constructor)}(e,r,n);case l:case g:return new o(e);case d:return function(e){var t=new e.constructor(e.source,P.exec(e));return t.lastIndex=e.lastIndex,t}(e);case y:return function(e,t,n){var r=t?n(K(e),!0):K(e);return B(r,F,new e.constructor)}(e,r,n);case v:return i=e,Ie?Object(Ie.call(i)):{}}var i}(e,k,Le,t)}}m||(m=new Te);var j=m.get(e);if(j)return j;if(m.set(e,x),!L)var U=n?function(e){return function(e,t,n){var r=t(e);return He(e)?r:function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}(r,n(e))}(e,Ye,Me)}(e):Ye(e);return function(e,t){for(var n=-1,r=e?e.length:0;++n<r&&!1!==t(e[n],n,e););}(U||e,(function(o,i){U&&(o=e[i=o]),Pe(x,i,Le(o,t,n,r,i,e,m))})),x}function Ce(e){return!(!Je(e)||(t=e,X&&X in t))&&(Ve(e)||$(e)?te:x).test(Be(e));var t}function ke(e){var t=new e.constructor(e.byteLength);return new oe(t).set(new oe(e)),t}function De(e,t,n,r){n||(n={});for(var o=-1,i=t.length;++o<i;){var s=t[o],a=r?r(n[s],e[s],s,n,e):void 0;Pe(n,s,void 0===a?e[s]:a)}return n}function je(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function Ue(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Ce(n)?n:void 0}Oe.prototype.clear=function(){this.__data__=ve?ve(null):{}},Oe.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Oe.prototype.get=function(e){var t=this.__data__;if(ve){var r=t[e];return r===n?void 0:r}return Q.call(t,e)?t[e]:void 0},Oe.prototype.has=function(e){var t=this.__data__;return ve?void 0!==t[e]:Q.call(t,e)},Oe.prototype.set=function(e,t){return this.__data__[e]=ve&&void 0===t?n:t,this},Ae.prototype.clear=function(){this.__data__=[]},Ae.prototype.delete=function(e){var t=this.__data__,n=xe(t,e);return!(n<0)&&(n==t.length-1?t.pop():ce.call(t,n,1),!0)},Ae.prototype.get=function(e){var t=this.__data__,n=xe(t,e);return n<0?void 0:t[n][1]},Ae.prototype.has=function(e){return xe(this.__data__,e)>-1},Ae.prototype.set=function(e,t){var n=this.__data__,r=xe(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Ne.prototype.clear=function(){this.__data__={hash:new Oe,map:new(pe||Ae),string:new Oe}},Ne.prototype.delete=function(e){return je(this,e).delete(e)},Ne.prototype.get=function(e){return je(this,e).get(e)},Ne.prototype.has=function(e){return je(this,e).has(e)},Ne.prototype.set=function(e,t){return je(this,e).set(e,t),this},Te.prototype.clear=function(){this.__data__=new Ae},Te.prototype.delete=function(e){return this.__data__.delete(e)},Te.prototype.get=function(e){return this.__data__.get(e)},Te.prototype.has=function(e){return this.__data__.has(e)},Te.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Ae){var r=n.__data__;if(!pe||r.length<199)return r.push([e,t]),this;n=this.__data__=new Ne(r)}return n.set(e,t),this};var Me=ue?G(ue,Object):function(){return[]},qe=function(e){return ee.call(e)};function We(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||L.test(e))&&e>-1&&e%1==0&&e<t}function Fe(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Y)}function Be(e){if(null!=e){try{return z.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function $e(e,t){return e===t||e!=e&&t!=t}(he&&qe(new he(new ArrayBuffer(1)))!=b||pe&&qe(new pe)!=f||de&&qe(de.resolve())!=p||ye&&qe(new ye)!=y||ge&&qe(new ge)!=m)&&(qe=function(e){var t=ee.call(e),n=t==h?e.constructor:void 0,r=n?Be(n):void 0;if(r)switch(r){case me:return b;case _e:return f;case be:return p;case we:return y;case Ee:return m}return t});var He=Array.isArray;function Ge(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=o}(e.length)&&!Ve(e)}var Ke=fe||function(){return!1};function Ve(e){var t=Je(e)?ee.call(e):"";return t==c||t==u}function Je(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ye(e){return Ge(e)?Re(e):function(e){if(!Fe(e))return le(e);var t=[];for(var n in Object(e))Q.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return Le(e,!0,!0)}}(rs,rs.exports);var os=o(rs.exports);function is(e){return void 0===e&&(e=""),(e?e+"_":"")+ +new Date+"_"+Math.random()}var ss,as=function(e){this.close=e.close,this.onChange=e.onChange,this.onError=e.onError,e.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return e.virtualClient}})},cs=function(e){var t,n,r=e.id,o=e.docChanges,i=e.docs,s=e.msgType,a=e.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return t||(t=JSON.parse(JSON.stringify(o))),t},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}})},us=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),fs=function(e){function t(t){var n=e.call(this,"Watch Error "+JSON.stringify(t.msgData)+" (requestid: "+t.requestId+")")||this;return n.isRealtimeErrorMessageError=!0,n.payload=t,n}return us(t,e),t}(Error),ls=function(e){return null==e?void 0:e.isRealtimeErrorMessageError},hs=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="timeout",t.payload=null,t.generic=!0,t}return us(t,e),t}(Error),ps=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="cancelled",t.payload=null,t.generic=!0,t}return us(t,e),t}(Error),ds=function(e){function t(t){var n=e.call(this,t.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: "+this.errCode+" "+(ys[this.errCode]||"")+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e}}}),n.errCode=t.errCode||"UNKNOWN_ERROR",n.errMsg=t.errMsg,n}return us(t,e),Object.defineProperty(t.prototype,"message",{get:function(){return"errCode: "+this.errCode+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e},enumerable:!1,configurable:!0}),t}(Error),ys={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"},gs=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},vs=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},ms=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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 e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};!function(e){e.LOGGINGIN="LOGGINGIN",e.INITING="INITING",e.REBUILDING="REBUILDING",e.ACTIVE="ACTIVE",e.ERRORED="ERRORED",e.CLOSING="CLOSING",e.CLOSED="CLOSED",e.PAUSED="PAUSED",e.RESUMING="RESUMING"}(ss||(ss={}));var bs=function(){function e(e){var t=this;this.watchStatus=ss.INITING,this._login=function(e,n){return vs(t,void 0,void 0,(function(){var t;return ms(this,(function(r){switch(r.label){case 0:return this.watchStatus=ss.LOGGINGIN,[4,this.login(e,n)];case 1:return t=r.sent(),this.envId||(this.envId=t.envId),[2,t]}}))}))},this.initWatch=function(e){return vs(t,void 0,void 0,(function(){var t,n=this;return ms(this,(function(r){switch(r.label){case 0:if(this._initWatchPromise)return[2,this._initWatchPromise];this._initWatchPromise=new Promise((function(t,r){return vs(n,void 0,void 0,(function(){var n,o,i,s,a,c,u,f,l,h;return ms(this,(function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),this.watchStatus===ss.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):[4,this._login(this.envId,e)];case 1:return n=p.sent().envId,this.watchStatus===ss.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(this.watchStatus=ss.INITING,o={watchId:this.watchId,requestId:is(),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=p.sent(),s=i.msgData,a=s.events,c=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:c-1,currentDocs:[]},a.length>0){for(u=0,f=a;u<f.length;u++)f[u].ID=c;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=c,l=new cs({id:c,docChanges:[],docs:[],type:"init"}),this.listener.onChange(l),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=ss.ACTIVE,this._availableRetries.INIT_WATCH=2,t(),[3,4];case 3:return h=p.sent(),this.handleWatchEstablishmentError(h,{operationName:"INIT_WATCH",resolve:t,reject:r}),[3,4];case 4:return[2]}}))}))})),t=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._initWatchPromise];case 2:return r.sent(),t=!0,[3,4];case 3:return this._initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch "+(t?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(e){return vs(t,void 0,void 0,(function(){var t,n=this;return ms(this,(function(r){switch(r.label){case 0:if(this._rebuildWatchPromise)return[2,this._rebuildWatchPromise];this._rebuildWatchPromise=new Promise((function(t,r){return vs(n,void 0,void 0,(function(){var n,o,i,s;return ms(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===ss.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):[4,this._login(this.envId,e)];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===ss.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):(this.watchStatus=ss.REBUILDING,o={watchId:this.watchId,requestId:is(),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=ss.ACTIVE,this._availableRetries.REBUILD_WATCH=2,t(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:t,reject:r}),[3,4];case 4:return[2]}}))}))})),t=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._rebuildWatchPromise];case 2:return r.sent(),t=!0,[3,4];case 3:return this._rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch "+(t?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(e,n){return vs(t,void 0,void 0,(function(){var t,r,o,i=this;return ms(this,(function(s){return t="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new ds({errCode:t?ys.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:ys.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),n.reject(e)},o=function(e){i.useRetryTicket(n.operationName)?t?(i._initWatchPromise=void 0,n.resolve(i.initWatch(e))):(i._rebuildWatchPromise=void 0,n.resolve(i.rebuildWatch(e))):r()},this.handleCommonError(e,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){return vs(i,void 0,void 0,(function(){var e,t=this;return ms(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),e=function(){return vs(t,void 0,void 0,(function(){return ms(this,(function(e){switch(e.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return e.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,e()];case 1:return r.sent(),[3,7];case 2:return[4,gs(100)];case 3:return r.sent(),this.watchStatus!==ss.PAUSED?[3,4]:(n.reject(new ps(n.operationName+" cancelled due to pause after unknownError")),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,e()];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 vs(t,void 0,void 0,(function(){var e,t,n;return ms(this,(function(r){switch(r.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==ss.ACTIVE)return this.watchStatus=ss.CLOSED,this.onWatchClose(this,e),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=ss.CLOSING,t={watchId:this.watchId,requestId:is(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=ss.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,e),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){t.clearACKSchedule(),t._ackTimeoutId=setTimeout((function(){t._waitExpectedTimeoutId?t.scheduleSendACK():t.sendACK()}),1e4)},this.clearACKSchedule=function(){t._ackTimeoutId&&clearTimeout(t._ackTimeoutId)},this.sendACK=function(){return vs(t,void 0,void 0,(function(){var e,t,n;return ms(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==ss.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(e={watchId:this.watchId,requestId:is(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:e})]):(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(t=r.sent(),ls(t))switch((n=t.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 ds({errCode:ys.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--,this.scheduleSendACK()):this.closeWithError(new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if(ls(e)){switch(e.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void t.onSignError(e);default:return void t.onNotRetryableError(e)}}else{if(function(e){return"timeout"===e.type}(e))return void t.onTimeoutError(e);if(function(e){return"cancelled"===e.type}(e))return void t.onCancelledError(e)}t.onUnknownError(e)},this.watchId="watchid_"+ +new Date+"_"+Math.random(),this.envId=e.envId,this.collectionName=e.collectionName,this.query=e.query,this.limit=e.limit,this.orderBy=e.orderBy,this.send=e.send,this.login=e.login,this.isWSConnected=e.isWSConnected,this.onceWSConnected=e.onceWSConnected,this.getWaitExpectedTimeoutLength=e.getWaitExpectedTimeoutLength,this.onWatchStart=e.onWatchStart,this.onWatchClose=e.onWatchClose,this.debug=e.debug,this._availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new as({close:this.closeWatch,onChange:e.onChange,onError:e.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return e.prototype.onMessage=function(e){var t=this;switch(this.watchStatus){case ss.PAUSED:if("ERROR"!==e.msgType)return;break;case ss.LOGGINGIN:case ss.INITING:case ss.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while "+this.watchStatus);case ss.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case ss.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(),e.msgType){case"NEXT_EVENT":console.warn("nextevent "+e.msgData.currEvent+" ignored",e),this.handleServerEvents(e);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<e.msgData.currEvent&&(this.sessionInfo.expectEventId=e.msgData.currEvent,this.clearWaitExpectedEvent(),this._waitExpectedTimeoutId=setTimeout((function(){t.rebuildWatch()}),this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength "+this.getWaitExpectedTimeoutLength()));break;case"ERROR":this.closeWithError(new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:e.msgData.code+" - "+e.msgData.message}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg "+e.msgType+": ",e)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},e.prototype.closeWithError=function(e){this.watchStatus=ss.ERRORED,this.clearACKSchedule(),this.listener.onError(e),this.onWatchClose(this,this.sessionInfo&&this.sessionInfo.queryID||""),console.log("[realtime] client closed ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.pause=function(){this.watchStatus=ss.PAUSED,console.log("[realtime] client paused ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.resume=function(){return vs(this,void 0,void 0,(function(){var e;return ms(this,(function(t){switch(t.label){case 0:this.watchStatus=ss.RESUMING,console.log("[realtime] client resuming with "+(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH")+" ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return t.sent(),console.log("[realtime] client successfully resumed ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),[3,4];case 3:return e=t.sent(),console.error("[realtime] client resume failed ("+this.collectionName+" "+this.query+") ("+this.watchId+")",e),[3,4];case 4:return[2]}}))}))},e.prototype.useRetryTicket=function(e){return!!(this._availableRetries[e]&&this._availableRetries[e]>0)&&(this._availableRetries[e]--,console.log("[realtime] "+e+" use a retry ticket, now only "+this._availableRetries[e]+" retry left"),!0)},e.prototype.handleServerEvents=function(e){return vs(this,void 0,void 0,(function(){var t;return ms(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this._handleServerEvents(e)];case 1:return n.sent(),this._postHandleServerEventsValidityCheck(e),[3,3];case 2:throw t=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",t),t;case 3:return[2]}}))}))},e.prototype._handleServerEvents=function(e){return vs(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,u,f,l,h;return ms(this,(function(p){switch(p.label){case 0:if(t=e.requestId,n=e.msgData.events,r=e.msgType,!n.length||!this.sessionInfo)return[2];o=this.sessionInfo;try{i=n.map(ws)}catch(e){return this.closeWithError(new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}s=_s(o.currentDocs),a=!1,c=function(n,c){var f,l,h,p,d,y,g,v,m,_,b;return ms(this,(function(w){switch(w.label){case 0:return f=i[n],o.currentEventId>=f.id?(!i[n-1]||f.id>i[n-1].id?console.warn("[realtime] duplicate event received, cur "+o.currentEventId+" but got "+f.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 "+t+")"),[2,"continue"]):[3,1];case 1:if(o.currentEventId!==f.id-1)return[3,2];switch(f.dataType){case"update":if(!f.doc)switch(f.queueType){case"update":case"dequeue":if(l=s.find((function(e){return e._id===f.docId})),l){if(y=os(l),f.updatedFields)for(d in f.updatedFields)fi(y,d,f.updatedFields[d]);if(f.removedFields)for(h=0,p=f.removedFields;h<p.length;h++)d=p[h],ns(y,d);f.doc=y}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw g=new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '+e.requestId+")"}),u.closeWithError(g),g}break;case"replace":if(!f.doc)throw g=new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '+e.requestId+")"}),u.closeWithError(g),g;break;case"remove":(y=s.find((function(e){return e._id===f.docId})))?f.doc=y:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!f.doc)switch(f.queueType){case"dequeue":(y=s.find((function(e){return e._id===f.docId})))?f.doc=y:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw g=new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '+e.requestId+")"}),u.closeWithError(g),g}}switch(f.queueType){case"init":a?s.push(f.doc):(a=!0,s=[f.doc]);break;case"enqueue":s.push(f.doc);break;case"dequeue":v=s.findIndex((function(e){return e._id===f.docId})),v>-1?s.splice(v,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":v=s.findIndex((function(e){return e._id===f.docId})),v>-1?s[v]=f.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===c-1||i[n+1]&&i[n+1].id!==f.id)&&(m=_s(s),_=i.slice(0,n+1).filter((function(e){return e.id===f.id})),u.sessionInfo.currentEventId=f.id,u.sessionInfo.currentDocs=s,b=new cs({id:f.id,docChanges:_,docs:m,msgType:r}),u.listener.onChange(b)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur "+u.sessionInfo.currentEventId+" but got "+f.id),[4,u.rebuildWatch()];case 3:return w.sent(),[2,{value:void 0}];case 4:return[2]}}))},u=this,f=0,l=i.length,p.label=1;case 1:return f<l?[5,c(f,l)]:[3,4];case 2:if("object"==typeof(h=p.sent()))return[2,h.value];p.label=3;case 3:return f++,[3,1];case 4:return[2]}}))}))},e.prototype._postHandleServerEventsValidityCheck=function(e){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<e.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")},e.prototype.clearWaitExpectedEvent=function(){this._waitExpectedTimeoutId&&(clearTimeout(this._waitExpectedTimeoutId),this._waitExpectedTimeoutId=void 0)},e}();function ws(e){var t={id:e.ID,dataType:e.DataType,queueType:e.QueueType,docId:e.DocID,doc:e.Doc&&"{}"!==e.Doc?JSON.parse(e.Doc):void 0};return"update"===e.DataType&&(e.UpdatedFields&&(t.updatedFields=JSON.parse(e.UpdatedFields)),(e.removedFields||e.RemovedFields)&&(t.removedFields=JSON.parse(e.removedFields))),t}var Es,Ss={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(e){e[e.NormalClosure=1e3]="NormalClosure",e[e.GoingAway=1001]="GoingAway",e[e.ProtocolError=1002]="ProtocolError",e[e.UnsupportedData=1003]="UnsupportedData",e[e.NoStatusReceived=1005]="NoStatusReceived",e[e.AbnormalClosure=1006]="AbnormalClosure",e[e.InvalidFramePayloadData=1007]="InvalidFramePayloadData",e[e.PolicyViolation=1008]="PolicyViolation",e[e.MessageTooBig=1009]="MessageTooBig",e[e.MissingExtension=1010]="MissingExtension",e[e.InternalError=1011]="InternalError",e[e.ServiceRestart=1012]="ServiceRestart",e[e.TryAgainLater=1013]="TryAgainLater",e[e.BadGateway=1014]="BadGateway",e[e.TLSHandshake=1015]="TLSHandshake",e[e.ReconnectWebSocket=3e3]="ReconnectWebSocket",e[e.NoRealtimeListeners=3001]="NoRealtimeListeners",e[e.HeartbeatPingError=3002]="HeartbeatPingError",e[e.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",e[e.NoAuthentication=3050]="NoAuthentication"}(Es||(Es={}));var Is=function(e,t){var n=Ss[e],r=n?n.name+", code "+e+", reason "+(t||n.description):"code "+e;return new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},Os=null,As="web";function Ns(){return Os}function Ts(){return As}function Rs(e){As=e}var Ps=function(){return Ps=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ps.apply(this,arguments)},xs=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Ls=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},Cs=1,ks=function(){function e(e){var t=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(e){return xs(t,void 0,void 0,(function(){var t=this;return Ls(this,(function(n){return[2,new Promise((function(n,r){return xs(t,void 0,void 0,(function(){var t,o,i,s,a,c,u,f=this;return Ls(this,(function(l){switch(l.label){case 0:o=!1,i=!1,s=function(e){o=!0,t&&clearTimeout(t),n(e)},a=function(e){i=!0,t&&clearTimeout(t),r(e)},e.timeout&&(t=setTimeout((function(){return xs(f,void 0,void 0,(function(){return Ls(this,(function(e){switch(e.label){case 0:return o&&i?[3,2]:[4,gs(0)];case 1:e.sent(),o&&i||a(new hs("wsclient.send timedout")),e.label=2;case 2:return[2]}}))}))}),e.timeout)),l.label=1;case 1:return l.trys.push([1,8,,9]),this._wsInitPromise?[4,this._wsInitPromise]:[3,3];case 2:l.sent(),l.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!==Cs)return a(new Error("ws readyState invalid: "+this._ws.readyState+", can not send message")),[2];e.waitResponse&&this._wsResponseWait.set(e.msg.requestId,{resolve:s,reject:a,skipOnMessage:e.skipOnMessage}),l.label=4;case 4:return l.trys.push([4,6,,7]),[4,this._ws.send(JSON.stringify(e.msg))];case 5:return l.sent(),e.waitResponse||s(),[3,7];case 6:return(c=l.sent())&&(a(c),e.waitResponse&&this._wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return u=l.sent(),a(u),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(e){t._virtualWSClient.forEach((function(t){t.closeWithError(e)}))},this.pauseClients=function(e){(e||t._virtualWSClient).forEach((function(e){e.pause()}))},this.resumeClients=function(e){(e||t._virtualWSClient).forEach((function(e){e.resume()}))},this.initWebSocketConnection=function(e,n){return void 0===n&&(n=t._maxReconnect),xs(t,void 0,void 0,(function(){var t=this;return Ls(this,(function(r){switch(r.label){case 0:if(e&&this._reconnectState)return[2];if(e&&(this._reconnectState=!0),this._wsInitPromise)return[2,this._wsInitPromise];e&&this.pauseClients(),this.close(Es.ReconnectWebSocket),this._wsInitPromise=new Promise((function(r,o){return xs(t,void 0,void 0,(function(){var t,i,s=this;return Ls(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return t=a.sent(),[4,new Promise((function(e){var n=t.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=Ns();s._ws=r?new r(n):new WebSocket(n),e()}))];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(),e&&(this.resumeClients(),this._reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),n>0?(!0,this._wsInitPromise=void 0,[4,gs(this._reconnectInterval)]):[3,9];case 7:a.sent(),e&&(this._reconnectState=!1),a.label=8;case 8:return r(this.initWebSocketConnection(e,n-1)),[3,10];case 9:o(i),e&&this.closeAllClients(new ds({errCode:ys.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(e){return(0,e.resolve)()})),[3,5];case 3:return r.sent(),this._wsReadySubsribers.forEach((function(e){return(0,e.reject)()})),[3,5];case 4:return this._wsInitPromise=void 0,this._wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(e,n){if(!t._ws)throw new Error("can not initWebSocketEvent, ws not exists");var r=!1;t._ws.onopen=function(t){console.warn("[realtime] ws event: open",t),r=!0,e()},t._ws.onerror=function(e){t._logins=new Map,r?(console.error("[realtime] ws event: error",e),t.clearHeartbeat(),t._virtualWSClient.forEach((function(t){return t.closeWithError(new ds({errCode:ys.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:e}))}))):(console.error("[realtime] ws open failed with ws event: error",e),n(e))},t._ws.onclose=function(e){switch(console.warn("[realtime] ws event: close",e),t._logins=new Map,t.clearHeartbeat(),e.code){case Es.ReconnectWebSocket:case Es.NoRealtimeListeners:break;case Es.HeartbeatPingError:case Es.HeartbeatPongTimeoutError:case Es.NormalClosure:case Es.AbnormalClosure:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(Is(e.code));break;case Es.NoAuthentication:t.closeAllClients(Is(e.code,e.reason));break;default:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(Is(e.code))}},t._ws.onmessage=function(e){var n,r=e.data;t.heartbeat();try{n=JSON.parse(r)}catch(e){throw new Error("[realtime] onMessage parse res.data error: "+e)}if("ERROR"===n.msgType){var o=null;t._virtualWSClient.forEach((function(e){e.watchId===n.watchId&&(o=e)})),o&&o.listener.onError(n)}var i=t._wsResponseWait.get(n.requestId);if(i){try{"ERROR"===n.msgType?i.reject(new fs(n)):i.resolve(n)}catch(e){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",e)}finally{t._wsResponseWait.delete(n.requestId)}if(i.skipOnMessage)return}if("PONG"!==n.msgType){var s=n.watchId&&t._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=t._queryIdClientMap.get(n.msgData.queryID))&&s.onMessage(n);break;default:for(var a=0,c=Array.from(t._watchIdClientMap.entries());a<c.length;a++){c[a][1].onMessage(n);break}}}else if(t._lastPingSendTS){var u=Date.now()-t._lastPingSendTS;if(u>1e4)return void console.warn("[realtime] untrusted rtt observed: "+u);t._rttObserved.length>=3&&t._rttObserved.splice(0,t._rttObserved.length-3+1),t._rttObserved.push(u)}},t.heartbeat()}))},this.isWSConnected=function(){return Boolean(t._ws&&t._ws.readyState===Cs)},this.onceWSConnected=function(){return xs(t,void 0,void 0,(function(){var e=this;return Ls(this,(function(t){return this.isWSConnected()?[2]:this._wsInitPromise?[2,this._wsInitPromise]:[2,new Promise((function(t,n){e._wsReadySubsribers.push({resolve:t,reject:n})}))]}))}))},this.webLogin=function(e,n){return xs(t,void 0,void 0,(function(){var t,r,o,i,s,a,c,u,f=this;return Ls(this,(function(l){switch(l.label){case 0:if(!n)if(e){if(t=this._logins.get(e)){if(t.loggedIn&&t.loginResult)return[2,t.loginResult];if(t.loggingInPromise)return[2,t.loggingInPromise]}}else if(null==(r=this._logins.get(""))?void 0:r.loggingInPromise)return[2,r.loggingInPromise];o=new Promise((function(e,t){return xs(f,void 0,void 0,(function(){var n,r,o,i,s;return Ls(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:is(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:Ts(),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?t(new Error(i.msgData.code+" "+i.msgData.message)):e({envId:n.envId}),[3,4];case 3:return s=a.sent(),t(s),[3,4];case 4:return[2]}}))}))})),i=e&&this._logins.get(e),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this._logins.set(e||"",i)),l.label=1;case 1:return l.trys.push([1,3,,4]),[4,o];case 2:if(a=l.sent(),(c=e&&this._logins.get(e))&&c===i&&c.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(c){if(c.loggedIn&&c.loginResult)return[2,c.loginResult];if(c.loggingInPromise)return[2,c.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw u=l.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,u;case 4:return[2]}}))}))},this.getWsSign=function(){return xs(t,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Ls(this,(function(a){switch(a.label){case 0:return this._wsSign&&this._wsSign.expiredTs>Date.now()?[2,this._wsSign]:(e=Date.now()+6e4,[4,this._context.appConfig.request.send("auth.wsWebSign",{runtime:Ts()})]);case 1:if((t=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: "+t.code);if(t.data)return n=t.data,r=n.signStr,o=n.wsUrl,i=n.secretVersion,s=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:i,envId:s,expiredTs:e}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return t._rttObserved.length?t._rttObserved.reduce((function(e,t){return e+t}))/t._rttObserved.length*1.5:5e3},this.ping=function(){return xs(t,void 0,void 0,(function(){var e;return Ls(this,(function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:is(),msgType:"PING",msgData:null},[4,this.send({msg:e})];case 1:return t.sent(),[2]}}))}))},this.onWatchStart=function(e,n){t._queryIdClientMap.set(n,e)},this.onWatchClose=function(e,n){n&&t._queryIdClientMap.delete(n),t._watchIdClientMap.delete(e.watchId),t._virtualWSClient.delete(e),t._virtualWSClient.size||t.close(Es.NoRealtimeListeners)},this._maxReconnect=e.maxReconnect||5,this._reconnectInterval=e.reconnectInterval||1e4,this._context=e.context}return e.prototype.clearHeartbeat=function(){this._pingTimeoutId&&clearTimeout(this._pingTimeoutId),this._pongTimeoutId&&clearTimeout(this._pongTimeoutId)},e.prototype.close=function(e){this.clearHeartbeat(),this._ws&&(this._ws.close(e,Ss[e].name),this._ws=void 0)},e.prototype.watch=function(e){this._ws||this._wsInitPromise||this.initWebSocketConnection(!1);var t=new bs(Ps(Ps({},e),{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(t),this._watchIdClientMap.set(t.watchId,t),t.listener},e.prototype.heartbeat=function(e){var t=this;this.clearHeartbeat(),this._pingTimeoutId=setTimeout((function(){return xs(t,void 0,void 0,(function(){var e=this;return Ls(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this._ws&&this._ws.readyState===Cs?(this._lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return t.sent(),this._pingFailed=0,this._pongTimeoutId=setTimeout((function(){console.error("pong timed out"),e._pongMissed<2?(e._pongMissed++,e.heartbeat(!0)):e.initWebSocketConnection(!0)}),this._context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return t.sent(),this._pingFailed<2?(this._pingFailed++,this.heartbeat()):this.close(Es.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),e?0:this._context.appConfig.realtimePingInterval)},e}(),Ds={target:"database",entity:function(){var e,t=this.platform,n=t.adapter,r=t.runtime;e=n.wsClass,Os=e,Rs(r)}},js={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=ks}};try{cloudbase.registerComponent(js),cloudbase.registerHook(Ds)}catch(e){}var Us=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Ms=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},qs=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Ws=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},Fs=Pe.ERRORS,Bs=Pe.COMMUNITY_SITE_URL,$s=Te.catchErrorsDecorator,Hs="analytics",Gs=["mall"];var Ks,Vs,Js=new(function(){function e(){}return e.prototype.analytics=function(e){return qs(this,void 0,void 0,(function(){var t,n,r;return Ws(this,(function(o){if(!function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))return!1;var t=e.report_data,n=e.report_type;return!1!==Gs.includes(n)&&"Object"===Object.prototype.toString.call(t).slice(8,-1)&&!(void 0!==t.action_time&&!Number.isInteger(t.action_time))&&"string"==typeof t.action_type}(e))throw new Error(JSON.stringify({code:Fs.INVALID_PARAMS,msg:"["+Hs+".analytics] invalid report data"}));return"analytics.report",t=void 0===e.report_data.action_time?Math.floor(Date.now()/1e3):e.report_data.action_time,n={analytics_scene:e.report_type,analytics_data:Object.assign({},e.report_data,{action_time:t})},r={requestData:n},this.request.send("analytics.report",r),[2]}))}))},Us([$s({customInfo:{className:"Cloudbase",methodName:"analytics"},title:"上报调用失败",messages:["请确认以下各项:"," 1 - 调用 analytics() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Bs]}),Ms("design:type",Function),Ms("design:paramtypes",[Object]),Ms("design:returntype",Promise)],e.prototype,"analytics",null),e}()),Ys={name:Hs,entity:{analytics:Js.analytics}};try{cloudbase.registerComponent(Ys)}catch(e){}!function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined"}(Vs||(Vs={}));var Zs,Xs,zs="Number",Qs="Object",ea="Array",ta="GeoPoint",na="GeoLineString",ra="GeoPolygon",oa="GeoMultiPoint",ia="GeoMultiLineString",sa="GeoMultiPolygon",aa="Date",ca="ServerDate",ua="BsonDate",fa=["desc","asc"],la=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(Zs||(Zs={})),(Ks={})[Zs.eq]="$eq",Ks[Zs.lt]="$lt",Ks[Zs.lte]="$lte",Ks[Zs.gt]="$gt",Ks[Zs.gte]="$gte",function(e){e.WHERE="WHERE",e.DOC="DOC"}(Xs||(Xs={}));var ha=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),pa=[],da={},ya=function(e){function t(t,n){if(n!==da)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return ha(t,e),t.for=function(e){for(var n=0,r=pa.length;n<r;n++)if(pa[n].target===e)return pa[n].instance;var o=new t(e,da);return pa.push({target:e,instance:o}),o},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),ga=ya,va=ga.for("UNSET_FIELD_NAME"),ma=ga.for("UPDATE_COMMAND"),_a=ga.for("QUERY_COMMAND"),ba=ga.for("LOGIC_COMMAND"),wa=ga.for("GEO_POINT"),Ea=ga.for("SYMBOL_GEO_LINE_STRING"),Sa=ga.for("SYMBOL_GEO_POLYGON"),Ia=ga.for("SYMBOL_GEO_MULTI_POINT"),Oa=ga.for("SYMBOL_GEO_MULTI_LINE_STRING"),Aa=ga.for("SYMBOL_GEO_MULTI_POLYGON"),Na=ga.for("SERVER_DATE"),Ta=ga.for("REGEXP"),Ra=function(){function e(e){var t=(void 0===e?{}:e).offset,n=void 0===t?0:t;this.offset=n}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return Na},enumerable:!0,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function Pa(e){return new Ra(e)}var xa,La=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},Ca=function(){function e(){}return e.formatResDocumentData=function(t){return t.map((function(t){return e.formatField(t)}))},e.formatField=function(t){var n=Object.keys(t),r={};return Array.isArray(t)&&(r=[]),n.forEach((function(n){var o,i=t[n];switch(e.whichType(i)){case ta:o=new Ba(i.coordinates[0],i.coordinates[1]);break;case na:o=new Ha(i.coordinates.map((function(e){return new Ba(e[0],e[1])})));break;case ra:o=new Ka(i.coordinates.map((function(e){return new Ha(e.map((function(e){var t=La(e,2),n=t[0],r=t[1];return new Ba(n,r)})))})));break;case oa:o=new Ja(i.coordinates.map((function(e){return new Ba(e[0],e[1])})));break;case ia:o=new Za(i.coordinates.map((function(e){return new Ha(e.map((function(e){var t=La(e,2),n=t[0],r=t[1];return new Ba(n,r)})))})));break;case sa:o=new za(i.coordinates.map((function(e){return new Ka(e.map((function(e){return new Ha(e.map((function(e){var t=La(e,2),n=t[0],r=t[1];return new Ba(n,r)})))})))})));break;case aa:o=new Date(1e3*i.$timestamp);break;case Qs:case ea:o=e.formatField(i);break;case ca:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o})),r},e.whichType=function(e){var t=Object.prototype.toString.call(e).slice(8,-1);if(t===aa)return ua;if(t===Qs){if(e instanceof Ba)return ta;if(e instanceof Date)return aa;if(e instanceof Ra)return ca;e.$timestamp?t=aa:e.$date?t=ca:Ba.validate(e)?t=ta:Ha.validate(e)?t=na:Ka.validate(e)?t=ra:Ja.validate(e)?t=oa:Za.validate(e)?t=ia:za.validate(e)&&(t=sa)}return t},e.generateDocId=function(){for(var e="ABCDEFabcdef0123456789",t="",n=0;n<24;n++)t+=e.charAt(Math.floor(22*Math.random()));return t},e}(),ka=function(){function e(){}return e.isGeopoint=function(e,t){if(Ca.whichType(t)!==zs)throw new Error("Geo Point must be number type");var n=Math.abs(t);if("latitude"===e&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===e&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},e.isInteger=function(e,t){if(!Number.isInteger(t))throw new Error(e+Vs.IntergerError);return!0},e.isFieldOrder=function(e){if(-1===fa.indexOf(e))throw new Error(Vs.DirectionError);return!0},e.isFieldPath=function(e){if(!/^[a-zA-Z0-9-_\.]/.test(e))throw new Error;return!0},e.isOperator=function(e){if(-1===la.indexOf(e))throw new Error(Vs.OpStrError);return!0},e.isCollName=function(e){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e))throw new Error(Vs.CollNameError);return!0},e.isDocID=function(e){if(!/^([a-fA-F0-9]){24}$/.test(e))throw new Error(Vs.DocIDError);return!0},e}(),Da=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},ja=function(e){return"object"===Da(e)},Ua=function(e){return"number"===Da(e)},Ma=function(e){return Array.isArray(e)},qa=function(e){return"date"===Da(e)},Wa=function(e){return"regexp"===Da(e)},Fa=function(e){return e&&e._internalType instanceof ya},Ba=function(){function e(e,t){ka.isGeopoint("longitude",e),ka.isGeopoint("latitude",t),this.longitude=e,this.latitude=t}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Point",coordinates:[this.longitude,this.latitude]},t},e.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},e.prototype.toReadableString=function(){return"["+this.longitude+","+this.latitude+"]"},e.validate=function(e){return"Point"===e.type&&Ma(e.coordinates)&&ka.isGeopoint("longitude",e.coordinates[0])&&ka.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return wa},enumerable:!0,configurable:!0}),e}(),$a=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ha=function(){function e(e){if(!Ma(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(e.length<2)throw new Error('"points" must contain 2 points at least');e.forEach((function(e){if(!(e instanceof Ba))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e+"[]")})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,n;if("LineString"!==e.type||!Ma(e.coordinates))return!1;try{for(var r=$a(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!Ua(i[0])||!Ua(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},e.isClosed=function(e){var t=e.points[0],n=e.points[e.points.length-1];if(t.latitude===n.latitude&&t.longitude===n.longitude)return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Ea},enumerable:!0,configurable:!0}),e}(),Ga=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ka=function(){function e(e){if(!Ma(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof Ha))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]");if(!Ha.isClosed(e))throw new Error("LineString "+e.points.map((function(e){return e.toReadableString()}))+" is not a closed cycle")})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,n,r,o;if("Polygon"!==e.type||!Ma(e.coordinates))return!1;try{for(var i=Ga(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var c=(r=void 0,Ga(a)),u=c.next();!u.done;u=c.next()){var f=u.value;if(!Ua(f[0])||!Ua(f[1]))return!1}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return!0},e.isCloseLineString=function(e){var t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Aa},enumerable:!0,configurable:!0}),e}(),Va=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ja=function(){function e(e){if(!Ma(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(0===e.length)throw new Error('"points" must contain 1 point at least');e.forEach((function(e){if(!(e instanceof Ba))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e+"[]")})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,n;if("MultiPoint"!==e.type||!Ma(e.coordinates))return!1;try{for(var r=Va(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!Ua(i[0])||!Ua(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Ia},enumerable:!0,configurable:!0}),e}(),Ya=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Za=function(){function e(e){if(!Ma(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof Ha))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]")})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,n,r,o;if("MultiLineString"!==e.type||!Ma(e.coordinates))return!1;try{for(var i=Ya(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var c=(r=void 0,Ya(a)),u=c.next();!u.done;u=c.next()){var f=u.value;if(!Ua(f[0])||!Ua(f[1]))return!1}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Oa},enumerable:!0,configurable:!0}),e}(),Xa=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},za=function(){function e(e){var t,n;if(!Ma(e))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof e);if(0===e.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=Xa(e),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof Ka))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof i+"[]")}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.polygons=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))},t},e.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))}},e.validate=function(e){var t,n,r,o,i,s;if("MultiPolygon"!==e.type||!Ma(e.coordinates))return!1;try{for(var a=Xa(e.coordinates),c=a.next();!c.done;c=a.next()){var u=c.value;try{for(var f=(r=void 0,Xa(u)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,Xa(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!Ua(y[0])||!Ua(y[1]))return!1}}catch(e){i={error:e}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Sa},enumerable:!0,configurable:!0}),e}(),Qa=Object.freeze({__proto__:null,LineString:Ha,MultiLineString:Za,MultiPoint:Ja,MultiPolygon:za,Point:Ba,Polygon:Ka}),ec=function(){var e;if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e};!function(e){e.SET="set",e.REMOVE="remove",e.INC="inc",e.MUL="mul",e.PUSH="push",e.PULL="pull",e.PULL_ALL="pullAll",e.POP="pop",e.SHIFT="shift",e.UNSHIFT="unshift",e.ADD_TO_SET="addToSet",e.BIT="bit",e.RENAME="rename",e.MAX="max",e.MIN="min"}(xa||(xa={}));var tc,nc=function(){function e(e,t,n){this._internalType=ma,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||va}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function rc(e){return e&&e instanceof nc&&e._internalType===ma}!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(tc||(tc={}));var oc=function(){function e(e,t,n){if(this._internalType=ba,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||va,this.fieldName!==va)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var r=0,o=t.length;r<o;r++){(ic(i=t[r])||uc(i))&&(t[r]=i._setFieldName(this.fieldName))}}else{var i;(ic(i=t)||uc(i))&&(t=i._setFieldName(this.fieldName))}}return e.prototype._setFieldName=function(t){var n=this.operands.map((function(n){return n instanceof e?n._setFieldName(t):n}));return new e(this.operator,n,t)},e.prototype.and=function(){var t=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return t.unshift(this),new e(tc.AND,t,this.fieldName)},e.prototype.or=function(){var t=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return t.unshift(this),new e(tc.OR,t,this.fieldName)},e}();function ic(e){return e&&e instanceof oc&&e._internalType===ba}var sc,ac=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){e.EQ="eq",e.NEQ="neq",e.GT="gt",e.GTE="gte",e.LT="lt",e.LTE="lte",e.IN="in",e.NIN="nin",e.ALL="all",e.ELEM_MATCH="elemMatch",e.EXISTS="exists",e.SIZE="size",e.MOD="mod",e.GEO_NEAR="geoNear",e.GEO_WITHIN="geoWithin",e.GEO_INTERSECTS="geoIntersects"}(sc||(sc={}));var cc=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.operator=t,o._internalType=_a,o}return ac(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case sc.IN:case sc.NIN:return(e={})["$"+this.operator]=this.operands,e;default:return(t={})["$"+this.operator]=this.operands[0],t}},t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t.prototype.eq=function(e){var n=new t(sc.EQ,[e],this.fieldName);return this.and(n)},t.prototype.neq=function(e){var n=new t(sc.NEQ,[e],this.fieldName);return this.and(n)},t.prototype.gt=function(e){var n=new t(sc.GT,[e],this.fieldName);return this.and(n)},t.prototype.gte=function(e){var n=new t(sc.GTE,[e],this.fieldName);return this.and(n)},t.prototype.lt=function(e){var n=new t(sc.LT,[e],this.fieldName);return this.and(n)},t.prototype.lte=function(e){var n=new t(sc.LTE,[e],this.fieldName);return this.and(n)},t.prototype.in=function(e){var n=new t(sc.IN,e,this.fieldName);return this.and(n)},t.prototype.nin=function(e){var n=new t(sc.NIN,e,this.fieldName);return this.and(n)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof Ba))throw new TypeError('"geometry" must be of type Point. Received type '+typeof e.geometry);if(void 0!==e.maxDistance&&!Ua(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof e.maxDistance);if(void 0!==e.minDistance&&!Ua(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof e.minDistance);var n=new t(sc.GEO_NEAR,[e],this.fieldName);return this.and(n)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof za||e.geometry instanceof Ka))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof e.geometry);var n=new t(sc.GEO_WITHIN,[e],this.fieldName);return this.and(n)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof Ba||e.geometry instanceof Ha||e.geometry instanceof Ka||e.geometry instanceof Ja||e.geometry instanceof Za||e.geometry instanceof za))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof e.geometry);var n=new t(sc.GEO_INTERSECTS,[e],this.fieldName);return this.and(n)},t}(oc);function uc(e){return e&&e instanceof cc&&e._internalType===_a}function fc(e){return uc(e)}var lc={};for(var hc in sc)lc[hc]="$"+hc;for(var hc in tc)lc[hc]="$"+hc;for(var hc in xa)lc[hc]="$"+hc;function pc(e){return lc[e]||"$"+e}lc[sc.NEQ]="$ne",lc[xa.REMOVE]="$unset",lc[xa.SHIFT]="$pop",lc[xa.UNSHIFT]="$push";var dc=function(){return dc=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},dc.apply(this,arguments)},yc=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},gc=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(yc(arguments[t]));return e};function vc(e){return mc(e,[e])}function mc(e,t){if(!Fa(e)){if(qa(e))return{$date:+e};if(Wa(e))return{$regex:e.source,$options:e.flags};if(Ma(e))return e.map((function(e){if(t.indexOf(e)>-1)throw new Error("Cannot convert circular structure to JSON");return mc(e,gc(t,[e]))}));if(ja(e)){var n=dc({},e);for(var r in n){if(t.indexOf(n[r])>-1)throw new Error("Cannot convert circular structure to JSON");n[r]=mc(n[r],gc(t,[n[r]]))}return n}return e}switch(e._internalType){case wa:return e.toJSON();case Na:case Ta:return e.parse();default:return e.toJSON?e.toJSON():e}}var _c=function(){return _c=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},_c.apply(this,arguments)},bc=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},wc=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(bc(arguments[t]));return e};function Ec(e,t,n,r){var o=_c({},e);for(var i in e)if(!/^\$/.test(i)){var s=e[i];if(s&&ja(s)&&!t(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Ec(s,t,wc(n,[i]),wc(r,[s]));o[i]=a;var c=!1;for(var u in a)/^\$/.test(u)?c=!0:(o[i+"."+u]=a[u],delete o[i][u]);c||delete o[i]}}return o}function Sc(e){return Ec(e,Oc,[],[e])}function Ic(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Ma(e[r])?e[r].push(t[r]):ja(e[r])?ja(t[r])?Object.assign(e[r],t[r]):(console.warn("unmergable condition, query is object but condition is "+Da(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+Da(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]}function Oc(e){return Fa(e)||qa(e)||Wa(e)}function Ac(e){return vc(e)}var Nc=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.prototype.encodeUpdate=function(e){return rc(e)?this.encodeUpdateCommand(e):"object"===Da(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===va)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case xa.PUSH:case xa.PULL:case xa.PULL_ALL:case xa.POP:case xa.SHIFT:case xa.UNSHIFT:case xa.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,n,r,o,i=pc(e.operator);return e.operator===xa.REMOVE?((t={})[i]=((n={})[e.fieldName]="",n),t):((r={})[i]=((o={})[e.fieldName]=e.operands[0],o),r)},e.prototype.encodeArrayUpdateCommand=function(e){var t,n,r,o,i,s,a,c,u,f,l=pc(e.operator);switch(e.operator){case xa.PUSH:var h=void 0;return h=Ma(e.operands)?{$each:e.operands.map(Ac)}:e.operands,(t={})[l]=((n={})[e.fieldName]=h,n),t;case xa.UNSHIFT:h={$each:e.operands.map(Ac),$position:0};return(r={})[l]=((o={})[e.fieldName]=h,o),r;case xa.POP:return(i={})[l]=((s={})[e.fieldName]=1,s),i;case xa.SHIFT:return(a={})[l]=((c={})[e.fieldName]=-1,c),a;default:return(u={})[l]=((f={})[e.fieldName]=Ac(e.operands),f),u}},e.prototype.encodeUpdateObject=function(e){var t=Sc(e);for(var n in t)if(!/^\$/.test(n)){var r=t[n];if(rc(r)){t[n]=r._setFieldName(n),Ic(t,this.encodeUpdateCommand(t[n]),n)}else{t[n]=r=Ac(r);var o=new nc(xa.SET,[r],n);Ic(t,this.encodeUpdateCommand(o),n)}}return t},e}(),Tc={};function Rc(e){if(!bf.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return Tc[t]||(Tc[t]=new bf.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new bf.reqClass(e.config)}}})),Tc[t]}var Pc=function(){return Pc=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Pc.apply(this,arguments)},xc=function(){function e(e,t,n,r){var o=this;void 0===r&&(r={}),this.watch=function(e){return Rc(o._db).watch(Pc(Pc({},e),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=e,this._coll=t,this.id=n,this.request=new bf.reqClass(this._db.config),this.projection=r}return e.prototype.create=function(e,t){t=t||ec();var n={collectionName:this._coll,data:vc(e)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(e){e.code?t(0,e):t(0,{id:e.data._id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.set=function(e,t){if(t=t||ec(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(e){if("object"==typeof e)for(var t in e)e[t]instanceof nc?n=!0:"object"==typeof e[t]&&r(e[t])};if(r(e),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:Xs.DOC,data:vc(e),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.update=function(e,t){if(t=t||ec(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:Nc.encode(e),query:n,queryType:Xs.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.remove=function(e){e=e||ec();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:Xs.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(t){t.code?e(0,t):e(0,{deleted:t.data.deleted,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},e.prototype.get=function(e){e=e||ec();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:Xs.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n=Ca.formatResDocumentData(t.data.list);e(0,{data:n,requestId:t.requestId,total:t.TotalCount,limit:t.Limit,offset:t.Offset})}})).catch((function(t){e(t)})),e.promise},e.prototype.field=function(t){for(var n in t)t[n]?t[n]=1:t[n]=0;return new e(this._db,this._coll,this.id,t)},e}(),Lc=function(){function e(){}return e.encode=function(e){return(new Cc).encodeQuery(e)},e}(),Cc=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var n;return Oc(e)?ic(e)?this.encodeLogicCommand(e):uc(e)?this.encodeQueryCommand(e):((n={})[t]=this.encodeQueryObject(e),n):ja(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regex:e.source,$options:e.flags}},e.prototype.encodeLogicCommand=function(e){var t,n,r,o,i,s,a,c=this;switch(e.operator){case tc.NOR:case tc.AND:case tc.OR:var u=pc(e.operator),f=e.operands.map((function(t){return c.encodeQuery(t,e.fieldName)}));return(t={})[u]=f,t;case tc.NOT:u=pc(e.operator);var l=e.operands[0];if(Wa(l))return(n={})[e.fieldName]=((r={})[u]=this.encodeRegExp(l),r),n;f=this.encodeQuery(l)[e.fieldName];return(o={})[e.fieldName]=((i={})[u]=f,i),o;default:u=pc(e.operator);if(1===e.operands.length){var h=this.encodeQuery(e.operands[0]);return(s={})[u]=h,s}f=e.operands.map(this.encodeQuery.bind(this));return(a={})[u]=f,a}},e.prototype.encodeQueryCommand=function(e){return fc(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,n,r,o,i,s,a,c,u;if(e.fieldName===va)throw new Error("Cannot encode a comparison command with unset field name");var f=pc(e.operator);switch(e.operator){case sc.EQ:case sc.NEQ:case sc.LT:case sc.LTE:case sc.GT:case sc.GTE:case sc.ELEM_MATCH:case sc.EXISTS:case sc.SIZE:case sc.MOD:return(t={})[e.fieldName]=((n={})[f]=Ac(e.operands[0]),n),t;case sc.IN:case sc.NIN:case sc.ALL:return(r={})[e.fieldName]=((o={})[f]=Ac(e.operands),o),r;case sc.GEO_NEAR:var l=e.operands[0];return(i={})[e.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case sc.GEO_WITHIN:l=e.operands[0];return(s={})[e.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case sc.GEO_INTERSECTS:l=e.operands[0];return(a={})[e.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(c={})[e.fieldName]=((u={})[f]=Ac(e.operands[0]),u),c}},e.prototype.encodeQueryObject=function(e){var t=Sc(e);for(var n in t){var r=t[n];if(ic(r)){t[n]=r._setFieldName(n);var o=this.encodeLogicCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else if(fc(r)){t[n]=r._setFieldName(n);o=this.encodeComparisonCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else Oc(r)&&(t[n]=Ac(r))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Ma(e[r])?e[r]=e[r].concat(t[r]):ja(e[r])?ja(t[r])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is "+Da(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+Da(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]},e}(),kc=function(){return kc=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},kc.apply(this,arguments)},Dc=function(){function e(e,t,n,r,o){var i=this;this.watch=function(e){return Rc(i._db).watch(kc(kc({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(e,t){return e[t.field]=t.direction,e}),{}):void 0}))},this._db=e,this._coll=t,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=new bf.reqClass(this._db.config)}return e.prototype.get=function(e){e=e||ec();var t=[];this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)}));var n={collectionName:this._coll,queryType:Xs.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),t.length>0&&(n.order=t),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n={data:Ca.formatResDocumentData(t.data.list),requestId:t.requestId};t.TotalCount&&(n.total=t.TotalCount),t.Limit&&(n.limit=t.Limit),t.Offset&&(n.offset=t.Offset),e(0,n)}})).catch((function(t){e(t)})),e.promise},e.prototype.count=function(e){e=e||ec();var t={collectionName:this._coll,queryType:Xs.WHERE};return this._fieldFilters&&(t.query=this._fieldFilters),this._request.send("database.countDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,total:t.data.total})})).catch((function(t){e(t)})),e.promise},e.prototype.where=function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))throw Error(Vs.QueryParamTypeError);var n=Object.keys(t),r=n.some((function(e){return void 0!==t[e]}));if(n.length&&!r)throw Error(Vs.QueryParamValueError);return new e(this._db,this._coll,Lc.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,n){ka.isFieldPath(t),ka.isFieldOrder(n);var r={field:t,direction:n},o=this._fieldOrders.concat(r);return new e(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},e.prototype.limit=function(t){ka.isInteger("limit",t);var n=kc({},this._queryOptions);return n.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.skip=function(t){ka.isInteger("offset",t);var n=kc({},this._queryOptions);return n.offset=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.update=function(e,t){if(t=t||ec(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:Xs.WHERE,multi:!0,merge:!0,upsert:!1,data:Nc.encode(e)};return this._request.send("database.updateDocument",n).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,updated:e.data.updated,upsertId:e.data.upsert_id})})).catch((function(e){t(e)})),t.promise},e.prototype.field=function(t){for(var n in t)t[n]?"object"!=typeof t[n]&&(t[n]=1):t[n]=0;var r=kc({},this._queryOptions);return r.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.remove=function(e){e=e||ec(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var t={collectionName:this._coll,query:Lc.encode(this._fieldFilters),queryType:Xs.WHERE,multi:!0};return this._request.send("database.deleteDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,deleted:t.data.deleted})})).catch((function(t){e(t)})),e.promise},e}(),jc=function(e,t){return jc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},jc(e,t)};function Uc(e,t){function n(){this.constructor=e}jc(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Mc=function(e){function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return Uc(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),t}(Error),qc=function(e){function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return Uc(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),t}(TypeError);function Wc(e){return e&&e.Math==Math&&e}function Fc(){return Wc("object"==typeof globalThis&&globalThis)||Wc("object"==typeof window&&window)||Wc("object"==typeof self&&self)||Wc("object"==typeof global&&global)||Function("return this")()}var Bc=function(t){var n,r="object"==typeof(n=Fc()).navigator&&"ReactNative"===n.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(r);for(var o=e.alloc(t),i=0;i<t;++i)o[i]=Math.floor(256*Math.random());return o},$c=function(){var e=void 0;try{e=require("crypto").randomBytes}catch(e){}return e||Bc}();function Hc(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)}function Gc(e){return"object"==typeof e&&null!==e}function Kc(e,t){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return n||(console.warn(t),n=!0),e.apply(this,r)}}function Vc(t){if(ArrayBuffer.isView(t))return e.from(t.buffer,t.byteOffset,t.byteLength);if(n=t,["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(n)))return e.from(t);var n;throw new qc("Must use either Buffer or TypedArray")}var Jc=/^(?:[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,Yc=function(e){return"string"==typeof e&&Jc.test(e)},Zc=function(t){if(!Yc(t))throw new qc('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var n=t.replace(/-/g,"");return e.from(n,"hex")},Xc=function(e,t){return void 0===t&&(t=!0),t?e.toString("hex",0,4)+"-"+e.toString("hex",4,6)+"-"+e.toString("hex",6,8)+"-"+e.toString("hex",8,10)+"-"+e.toString("hex",10,16):e.toString("hex")},zc=Math.pow(2,53),Qc=-Math.pow(2,53),eu=function(){function t(n,r){if(!(this instanceof t))return new t(n,r);if(!(null==n||"string"==typeof n||ArrayBuffer.isView(n)||n instanceof ArrayBuffer||Array.isArray(n)))throw new qc("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=r?r:t.BSON_BINARY_SUBTYPE_DEFAULT,null==n?(this.buffer=e.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof n?this.buffer=e.from(n,"binary"):Array.isArray(n)?this.buffer=e.from(n):this.buffer=Vc(n),this.position=this.buffer.byteLength)}return t.prototype.put=function(n){if("string"==typeof n&&1!==n.length)throw new qc("only accepts single character String");if("number"!=typeof n&&1!==n.length)throw new qc("only accepts single character Uint8Array or Array");var r;if((r="string"==typeof n?n.charCodeAt(0):"number"==typeof n?n:n[0])<0||r>255)throw new qc("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=r;else{var o=e.alloc(t.BUFFER_SIZE+this.buffer.length);this.buffer.copy(o,0,0,this.buffer.length),this.buffer=o,this.buffer[this.position++]=r}},t.prototype.write=function(t,n){if(n="number"==typeof n?n:this.position,this.buffer.length<n+t.length){var r=e.alloc(this.buffer.length+t.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r}ArrayBuffer.isView(t)?(this.buffer.set(Vc(t),n),this.position=n+t.byteLength>this.position?n+t.length:this.position):"string"==typeof t&&(this.buffer.write(t,n,t.length,"binary"),this.position=n+t.length>this.position?n+t.length:this.position)},t.prototype.read=function(e,t){return t=t&&t>0?t:this.position,this.buffer.slice(e,e+t)},t.prototype.value=function(e){return(e=!!e)&&this.buffer.length===this.position?this.buffer:e?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(e){return this.buffer.toString(e)},t.prototype.toExtendedJSON=function(e){e=e||{};var t=this.buffer.toString("base64"),n=Number(this.sub_type).toString(16);return e.legacy?{$binary:t,$type:1===n.length?"0"+n:n}:{$binary:{base64:t,subType:1===n.length?"0"+n:n}}},t.prototype.toUUID=function(){if(this.sub_type===t.SUBTYPE_UUID)return new tu(this.buffer.slice(0,this.position));throw new Mc('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(n,r){var o,i;if(r=r||{},"$binary"in n?r.legacy&&"string"==typeof n.$binary&&"$type"in n?(i=n.$type?parseInt(n.$type,16):0,o=e.from(n.$binary,"base64")):"string"!=typeof n.$binary&&(i=n.$binary.subType?parseInt(n.$binary.subType,16):0,o=e.from(n.$binary.base64,"base64")):"$uuid"in n&&(i=4,o=Zc(n.$uuid)),!o)throw new qc("Unexpected Binary Extended JSON format ".concat(JSON.stringify(n)));return 4===i?new tu(o):new t(o,i)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var e=this.value(!0);return'new Binary(Buffer.from("'.concat(e.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(eu.prototype,"_bsontype",{value:"Binary"});var tu=function(t){function n(r){var o,i,s=this;if(null==r)o=n.generate();else if(r instanceof n)o=e.from(r.buffer),i=r.__id;else if(ArrayBuffer.isView(r)&&16===r.byteLength)o=Vc(r);else{if("string"!=typeof r)throw new qc("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).");o=Zc(r)}return(s=t.call(this,o,4)||this).__id=i,s}return Uc(n,t),Object.defineProperty(n.prototype,"id",{get:function(){return this.buffer},set:function(e){this.buffer=e,n.cacheHexString&&(this.__id=Xc(e))},enumerable:!1,configurable:!0}),n.prototype.toHexString=function(e){if(void 0===e&&(e=!0),n.cacheHexString&&this.__id)return this.__id;var t=Xc(this.id,e);return n.cacheHexString&&(this.__id=t),t},n.prototype.toString=function(e){return e?this.id.toString(e):this.toHexString()},n.prototype.toJSON=function(){return this.toHexString()},n.prototype.equals=function(e){if(!e)return!1;if(e instanceof n)return e.id.equals(this.id);try{return new n(e).id.equals(this.id)}catch(e){return!1}},n.prototype.toBinary=function(){return new eu(this.id,eu.SUBTYPE_UUID)},n.generate=function(){var t=$c(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,e.from(t)},n.isValid=function(e){return!!e&&(e instanceof n||("string"==typeof e?Yc(e):!!Hc(e)&&(16===e.length&&(64==(240&e[6])&&128==(128&e[8])))))},n.createFromHexString=function(e){return new n(Zc(e))},n.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},n.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},n}(eu),nu=function(){function e(t,n){if(!(this instanceof e))return new e(t,n);this.code=t,this.scope=n}return e.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},e.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},e.fromExtendedJSON=function(t){return new e(t.$code,t.$scope)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var e=this.toJSON();return'new Code("'.concat(String(e.code),'"').concat(e.scope?", ".concat(JSON.stringify(e.scope)):"",")")},e}();Object.defineProperty(nu.prototype,"_bsontype",{value:"Code"});var ru=function(){function e(t,n,r,o){if(!(this instanceof e))return new e(t,n,r,o);var i=t.split(".");2===i.length&&(r=i.shift(),t=i.shift()),this.collection=t,this.oid=n,this.db=r,this.fields=o||{}}return Object.defineProperty(e.prototype,"namespace",{get:function(){return this.collection},set:function(e){this.collection=e},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){var e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(e.$db=this.db),e},e.prototype.toExtendedJSON=function(e){e=e||{};var t={$ref:this.collection,$id:this.oid};return e.legacy?t:(this.db&&(t.$db=this.db),t=Object.assign(t,this.fields))},e.fromExtendedJSON=function(t){var n=Object.assign({},t);return delete n.$ref,delete n.$id,delete n.$db,new e(t.$ref,t.$id,t.$db,n)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var e=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return'new DBRef("'.concat(this.namespace,'", new ObjectId("').concat(String(e),'")').concat(this.db?', "'.concat(this.db,'"'):"",")")},e}();Object.defineProperty(ru.prototype,"_bsontype",{value:"DBRef"});var ou=void 0;try{ou=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(Ks){}var iu=4294967296,su=0x10000000000000000,au=su/2,cu={},uu={},fu=function(){function e(t,n,r){if(void 0===t&&(t=0),!(this instanceof e))return new e(t,n,r);"bigint"==typeof t?Object.assign(this,e.fromBigInt(t,!!n)):"string"==typeof t?Object.assign(this,e.fromString(t,!!n)):(this.low=0|t,this.high=0|n,this.unsigned=!!r),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return e.fromBits=function(t,n,r){return new e(t,n,r)},e.fromInt=function(t,n){var r,o,i;return n?(i=0<=(t>>>=0)&&t<256)&&(o=uu[t])?o:(r=e.fromBits(t,(0|t)<0?-1:0,!0),i&&(uu[t]=r),r):(i=-128<=(t|=0)&&t<128)&&(o=cu[t])?o:(r=e.fromBits(t,t<0?-1:0,!1),i&&(cu[t]=r),r)},e.fromNumber=function(t,n){if(isNaN(t))return n?e.UZERO:e.ZERO;if(n){if(t<0)return e.UZERO;if(t>=su)return e.MAX_UNSIGNED_VALUE}else{if(t<=-au)return e.MIN_VALUE;if(t+1>=au)return e.MAX_VALUE}return t<0?e.fromNumber(-t,n).neg():e.fromBits(t%iu|0,t/iu|0,n)},e.fromBigInt=function(t,n){return e.fromString(t.toString(),n)},e.fromString=function(t,n,r){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return e.ZERO;if("number"==typeof n?(r=n,n=!1):n=!!n,(r=r||10)<2||36<r)throw RangeError("radix");var o;if((o=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===o)return e.fromString(t.substring(1),n,r).neg();for(var i=e.fromNumber(Math.pow(r,8)),s=e.ZERO,a=0;a<t.length;a+=8){var c=Math.min(8,t.length-a),u=parseInt(t.substring(a,a+c),r);if(c<8){var f=e.fromNumber(Math.pow(r,c));s=s.mul(f).add(e.fromNumber(u))}else s=(s=s.mul(i)).add(e.fromNumber(u))}return s.unsigned=n,s},e.fromBytes=function(t,n,r){return r?e.fromBytesLE(t,n):e.fromBytesBE(t,n)},e.fromBytesLE=function(t,n){return new e(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,n)},e.fromBytesBE=function(t,n){return new e(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],n)},e.isLong=function(e){return Gc(e)&&!0===e.__isLong__},e.fromValue=function(t,n){return"number"==typeof t?e.fromNumber(t,n):"string"==typeof t?e.fromString(t,n):e.fromBits(t.low,t.high,"boolean"==typeof n?n:t.unsigned)},e.prototype.add=function(t){e.isLong(t)||(t=e.fromValue(t));var n=this.high>>>16,r=65535&this.high,o=this.low>>>16,i=65535&this.low,s=t.high>>>16,a=65535&t.high,c=t.low>>>16,u=0,f=0,l=0,h=0;return l+=(h+=i+(65535&t.low))>>>16,h&=65535,f+=(l+=o+c)>>>16,l&=65535,u+=(f+=r+a)>>>16,f&=65535,u+=n+s,u&=65535,e.fromBits(l<<16|h,u<<16|f,this.unsigned)},e.prototype.and=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)},e.prototype.compare=function(t){if(e.isLong(t)||(t=e.fromValue(t)),this.eq(t))return 0;var n=this.isNegative(),r=t.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},e.prototype.comp=function(e){return this.compare(e)},e.prototype.divide=function(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw Error("division by zero");if(ou){if(!this.unsigned&&-2147483648===this.high&&-1===t.low&&-1===t.high)return this;var n=(this.unsigned?ou.div_u:ou.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(n,ou.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;var r,o,i;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return e.UZERO;if(t.gt(this.shru(1)))return e.UONE;i=e.UZERO}else{if(this.eq(e.MIN_VALUE))return t.eq(e.ONE)||t.eq(e.NEG_ONE)?e.MIN_VALUE:t.eq(e.MIN_VALUE)?e.ONE:(r=this.shr(1).div(t).shl(1)).eq(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(o=this.sub(t.mul(r)),i=r.add(o.div(t)));if(t.eq(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();i=e.ZERO}for(o=this;o.gte(t);){r=Math.max(1,Math.floor(o.toNumber()/t.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),a=s<=48?1:Math.pow(2,s-48),c=e.fromNumber(r),u=c.mul(t);u.isNegative()||u.gt(o);)r-=a,u=(c=e.fromNumber(r,this.unsigned)).mul(t);c.isZero()&&(c=e.ONE),i=i.add(c),o=o.sub(u)}return i},e.prototype.div=function(e){return this.divide(e)},e.prototype.equals=function(t){return e.isLong(t)||(t=e.fromValue(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},e.prototype.eq=function(e){return this.equals(e)},e.prototype.getHighBits=function(){return this.high},e.prototype.getHighBitsUnsigned=function(){return this.high>>>0},e.prototype.getLowBits=function(){return this.low},e.prototype.getLowBitsUnsigned=function(){return this.low>>>0},e.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(e.MIN_VALUE)?64:this.neg().getNumBitsAbs();var t,n=0!==this.high?this.high:this.low;for(t=31;t>0&&0==(n&1<<t);t--);return 0!==this.high?t+33:t+1},e.prototype.greaterThan=function(e){return this.comp(e)>0},e.prototype.gt=function(e){return this.greaterThan(e)},e.prototype.greaterThanOrEqual=function(e){return this.comp(e)>=0},e.prototype.gte=function(e){return this.greaterThanOrEqual(e)},e.prototype.ge=function(e){return this.greaterThanOrEqual(e)},e.prototype.isEven=function(){return 0==(1&this.low)},e.prototype.isNegative=function(){return!this.unsigned&&this.high<0},e.prototype.isOdd=function(){return 1==(1&this.low)},e.prototype.isPositive=function(){return this.unsigned||this.high>=0},e.prototype.isZero=function(){return 0===this.high&&0===this.low},e.prototype.lessThan=function(e){return this.comp(e)<0},e.prototype.lt=function(e){return this.lessThan(e)},e.prototype.lessThanOrEqual=function(e){return this.comp(e)<=0},e.prototype.lte=function(e){return this.lessThanOrEqual(e)},e.prototype.modulo=function(t){if(e.isLong(t)||(t=e.fromValue(t)),ou){var n=(this.unsigned?ou.rem_u:ou.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(n,ou.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))},e.prototype.mod=function(e){return this.modulo(e)},e.prototype.rem=function(e){return this.modulo(e)},e.prototype.multiply=function(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),ou){var n=ou.mul(this.low,this.high,t.low,t.high);return e.fromBits(n,ou.get_high(),this.unsigned)}if(t.isZero())return e.ZERO;if(this.eq(e.MIN_VALUE))return t.isOdd()?e.MIN_VALUE:e.ZERO;if(t.eq(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(e.TWO_PWR_24)&&t.lt(e.TWO_PWR_24))return e.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);var r=this.high>>>16,o=65535&this.high,i=this.low>>>16,s=65535&this.low,a=t.high>>>16,c=65535&t.high,u=t.low>>>16,f=65535&t.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*u)>>>16,p&=65535,l+=(h+=o*f)>>>16,h&=65535,l+=(h+=i*u)>>>16,h&=65535,l+=(h+=s*c)>>>16,h&=65535,l+=r*f+o*u+i*c+s*a,l&=65535,e.fromBits(p<<16|d,l<<16|h,this.unsigned)},e.prototype.mul=function(e){return this.multiply(e)},e.prototype.negate=function(){return!this.unsigned&&this.eq(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)},e.prototype.neg=function(){return this.negate()},e.prototype.not=function(){return e.fromBits(~this.low,~this.high,this.unsigned)},e.prototype.notEquals=function(e){return!this.equals(e)},e.prototype.neq=function(e){return this.notEquals(e)},e.prototype.ne=function(e){return this.notEquals(e)},e.prototype.or=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)},e.prototype.shiftLeft=function(t){return e.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?e.fromBits(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):e.fromBits(0,this.low<<t-32,this.unsigned)},e.prototype.shl=function(e){return this.shiftLeft(e)},e.prototype.shiftRight=function(t){return e.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?e.fromBits(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):e.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},e.prototype.shr=function(e){return this.shiftRight(e)},e.prototype.shiftRightUnsigned=function(t){if(e.isLong(t)&&(t=t.toInt()),0===(t&=63))return this;var n=this.high;if(t<32){var r=this.low;return e.fromBits(r>>>t|n<<32-t,n>>>t,this.unsigned)}return 32===t?e.fromBits(n,0,this.unsigned):e.fromBits(n>>>t-32,0,this.unsigned)},e.prototype.shr_u=function(e){return this.shiftRightUnsigned(e)},e.prototype.shru=function(e){return this.shiftRightUnsigned(e)},e.prototype.subtract=function(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.neg())},e.prototype.sub=function(e){return this.subtract(e)},e.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},e.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*iu+(this.low>>>0):this.high*iu+(this.low>>>0)},e.prototype.toBigInt=function(){return BigInt(this.toString())},e.prototype.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},e.prototype.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},e.prototype.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},e.prototype.toSigned=function(){return this.unsigned?e.fromBits(this.low,this.high,!1):this},e.prototype.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(e.MIN_VALUE)){var n=e.fromNumber(t),r=this.div(n),o=r.mul(n).sub(this);return r.toString(t)+o.toInt().toString(t)}return"-"+this.neg().toString(t)}for(var i=e.fromNumber(Math.pow(t,6),this.unsigned),s=this,a="";;){var c=s.div(i),u=(s.sub(c.mul(i)).toInt()>>>0).toString(t);if((s=c).isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}},e.prototype.toUnsigned=function(){return this.unsigned?this:e.fromBits(this.low,this.high,!0)},e.prototype.xor=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low^t.low,this.high^t.high,this.unsigned)},e.prototype.eqz=function(){return this.isZero()},e.prototype.le=function(e){return this.lessThanOrEqual(e)},e.prototype.toExtendedJSON=function(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}},e.fromExtendedJSON=function(t,n){var r=e.fromString(t.$numberLong);return n&&n.relaxed?r.toNumber():r},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new Long("'.concat(this.toString(),'"').concat(this.unsigned?", true":"",")")},e.TWO_PWR_24=e.fromInt(16777216),e.MAX_UNSIGNED_VALUE=e.fromBits(-1,-1,!0),e.ZERO=e.fromInt(0),e.UZERO=e.fromInt(0,!0),e.ONE=e.fromInt(1),e.UONE=e.fromInt(1,!0),e.NEG_ONE=e.fromInt(-1),e.MAX_VALUE=e.fromBits(-1,2147483647,!1),e.MIN_VALUE=e.fromBits(0,-2147483648,!1),e}();Object.defineProperty(fu.prototype,"__isLong__",{value:!0}),Object.defineProperty(fu.prototype,"_bsontype",{value:"Long"});var lu=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,hu=/^(\+|-)?(Infinity|inf)$/i,pu=/^(\+|-)?NaN$/i,du=6111,yu=-6176,gu=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),vu=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),mu=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),_u=/^([-+])?(\d+)?$/;function bu(e){return!isNaN(parseInt(e,10))}function wu(e){var t=fu.fromNumber(1e9),n=fu.fromNumber(0);if(!(e.parts[0]||e.parts[1]||e.parts[2]||e.parts[3]))return{quotient:e,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new fu(e.parts[r],0)),e.parts[r]=n.div(t).low,n=n.modulo(t);return{quotient:e,rem:n}}function Eu(e,t){throw new qc('"'.concat(e,'" is not a valid Decimal128 string - ').concat(t))}var Su=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!Hc(e))throw new qc("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new qc("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(n){var r,o=!1,i=!1,s=!1,a=0,c=0,u=0,f=0,l=0,h=[0],p=0,d=0,y=0,g=0,v=0,m=0,_=new fu(0,0),b=new fu(0,0),w=0;if(n.length>=7e3)throw new qc(n+" not a valid Decimal128 string");var E=n.match(lu),S=n.match(hu),I=n.match(pu);if(!E&&!S&&!I||0===n.length)throw new qc(n+" not a valid Decimal128 string");if(E){var O=E[2],A=E[4],N=E[5],T=E[6];A&&void 0===T&&Eu(n,"missing exponent power"),A&&void 0===O&&Eu(n,"missing exponent base"),void 0===A&&(N||T)&&Eu(n,"missing e before exponent")}if("+"!==n[w]&&"-"!==n[w]||(o="-"===n[w++]),!bu(n[w])&&"."!==n[w]){if("i"===n[w]||"I"===n[w])return new t(e.from(o?vu:mu));if("N"===n[w])return new t(e.from(gu))}for(;bu(n[w])||"."===n[w];)"."!==n[w]?(p<34&&("0"!==n[w]||s)&&(s||(l=c),s=!0,h[d++]=parseInt(n[w],10),p+=1),s&&(u+=1),i&&(f+=1),c+=1,w+=1):(i&&Eu(n,"contains multiple periods"),i=!0,w+=1);if(i&&!c)throw new qc(n+" not a valid Decimal128 string");if("e"===n[w]||"E"===n[w]){var R=n.substr(++w).match(_u);if(!R||!R[2])return new t(e.from(gu));v=parseInt(R[0],10),w+=R[0].length}if(n[w])return new t(e.from(gu));if(y=0,p){if(g=p-1,1!==(a=u))for(;0===h[l+a-1];)a-=1}else y=0,g=0,h[0]=0,u=1,p=1,a=0;for(v<=f&&f-v>16384?v=yu:v-=f;v>du;){if((g+=1)-y>34){if(h.join("").match(/^0+$/)){v=du;break}Eu(n,"overflow")}v-=1}for(;v<yu||p<u;){if(0===g&&a<p){v=yu,a=0;break}if(p<u?u-=1:g-=1,v<du)v+=1;else{if(h.join("").match(/^0+$/)){v=du;break}Eu(n,"overflow")}}if(g-y+1<a){var P=c;i&&(l+=1,P+=1),o&&(l+=1,P+=1);var x=parseInt(n[l+g+1],10),L=0;if(x>=5&&(L=1,5===x))for(L=h[g]%2==1?1:0,m=l+g+2;m<P;m++)if(parseInt(n[m],10)){L=1;break}if(L)for(var C=g;C>=0;C--)if(++h[C]>9&&(h[C]=0,0===C)){if(!(v<du))return new t(e.from(o?vu:mu));v+=1,h[C]=1}}if(_=fu.fromNumber(0),b=fu.fromNumber(0),0===a)_=fu.fromNumber(0),b=fu.fromNumber(0);else if(g-y<17){C=y;for(b=fu.fromNumber(h[C++]),_=new fu(0,0);C<=g;C++)b=(b=b.multiply(fu.fromNumber(10))).add(fu.fromNumber(h[C]))}else{C=y;for(_=fu.fromNumber(h[C++]);C<=g-17;C++)_=(_=_.multiply(fu.fromNumber(10))).add(fu.fromNumber(h[C]));for(b=fu.fromNumber(h[C++]);C<=g;C++)b=(b=b.multiply(fu.fromNumber(10))).add(fu.fromNumber(h[C]))}var k,D,j,U,M=function(e,t){if(!e&&!t)return{high:fu.fromNumber(0),low:fu.fromNumber(0)};var n=e.shiftRightUnsigned(32),r=new fu(e.getLowBits(),0),o=t.shiftRightUnsigned(32),i=new fu(t.getLowBits(),0),s=n.multiply(o),a=n.multiply(i),c=r.multiply(o),u=r.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new fu(a.getLowBits(),0).add(c).add(u.shiftRightUnsigned(32)),{high:s=s.add(a.shiftRightUnsigned(32)),low:u=a.shiftLeft(32).add(new fu(u.getLowBits(),0))}}(_,fu.fromString("100000000000000000"));M.low=M.low.add(b),k=M.low,D=b,j=k.high>>>0,U=D.high>>>0,(j<U||j===U&&k.low>>>0<D.low>>>0)&&(M.high=M.high.add(fu.fromNumber(1))),r=v+6176;var q={low:fu.fromNumber(0),high:fu.fromNumber(0)};M.high.shiftRightUnsigned(49).and(fu.fromNumber(1)).equals(fu.fromNumber(1))?(q.high=q.high.or(fu.fromNumber(3).shiftLeft(61)),q.high=q.high.or(fu.fromNumber(r).and(fu.fromNumber(16383).shiftLeft(47))),q.high=q.high.or(M.high.and(fu.fromNumber(0x7fffffffffff)))):(q.high=q.high.or(fu.fromNumber(16383&r).shiftLeft(49)),q.high=q.high.or(M.high.and(fu.fromNumber(562949953421311)))),q.low=M.low,o&&(q.high=q.high.or(fu.fromString("9223372036854775808")));var W=e.alloc(16);return w=0,W[w++]=255&q.low.low,W[w++]=q.low.low>>8&255,W[w++]=q.low.low>>16&255,W[w++]=q.low.low>>24&255,W[w++]=255&q.low.high,W[w++]=q.low.high>>8&255,W[w++]=q.low.high>>16&255,W[w++]=q.low.high>>24&255,W[w++]=255&q.high.low,W[w++]=q.high.low>>8&255,W[w++]=q.high.low>>16&255,W[w++]=q.high.low>>24&255,W[w++]=255&q.high.high,W[w++]=q.high.high>>8&255,W[w++]=q.high.high>>16&255,W[w++]=q.high.high>>24&255,new t(W)},t.prototype.toString=function(){for(var e,t=0,n=new Array(36),r=0;r<n.length;r++)n[r]=0;var o,i,s,a=0,c=!1,u={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 fu(h,p),high:new fu(d,y)}.high.lessThan(fu.ZERO)&&f.push("-");var g=y>>26&31;if(g>>3==3){if(30===g)return f.join("")+"Infinity";if(31===g)return"NaN";e=y>>15&16383,o=8+(y>>14&1)}else o=y>>14&7,e=y>>17&16383;var v=e-6176;if(u.parts[0]=(16383&y)+((15&o)<<14),u.parts[1]=d,u.parts[2]=p,u.parts[3]=h,0===u.parts[0]&&0===u.parts[1]&&0===u.parts[2]&&0===u.parts[3])c=!0;else for(s=3;s>=0;s--){var m=0,_=wu(u);if(u=_.quotient,m=_.rem.low)for(i=8;i>=0;i--)n[9*s+i]=m%10,m=Math.floor(m/10)}if(c)t=1,n[a]=0;else for(t=36;!n[a];)t-=1,a+=1;var b=t-1+v;if(b>=34||b<=-7||v>0){if(t>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++])),(t-=1)&&f.push(".");for(r=0;r<t;r++)f.push("".concat(n[a++]));f.push("E"),b>0?f.push("+".concat(b)):f.push("".concat(b))}else if(v>=0)for(r=0;r<t;r++)f.push("".concat(n[a++]));else{var w=t+v;if(w>0)for(r=0;r<w;r++)f.push("".concat(n[a++]));else f.push("0");for(f.push(".");w++<0;)f.push("0");for(r=0;r<t-Math.max(w-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(Su.prototype,"_bsontype",{value:"Decimal128"});var Iu=function(){function e(t){if(!(this instanceof e))return new e(t);t instanceof Number&&(t=t.valueOf()),this.value=+t}return e.prototype.valueOf=function(){return this.value},e.prototype.toJSON=function(){return this.value},e.prototype.toString=function(e){return this.value.toString(e)},e.prototype.toExtendedJSON=function(e){return e&&(e.legacy||e.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-".concat(this.value.toFixed(1))}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}},e.fromExtendedJSON=function(t,n){var r=parseFloat(t.$numberDouble);return n&&n.relaxed?r:new e(r)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var e=this.toExtendedJSON();return"new Double(".concat(e.$numberDouble,")")},e}();Object.defineProperty(Iu.prototype,"_bsontype",{value:"Double"});var Ou=function(){function e(t){if(!(this instanceof e))return new e(t);t instanceof Number&&(t=t.valueOf()),this.value=0|+t}return e.prototype.valueOf=function(){return this.value},e.prototype.toString=function(e){return this.value.toString(e)},e.prototype.toJSON=function(){return this.value},e.prototype.toExtendedJSON=function(e){return e&&(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}},e.fromExtendedJSON=function(t,n){return n&&n.relaxed?parseInt(t.$numberInt,10):new e(t.$numberInt)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Int32(".concat(this.valueOf(),")")},e}();Object.defineProperty(Ou.prototype,"_bsontype",{value:"Int32"});var Au=function(){function e(){if(!(this instanceof e))return new e}return e.prototype.toExtendedJSON=function(){return{$maxKey:1}},e.fromExtendedJSON=function(){return new e},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new MaxKey()"},e}();Object.defineProperty(Au.prototype,"_bsontype",{value:"MaxKey"});var Nu=function(){function e(){if(!(this instanceof e))return new e}return e.prototype.toExtendedJSON=function(){return{$minKey:1}},e.fromExtendedJSON=function(){return new e},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new MinKey()"},e}();Object.defineProperty(Nu.prototype,"_bsontype",{value:"MinKey"});var Tu=new RegExp("^[0-9a-fA-F]{24}$"),Ru=null,Pu=Symbol("id"),xu=function(){function t(n){if(!(this instanceof t))return new t(n);var r;if("object"==typeof n&&n&&"id"in n){if("string"!=typeof n.id&&!ArrayBuffer.isView(n.id))throw new qc("Argument passed in must have an id that is of type string or Buffer");r="toHexString"in n&&"function"==typeof n.toHexString?e.from(n.toHexString(),"hex"):n.id}else r=n;if(null==r||"number"==typeof r)this[Pu]=t.generate("number"==typeof r?r:void 0);else if(ArrayBuffer.isView(r)&&12===r.byteLength)this[Pu]=r instanceof e?r:Vc(r);else{if("string"!=typeof r)throw new qc("Argument passed in does not match the accepted types");if(12===r.length){var o=e.from(r);if(12!==o.byteLength)throw new qc("Argument passed in must be a string of 12 bytes");this[Pu]=o}else{if(24!==r.length||!Tu.test(r))throw new qc("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[Pu]=e.from(r,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[Pu]},set:function(e){this[Pu]=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(e){this.id.writeUInt32BE(e,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(n){"number"!=typeof n&&(n=Math.floor(Date.now()/1e3));var r=t.getInc(),o=e.alloc(12);return o.writeUInt32BE(n,0),null===Ru&&(Ru=$c(5)),o[4]=Ru[0],o[5]=Ru[1],o[6]=Ru[2],o[7]=Ru[3],o[8]=Ru[4],o[11]=255&r,o[10]=r>>8&255,o[9]=r>>16&255,o},t.prototype.toString=function(e){return e?this.id.toString(e):this.toHexString()},t.prototype.toJSON=function(){return this.toHexString()},t.prototype.equals=function(n){if(null==n)return!1;if(n instanceof t)return this[Pu][11]===n[Pu][11]&&this[Pu].equals(n[Pu]);if("string"==typeof n&&t.isValid(n)&&12===n.length&&Hc(this.id))return n===e.prototype.toString.call(this.id,"latin1");if("string"==typeof n&&t.isValid(n)&&24===n.length)return n.toLowerCase()===this.toHexString();if("string"==typeof n&&t.isValid(n)&&12===n.length)return e.from(n).equals(this.id);if("object"==typeof n&&"toHexString"in n&&"function"==typeof n.toHexString){var r=n.toHexString(),o=this.toHexString().toLowerCase();return"string"==typeof r&&r.toLowerCase()===o}return!1},t.prototype.getTimestamp=function(){var e=new Date,t=this.id.readUInt32BE(0);return e.setTime(1e3*Math.floor(t)),e},t.createPk=function(){return new t},t.createFromTime=function(n){var r=e.from([0,0,0,0,0,0,0,0,0,0,0,0]);return r.writeUInt32BE(n,0),new t(r)},t.createFromHexString=function(n){if(void 0===n||null!=n&&24!==n.length)throw new qc("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(e.from(n,"hex"))},t.isValid=function(e){if(null==e)return!1;try{return new t(e),!0}catch(e){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(xu.prototype,"generate",{value:Kc((function(e){return xu.generate(e)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(xu.prototype,"getInc",{value:Kc((function(){return xu.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(xu.prototype,"get_inc",{value:Kc((function(){return xu.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(xu,"get_inc",{value:Kc((function(){return xu.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(xu.prototype,"_bsontype",{value:"ObjectID"});var Lu=function(){function e(t,n){if(!(this instanceof e))return new e(t,n);if(this.pattern=t,this.options=(null!=n?n:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new Mc("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new Mc("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 Mc("The regular expression option [".concat(this.options[r],"] is not supported"))}return e.parseOptions=function(e){return e?e.split("").sort().join(""):""},e.prototype.toExtendedJSON=function(e){return(e=e||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}},e.fromExtendedJSON=function(t){if("$regex"in t){if("string"==typeof t.$regex)return new e(t.$regex,e.parseOptions(t.$options));if("BSONRegExp"===t.$regex._bsontype)return t}if("$regularExpression"in t)return new e(t.$regularExpression.pattern,e.parseOptions(t.$regularExpression.options));throw new qc("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(t)))},e}();Object.defineProperty(Lu.prototype,"_bsontype",{value:"BSONRegExp"});var Cu=function(){function e(t){if(!(this instanceof e))return new e(t);this.value=t}return e.prototype.valueOf=function(){return this.value},e.prototype.toString=function(){return this.value},e.prototype.inspect=function(){return'new BSONSymbol("'.concat(this.value,'")')},e.prototype.toJSON=function(){return this.value},e.prototype.toExtendedJSON=function(){return{$symbol:this.value}},e.fromExtendedJSON=function(t){return new e(t.$symbol)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e}();Object.defineProperty(Cu.prototype,"_bsontype",{value:"Symbol"});var ku=function(e){function t(n,r){var o=this;return o instanceof t?(o=fu.isLong(n)?e.call(this,n.low,n.high,!0)||this:Gc(n)&&void 0!==n.t&&void 0!==n.i?e.call(this,n.i,n.t,!0)||this:e.call(this,n,r,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new t(n,r)}return Uc(t,e),t.prototype.toJSON=function(){return{$timestamp:this.toString()}},t.fromInt=function(e){return new t(fu.fromInt(e,!0))},t.fromNumber=function(e){return new t(fu.fromNumber(e,!0))},t.fromBits=function(e,n){return new t(e,n)},t.fromString=function(e,n){return new t(fu.fromString(e,!0,n))},t.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},t.fromExtendedJSON=function(e){return new t(e.$timestamp)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new Timestamp({ t: ".concat(this.getHighBits(),", i: ").concat(this.getLowBits()," })")},t.MAX_VALUE=fu.MAX_UNSIGNED_VALUE,t}(fu);var Du=2147483647,ju=-2147483648,Uu=0x8000000000000000,Mu=-0x8000000000000000,qu={$oid:xu,$binary:eu,$uuid:eu,$symbol:Cu,$numberInt:Ou,$numberDecimal:Su,$numberDouble:Iu,$numberLong:fu,$minKey:Nu,$maxKey:Au,$regex:Lu,$regularExpression:Lu,$timestamp:ku};function Wu(e,t){if(void 0===t&&(t={}),"number"==typeof e){if(t.relaxed||t.legacy)return e;if(Math.floor(e)===e){if(e>=ju&&e<=Du)return new Ou(e);if(e>=Mu&&e<=Uu)return fu.fromNumber(e)}return new Iu(e)}if(null==e||"object"!=typeof e)return e;if(e.$undefined)return null;for(var n=Object.keys(e).filter((function(t){return t.startsWith("$")&&null!=e[t]})),r=0;r<n.length;r++){var o=qu[n[r]];if(o)return o.fromExtendedJSON(e,t)}if(null!=e.$date){var i=e.$date,s=new Date;return t.legacy?"number"==typeof i?s.setTime(i):"string"==typeof i&&s.setTime(Date.parse(i)):"string"==typeof i?s.setTime(Date.parse(i)):fu.isLong(i)?s.setTime(i.toNumber()):"number"==typeof i&&t.relaxed&&s.setTime(i),s}if(null!=e.$code){var a=Object.assign({},e);return e.$scope&&(a.$scope=Wu(e.$scope)),nu.fromExtendedJSON(e)}if(function(e){return Gc(e)&&null!=e.$id&&"string"==typeof e.$ref&&(null==e.$db||"string"==typeof e.$db)}(e)||e.$dbPointer){var c=e.$ref?e:e.$dbPointer;if(c instanceof ru)return c;var u=Object.keys(c).filter((function(e){return e.startsWith("$")})),f=!0;if(u.forEach((function(e){-1===["$ref","$id","$db"].indexOf(e)&&(f=!1)})),f)return ru.fromExtendedJSON(c)}return e}function Fu(e){var t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function Bu(e,t){if(("object"==typeof e||"function"==typeof e)&&null!==e){var n=t.seenObjects.findIndex((function(t){return t.obj===e}));if(-1!==n){var r=t.seenObjects.map((function(e){return e.propertyName})),o=r.slice(0,n).map((function(e){return"".concat(e," -> ")})).join(""),i=r[n],s=" -> "+r.slice(n+1,r.length-1).map((function(e){return"".concat(e," -> ")})).join(""),a=r[r.length-1],c=" ".repeat(o.length+i.length/2),u="-".repeat(s.length+(i.length+a.length)/2-1);throw new qc("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(s).concat(a,"\n")+" ".concat(c,"\\").concat(u,"/"))}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return function(e,t){return e.map((function(e,n){t.seenObjects.push({propertyName:"index ".concat(n),obj:null});try{return Bu(e,t)}finally{t.seenObjects.pop()}}))}(e,t);if(void 0===e)return null;if(e instanceof Date||Gc(h=e)&&"[object Date]"===Object.prototype.toString.call(h)){var f=e.getTime(),l=f>-1&&f<2534023188e5;return t.legacy?t.relaxed&&l?{$date:e.getTime()}:{$date:Fu(e)}:t.relaxed&&l?{$date:Fu(e)}:{$date:{$numberLong:e.getTime().toString()}}}var h;if(!("number"!=typeof e||t.relaxed&&isFinite(e))){if(Math.floor(e)===e){var p=e>=Mu&&e<=Uu;if(e>=ju&&e<=Du)return{$numberInt:e.toString()};if(p)return{$numberLong:e.toString()}}return{$numberDouble:e.toString()}}if(e instanceof RegExp||function(e){return"[object RegExp]"===Object.prototype.toString.call(e)}(e)){var d=e.flags;if(void 0===d){var y=e.toString().match(/[gimuy]*$/);y&&(d=y[0])}return new Lu(e.source,d).toExtendedJSON(t)}return null!=e&&"object"==typeof e?function(e,t){if(null==e||"object"!=typeof e)throw new Mc("not an object instance");var n=e._bsontype;if(void 0===n){var r={};for(var o in e){t.seenObjects.push({propertyName:o,obj:null});try{var i=Bu(e[o],t);"__proto__"===o?Object.defineProperty(r,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):r[o]=i}finally{t.seenObjects.pop()}}return r}if(function(e){return Gc(e)&&Reflect.has(e,"_bsontype")&&"string"==typeof e._bsontype}(e)){var s=e;if("function"!=typeof s.toExtendedJSON){var a=Hu[e._bsontype];if(!a)throw new qc("Unrecognized or invalid _bsontype: "+e._bsontype);s=a(s)}return"Code"===n&&s.scope?s=new nu(s.code,Bu(s.scope,t)):"DBRef"===n&&s.oid&&(s=new ru(Bu(s.collection,t),Bu(s.oid,t),Bu(s.db,t),Bu(s.fields,t))),s.toExtendedJSON(t)}throw new Mc("_bsontype must be a string, but was: "+typeof n)}(e,t):e}var $u,Hu={Binary:function(e){return new eu(e.value(),e.sub_type)},Code:function(e){return new nu(e.code,e.scope)},DBRef:function(e){return new ru(e.collection||e.namespace,e.oid,e.db,e.fields)},Decimal128:function(e){return new Su(e.bytes)},Double:function(e){return new Iu(e.value)},Int32:function(e){return new Ou(e.value)},Long:function(e){return fu.fromBits(null!=e.low?e.low:e.low_,null!=e.low?e.high:e.high_,null!=e.low?e.unsigned:e.unsigned_)},MaxKey:function(){return new Au},MinKey:function(){return new Nu},ObjectID:function(e){return new xu(e)},ObjectId:function(e){return new xu(e)},BSONRegExp:function(e){return new Lu(e.pattern,e.options)},Symbol:function(e){return new Cu(e.value)},Timestamp:function(e){return ku.fromBits(e.low,e.high)}};!function(e){function t(e,t){var n=Object.assign({},{relaxed:!0,legacy:!1},t);return"boolean"==typeof n.relaxed&&(n.strict=!n.relaxed),"boolean"==typeof n.strict&&(n.relaxed=!n.strict),JSON.parse(e,(function(e,t){if(-1!==e.indexOf("\0"))throw new Mc("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(e)));return Wu(t,n)}))}function n(e,t,n,r){null!=n&&"object"==typeof n&&(r=n,n=0),null==t||"object"!=typeof t||Array.isArray(t)||(r=t,t=void 0,n=0);var o=Bu(e,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,t,n)}e.parse=t,e.stringify=n,e.serialize=function(e,t){return t=t||{},JSON.parse(n(e,t))},e.deserialize=function(e,n){return n=n||{},t(JSON.stringify(e),n)}}($u||($u={}));var Gu=Fc();Gu.Map?Gu.Map:function(){function e(e){void 0===e&&(e=[]),this._keys=[],this._values={};for(var t=0;t<e.length;t++)if(null!=e[t]){var n=e[t],r=n[0],o=n[1];this._keys.push(r),this._values[r]={v:o,i:this._keys.length-1}}}e.prototype.clear=function(){this._keys=[],this._values={}},e.prototype.delete=function(e){var t=this._values[e];return null!=t&&(delete this._values[e],this._keys.splice(t.i,1),!0)},e.prototype.entries=function(){var e=this,t=0;return{next:function(){var n=e._keys[t++];return{value:void 0!==n?[n,e._values[n].v]:void 0,done:void 0===n}}}},e.prototype.forEach=function(e,t){t=t||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];e.call(t,this._values[r].v,r,t)}},e.prototype.get=function(e){return this._values[e]?this._values[e].v:void 0},e.prototype.has=function(e){return null!=this._values[e]},e.prototype.keys=function(){var e=this,t=0;return{next:function(){var n=e._keys[t++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},e.prototype.set=function(e,t){return this._values[e]?(this._values[e].v=t,this):(this._keys.push(e),this._values[e]={v:t,i:this._keys.length-1},this)},e.prototype.values=function(){var e=this,t=0;return{next:function(){var n=e._keys[t++];return{value:void 0!==n?e._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0})}(),fu.fromNumber(zc),fu.fromNumber(Qc);var Ku=new Uint8Array(8);new DataView(Ku.buffer,Ku.byteOffset,Ku.byteLength);e.alloc(17825792);var Vu=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Ju=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},Yu=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=new bf.reqClass(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return Vu(this,void 0,void 0,(function(){var e;return Ju(this,(function(t){switch(t.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(e=t.sent())&&e.data&&e.data.list?[2,{requestId:e.requestId,data:JSON.parse(e.data.list).map($u.parse)}]:[2,e]}}))}))},e.prototype.unwrap=function(){return this._stages},e.prototype.done=function(){return this._stages.map((function(e){var t,n=e.stageKey,r=e.stageValue;return(t={})[n]=JSON.parse(r),t}))},e.prototype._pipe=function(e,t){return this._stages.push({stageKey:"$"+e,stageValue:JSON.stringify(t)}),this},e.prototype.addFields=function(e){return this._pipe("addFields",e)},e.prototype.bucket=function(e){return this._pipe("bucket",e)},e.prototype.bucketAuto=function(e){return this._pipe("bucketAuto",e)},e.prototype.count=function(e){return this._pipe("count",e)},e.prototype.geoNear=function(e){return this._pipe("geoNear",e)},e.prototype.group=function(e){return this._pipe("group",e)},e.prototype.limit=function(e){return this._pipe("limit",e)},e.prototype.match=function(e){return this._pipe("match",Lc.encode(e))},e.prototype.project=function(e){return this._pipe("project",e)},e.prototype.lookup=function(e){return this._pipe("lookup",e)},e.prototype.replaceRoot=function(e){return this._pipe("replaceRoot",e)},e.prototype.sample=function(e){return this._pipe("sample",e)},e.prototype.skip=function(e){return this._pipe("skip",e)},e.prototype.sort=function(e){return this._pipe("sort",e)},e.prototype.sortByCount=function(e){return this._pipe("sortByCount",e)},e.prototype.unwind=function(e){return this._pipe("unwind",e)},e}(),Zu=Yu,Xu=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),zu=function(e){function t(t,n){return e.call(this,t,n)||this}return Xu(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new xc(this._db,this._coll,e)},t.prototype.add=function(e,t){return new xc(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new Zu(this._db,this._coll)},t}(Dc),Qu={eq:function(e){return new cc(sc.EQ,[e])},neq:function(e){return new cc(sc.NEQ,[e])},lt:function(e){return new cc(sc.LT,[e])},lte:function(e){return new cc(sc.LTE,[e])},gt:function(e){return new cc(sc.GT,[e])},gte:function(e){return new cc(sc.GTE,[e])},in:function(e){return new cc(sc.IN,e)},nin:function(e){return new cc(sc.NIN,e)},all:function(e){return new cc(sc.ALL,e)},elemMatch:function(e){return new cc(sc.ELEM_MATCH,[e])},exists:function(e){return new cc(sc.EXISTS,[e])},size:function(e){return new cc(sc.SIZE,[e])},mod:function(e){return new cc(sc.MOD,[e])},geoNear:function(e){return new cc(sc.GEO_NEAR,[e])},geoWithin:function(e){return new cc(sc.GEO_WITHIN,[e])},geoIntersects:function(e){return new cc(sc.GEO_INTERSECTS,[e])},and:function(){var e=Ma(arguments[0])?arguments[0]:Array.from(arguments);return new oc(tc.AND,e)},nor:function(){var e=Ma(arguments[0])?arguments[0]:Array.from(arguments);return new oc(tc.NOR,e)},or:function(){var e=Ma(arguments[0])?arguments[0]:Array.from(arguments);return new oc(tc.OR,e)},not:function(){var e=Ma(arguments[0])?arguments[0]:Array.from(arguments);return new oc(tc.NOT,e)},set:function(e){return new nc(xa.SET,[e])},remove:function(){return new nc(xa.REMOVE,[])},inc:function(e){return new nc(xa.INC,[e])},mul:function(e){return new nc(xa.MUL,[e])},push:function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(ja(t[0])&&t[0].hasOwnProperty("each")){var r=t[0];e={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else e=Ma(t[0])?t[0]:Array.from(t);return new nc(xa.PUSH,e)},pull:function(e){return new nc(xa.PULL,e)},pullAll:function(e){return new nc(xa.PULL_ALL,e)},pop:function(){return new nc(xa.POP,[])},shift:function(){return new nc(xa.SHIFT,[])},unshift:function(){var e=Ma(arguments[0])?arguments[0]:Array.from(arguments);return new nc(xa.UNSHIFT,e)},addToSet:function(e){return new nc(xa.ADD_TO_SET,e)},rename:function(e){return new nc(xa.RENAME,[e])},bit:function(e){return new nc(xa.BIT,[e])},max:function(e){return new nc(xa.MAX,[e])},min:function(e){return new nc(xa.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===Da(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new Zu},abs:function(e){return new ef("abs",e)},add:function(e){return new ef("add",e)},ceil:function(e){return new ef("ceil",e)},divide:function(e){return new ef("divide",e)},exp:function(e){return new ef("exp",e)},floor:function(e){return new ef("floor",e)},ln:function(e){return new ef("ln",e)},log:function(e){return new ef("log",e)},log10:function(e){return new ef("log10",e)},mod:function(e){return new ef("mod",e)},multiply:function(e){return new ef("multiply",e)},pow:function(e){return new ef("pow",e)},sqrt:function(e){return new ef("sqrt",e)},subtract:function(e){return new ef("subtract",e)},trunc:function(e){return new ef("trunc",e)},arrayElemAt:function(e){return new ef("arrayElemAt",e)},arrayToObject:function(e){return new ef("arrayToObject",e)},concatArrays:function(e){return new ef("concatArrays",e)},filter:function(e){return new ef("filter",e)},in:function(e){return new ef("in",e)},indexOfArray:function(e){return new ef("indexOfArray",e)},isArray:function(e){return new ef("isArray",e)},map:function(e){return new ef("map",e)},range:function(e){return new ef("range",e)},reduce:function(e){return new ef("reduce",e)},reverseArray:function(e){return new ef("reverseArray",e)},size:function(e){return new ef("size",e)},slice:function(e){return new ef("slice",e)},zip:function(e){return new ef("zip",e)},and:function(e){return new ef("and",e)},not:function(e){return new ef("not",e)},or:function(e){return new ef("or",e)},cmp:function(e){return new ef("cmp",e)},eq:function(e){return new ef("eq",e)},gt:function(e){return new ef("gt",e)},gte:function(e){return new ef("gte",e)},lt:function(e){return new ef("lt",e)},lte:function(e){return new ef("lte",e)},neq:function(e){return new ef("ne",e)},cond:function(e){return new ef("cond",e)},ifNull:function(e){return new ef("ifNull",e)},switch:function(e){return new ef("switch",e)},dateFromParts:function(e){return new ef("dateFromParts",e)},dateFromString:function(e){return new ef("dateFromString",e)},dayOfMonth:function(e){return new ef("dayOfMonth",e)},dayOfWeek:function(e){return new ef("dayOfWeek",e)},dayOfYear:function(e){return new ef("dayOfYear",e)},isoDayOfWeek:function(e){return new ef("isoDayOfWeek",e)},isoWeek:function(e){return new ef("isoWeek",e)},isoWeekYear:function(e){return new ef("isoWeekYear",e)},millisecond:function(e){return new ef("millisecond",e)},minute:function(e){return new ef("minute",e)},month:function(e){return new ef("month",e)},second:function(e){return new ef("second",e)},hour:function(e){return new ef("hour",e)},week:function(e){return new ef("week",e)},year:function(e){return new ef("year",e)},literal:function(e){return new ef("literal",e)},mergeObjects:function(e){return new ef("mergeObjects",e)},objectToArray:function(e){return new ef("objectToArray",e)},allElementsTrue:function(e){return new ef("allElementsTrue",e)},anyElementTrue:function(e){return new ef("anyElementTrue",e)},setDifference:function(e){return new ef("setDifference",e)},setEquals:function(e){return new ef("setEquals",e)},setIntersection:function(e){return new ef("setIntersection",e)},setIsSubset:function(e){return new ef("setIsSubset",e)},setUnion:function(e){return new ef("setUnion",e)},concat:function(e){return new ef("concat",e)},dateToString:function(e){return new ef("dateToString",e)},indexOfBytes:function(e){return new ef("indexOfBytes",e)},indexOfCP:function(e){return new ef("indexOfCP",e)},split:function(e){return new ef("split",e)},strLenBytes:function(e){return new ef("strLenBytes",e)},strLenCP:function(e){return new ef("strLenCP",e)},strcasecmp:function(e){return new ef("strcasecmp",e)},substr:function(e){return new ef("substr",e)},substrBytes:function(e){return new ef("substrBytes",e)},substrCP:function(e){return new ef("substrCP",e)},toLower:function(e){return new ef("toLower",e)},toUpper:function(e){return new ef("toUpper",e)},meta:function(e){return new ef("meta",e)},addToSet:function(e){return new ef("addToSet",e)},avg:function(e){return new ef("avg",e)},first:function(e){return new ef("first",e)},last:function(e){return new ef("last",e)},max:function(e){return new ef("max",e)},min:function(e){return new ef("min",e)},push:function(e){return new ef("push",e)},stdDevPop:function(e){return new ef("stdDevPop",e)},stdDevSamp:function(e){return new ef("stdDevSamp",e)},sum:function(e){return new ef("sum",e)},let:function(e){return new ef("let",e)}},project:{slice:function(e){return new tf("slice",e)},elemMatch:function(e){return new tf("elemMatch",e)}}},ef=function(e,t){this["$"+e]=t},tf=function(e,t){this["$"+e]=t},nf=function(){function e(e){var t=e.regexp,n=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regex=t,this.$options=n}return e.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Ta},enumerable:!0,configurable:!0}),e}();function rf(e){return new nf(e)}var of={code:"INSERT_DOC_FAIL",message:"insert document failed"},sf={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},af=function(){return af=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},af.apply(this,arguments)},cf=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},uf=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},ff="database.updateDocInTransaction",lf=function(){function e(e,t,n){this._coll=t,this.id=n,this._transaction=e,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return e.prototype.create=function(e){return cf(this,void 0,void 0,(function(){var t,n,r,o;return uf(this,(function(i){switch(i.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:$u.stringify(vc(e),{relaxed:!1})},this.id&&(t._id=this.id),[4,this._request.send("database.insertDocInTransaction",t)];case 1:if((n=i.sent()).code)throw n;if(r=$u.parse(n.inserted),1==(o=$u.parse(n.ok))&&1==r)return[2,af(af({},n),{ok:o,inserted:r})];throw new Error(of.message)}}))}))},e.prototype.get=function(){return cf(this,void 0,void 0,(function(){var e,t;return uf(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,{data:"null"!==t.data?Ca.formatField($u.parse(t.data)):$u.parse(t.data),requestId:t.requestId}]}}))}))},e.prototype.set=function(e){return cf(this,void 0,void 0,(function(){var t,n;return uf(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:$u.stringify(vc(e),{relaxed:!1}),upsert:!0},[4,this._request.send(ff,t)];case 1:if((n=r.sent()).code)throw n;return[2,af(af({},n),{updated:$u.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},e.prototype.update=function(e){return cf(this,void 0,void 0,(function(){var t,n;return uf(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:$u.stringify(Nc.encode(e),{relaxed:!1})},[4,this._request.send(ff,t)];case 1:if((n=r.sent()).code)throw n;return[2,af(af({},n),{updated:$u.parse(n.updated)})]}}))}))},e.prototype.delete=function(){return cf(this,void 0,void 0,(function(){var e,t;return uf(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,af(af({},t),{deleted:$u.parse(t.deleted)})]}}))}))},e}(),hf=function(e,t){this._coll=t,this._transaction=e},pf=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),df=function(e){function t(t,n){return e.call(this,t,n)||this}return pf(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new lf(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new lf(this._transaction,this._coll,t).create(e)},t}(hf),yf=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},gf=function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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])}}},vf=function(){function e(e){this._db=e,this._request=new bf.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return yf(this,void 0,void 0,(function(){var e;return gf(this,(function(t){switch(t.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((e=t.sent()).code)throw e;return this.inited=!0,this._id=e.transactionId,[2]}}))}))},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new df(this,e)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return yf(this,void 0,void 0,(function(){var e,t;return gf(this,(function(n){switch(n.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.commitTransaction",e)];case 1:if((t=n.sent()).code)throw t;return this.commited=!0,[2,t]}}))}))},e.prototype.rollback=function(e){return yf(this,void 0,void 0,(function(){var t,n;return gf(this,(function(r){switch(r.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.abortTransaction",t)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=e,[2,n]}}))}))},e}();function mf(){return yf(this,void 0,void 0,(function(){var e;return gf(this,(function(t){switch(t.label){case 0:return[4,(e=new vf(this)).init()];case 1:return t.sent(),[2,e]}}))}))}function _f(e,t){return void 0===t&&(t=3),yf(this,void 0,void 0,(function(){var n,r,o,i,s=this;return gf(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new vf(this)).init()];case 1:return a.sent(),[4,e(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(e){return yf(s,void 0,void 0,(function(){return gf(this,(function(t){switch(t.label){case 0:if(n.aborted||n.commited)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,n.rollback()];case 2:case 3:return t.sent(),[3,4];case 4:throw e;case 5:if(!0===n.aborted)throw n.abortReason;throw e}}))}))},t<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===sf.code?[4,_f.bind(this)(e,--t)]:[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 bf=function(){function e(e){this.config=e,this.Geo=Qa,this.serverDate=Pa,this.command=Qu,this.RegExp=rf,this.startTransaction=mf,this.runTransaction=_f,this.logicCommand=oc,this.updateCommand=nc,this.queryCommand=cc}return e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new zu(this,e)},e.prototype.createCollection=function(t){var n={collectionName:t};return new e.reqClass(this.config).send("database.addCollection",n)},e}(),wf=function(){return wf=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},wf.apply(this,arguments)};var Ef={name:"database",entity:{database:function(e){var t=this.platform,n=t.adapter,r=t.runtime;return bf.reqClass=this.request.constructor,bf.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},bf.runtime=r,this.wsClientClass&&(bf.wsClass=n.wsClass,bf.wsClientClass=this.wsClientClass),bf.ws||(bf.ws=null),new bf(wf(wf({},this.config),e))}}};try{cloudbase.registerComponent(Ef)}catch(e){}var Sf,If="1.7.2";Jt.registerVersion(If);try{!function(e){try{e.registerComponent(Mr)}catch(e){console.warn(e)}}(Jt),function(e){try{e.registerComponent(Xr)}catch(e){console.warn(e)}}(Jt),function(e){try{e.registerComponent(po)}catch(e){console.warn(e)}}(Jt),function(e){try{e.registerComponent(Ef)}catch(e){console.warn(e)}}(Jt),function(e){try{e.registerComponent(js),e.registerHook(Ds)}catch(e){console.warn(e)}}(Jt),function(e){try{e.registerComponent(Ys)}catch(e){console.warn(e)}}(Jt)}catch(e){}try{window.cloudbase=Jt}catch(e){}!function(e){e.development="dev-1gpp53ju3ceb46c7",e.production="release-7gvojkxi667a3f26"}(Sf||(Sf={}));var Of={ENV:Sf[process.env.NODE_ENV],REGION:"ap-shanghai"},Af={region:Of.REGION,env:Of.ENV},Nf=Jt.init(Af);function Tf(e){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return[4,Nf.callFunction(e)];case 1:return t=n.sent(),[2,new Promise((function(e,n){var r;(null===(r=t.result)||void 0===r?void 0:r.success)?e(t.result.data):n(t.result)}))]}}))}))}export{Tf as callFunction};