@be-link/request 1.13.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/beLinkRequest.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Buffer as e}from"buffer";import t,{AxiosError as n}from"axios";import r from"crypto-js";function o(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 i(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 s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function c(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 u={},f={},l={};Object.defineProperty(l,"__esModule",{value:!0}),l.COMMUNITY_SITE_URL=l.IS_DEBUG_MODE=l.getProtocol=l.setProtocol=l.getSdkName=l.setSdkName=void 0;var h="@cloudbase/js-sdk";l.setSdkName=function(e){h=e},l.getSdkName=function(){return h};var p="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";l.setProtocol=function(e){p=e},l.getProtocol=function(){return p},l.IS_DEBUG_MODE="development"===process.env.NODE_ENV,l.COMMUNITY_SITE_URL="https://support.qq.com/products/148793";var d={};Object.defineProperty(d,"__esModule",{value:!0}),d.ERRORS=void 0,d.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=s&&s.__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=s&&s.__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(l,e),n(d,e)}(f);var y,g={},v={};!function(e){e.local="local",e.none="none",e.session="session"}(y||(y={}));var m=function(){},_=function(){};function b(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 w,E=c(Object.freeze({__proto__:null,AbstractSDKRequest:m,AbstractStorage:_,get StorageType(){return y},formatUrl:b})),S={},I={exports:{}},O={exports:{}};function A(){return w||(w=1,O.exports=function(){var 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);return e}()),O.exports}var N,T={exports:{}};function R(){return N||(N=1,T.exports=function(e){return 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}(A())),T.exports}var P,x,L,k,C={exports:{}};I.exports=function(e){return e.HmacSHA256}(A(),R(),P||(P=1,C.exports=(L=(x=A()).lib.Base,k=x.enc.Utf8,void(x.algo.HMAC=L.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=k.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 D=I.exports,j={exports:{}};j.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}(A());var U=j.exports,M={exports:{}};M.exports=function(e){return e.enc.Utf8}(A());var q=M.exports,W=s&&s.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(S,"__esModule",{value:!0}),S.transformPhone=S.sleep=S.printGroupLog=S.throwError=S.printInfo=S.printError=S.printWarn=S.execCallback=S.createPromiseCallback=S.removeParam=S.getHash=S.getQuery=S.toQueryString=S.createSign=S.formatUrl=S.genSeqId=S.isFormData=S.isInstanceOf=S.isNull=S.isPalinObject=S.isUndefined=S.isString=S.isArray=void 0;var F=W(D),B=W(U),$=W(q),H=f;function G(e){var t=B.default.stringify(e);return t=(t=(t=t.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}S.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},S.isString=function(e){return"string"==typeof e},S.isUndefined=function(e){return void 0===e},S.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},S.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},S.isInstanceOf=function(e,t){return e instanceof t},S.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},S.genSeqId=function(){return Math.random().toString(16).slice(2)},S.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},S.createSign=function(e,t){var n=G($.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+G($.default.parse(JSON.stringify(e)));return n+"."+G(F.default(n,t))},S.toQueryString=function(e){void 0===e&&(e={});var t=[];for(var n in e)t.push(n+"="+encodeURIComponent(e[n]));return t.join("&")},S.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]:""},S.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]"+e+"=([^&#]*)"));return t?t[1]:""},S.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},S.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},S.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},S.printWarn=function(e,t){console.warn("["+H.getSdkName()+"]["+e+"]:"+t)},S.printError=function(e,t){console.error({code:e,msg:"["+H.getSdkName()+"]["+e+"]:"+t})},S.printInfo=function(e,t){console.log("["+H.getSdkName()+"]["+e+"]:"+t)},S.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"["+H.getSdkName()+"]["+e+"]:"+t}))},S.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()},S.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},S.transformPhone=function(e){return"+86"+e};var K,V=s&&s.__extends||(K=function(e,t){return K=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])},K(e,t)},function(e,t){function n(){this.constructor=e}K(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),J=s&&s.__assign||function(){return J=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},J.apply(this,arguments)},Y=s&&s.__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())}))},Z=s&&s.__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(v,"__esModule",{value:!0}),v.WebRequest=v.genAdapter=void 0;var z=S,X=l,Q=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 V(t,e),t.prototype.get=function(e){return this._request(J(J({},e),{method:"get"}),this._restrictedMethods.includes("get"))},t.prototype.post=function(e){return this._request(J(J({},e),{method:"post"}),this._restrictedMethods.includes("post"))},t.prototype.put=function(e){return this._request(J(J({},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(J(J({},e),{data:o,method:"post"}),this._restrictedMethods.includes("upload"))},t.prototype.download=function(e){return Y(this,void 0,void 0,(function(){var t,n,r,o;return Z(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(J(J({},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=z.formatUrl(X.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=z.isFormData(f)?f:"application/x-www-form-urlencoded"===u["content-type"]?z.toQueryString(f):p||(f?JSON.stringify(f):void 0),h&&(g.withCredentials=!0),g.send(s)}))},t}(E.AbstractSDKRequest);v.WebRequest=Q,v.genAdapter=function(){return{root:window,reqClass:Q,wsClass:WebSocket,localStorage:localStorage,sessionStorage:sessionStorage}},function(e){var t=s&&s.__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=s&&s.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=s&&s.__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 o,i=r(v),a=S;!function(e){e.WEB="web",e.WX_MP="wx_mp"}(o=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:i.genAdapter(),runtime:o.WEB}}}(g);var ee={},te=s&&s.__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)}}(),ne=s&&s.__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())}))},re=s&&s.__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(ee,"__esModule",{value:!0}),ee.CloudbaseCache=void 0;var oe=S,ie=f,se=function(e){function t(t){var n=e.call(this)||this;return n._root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return te(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}(E.AbstractStorage);function ae(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:(oe.printWarn(ie.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new se(t.root));case"none":return new se(t.root);case"session":return t.sessionStorage?t.sessionStorage:(oe.printWarn(ie.ERRORS.INVALID_PARAMS,"sessionStorage is not supported on current platform"),new se(t.root))}}var ce=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=ae(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=ae(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);oe.isUndefined(i)||oe.isNull(i)||(n.setItem(o,i),this._storage.removeItem(o))}}this._storage=n}}else oe.printWarn(ie.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use updatePersistenceAsync insteed")},e.prototype.updatePersistenceAsync=function(e){return ne(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c;return re(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=ae(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(),oe.isUndefined(c)||oe.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:ie.ERRORS.OPERATION_FAIL,msg:"["+ie.getSdkName()+"]["+ie.ERRORS.OPERATION_FAIL+"]setStore failed",info:e}))}}else oe.printWarn(ie.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,n){return ne(this,void 0,void 0,(function(){var r;return re(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:""}oe.printWarn(ie.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var n;return ne(this,void 0,void 0,(function(){var r;return re(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):oe.printWarn(ie.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return ne(this,void 0,void 0,(function(){return re(this,(function(t){switch(t.label){case 0:return[4,this._storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}();ee.CloudbaseCache=ce;var ue={},fe=s&&s.__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)}}(),le=s&&s.__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(ue,"__esModule",{value:!0}),ue.removeEventListener=ue.activateEvent=ue.addEventListener=ue.CloudbaseEventEmitter=ue.IErrorEvent=ue.CloudbaseEvent=void 0;var he=S;var pe=function(e,t){this.data=t||null,this.name=e};ue.CloudbaseEvent=pe;var de=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return fe(t,e),t}(pe);ue.IErrorEvent=de;var ye=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(he.isInstanceOf(e,de))return console.error(e.error),this;var n=he.isString(e)?new pe(e,t||{}):e,r=n.name;if(this._listens(r)){n.target=this;for(var o=0,i=this._listeners[r]?le(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}();ue.CloudbaseEventEmitter=ye;var ge=new ye;ue.addEventListener=function(e,t){ge.on(e,t)},ue.activateEvent=function(e,t){void 0===t&&(t={}),ge.fire(e,t)},ue.removeEventListener=function(e,t){ge.off(e,t)};var ve={},me={},_e=s&&s.__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())}))},be=s&&s.__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(me,"__esModule",{value:!0}),me.catchErrorsDecorator=void 0;var we=S,Ee=f,Se=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(Se=-1!==navigator.userAgent.indexOf("Firefox"));var Ie=Se?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,Oe=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function Ae(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=Se?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]\\s*\\(.*\\)$"),c=Se?/^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(Oe,o)),(i=new Error).stack=(Se?"@debugger":"Error")+"\n"+f.join("\n")}return i}me.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(Ee.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 Ie.test(e)}));if(-1!==r){var o=Oe.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=Ae({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 we.printGroupLog(l),r}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return _e(this,void 0,void 0,(function(){var t,n,r,o,l,h;return be(this,(function(p){switch(p.label){case 0:t=Ae({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}})))),we.printGroupLog(l),r;case 4:return[2]}}))}))}}}},function(e){var t=s&&s.__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=s&&s.__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(me,e)}(ve);var Ne=s&&s.__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]}),Te=s&&s.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Re=s&&s.__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)&&Ne(t,e,n);return Te(t,e),t};Object.defineProperty(u,"__esModule",{value:!0});var Pe=u.helpers=u.utils=u.events=u.cache=u.adapters=u.constants=void 0,xe=Re(f),Le=u.constants=xe,ke=Re(g),Ce=u.adapters=ke,De=Re(ee),je=u.cache=De,Ue=Re(ue),Me=u.events=Ue,qe=Re(S),We=u.utils=qe,Fe=Re(ve);Pe=u.helpers=Fe;var Be=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)}}(),$e=function(){return $e=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},$e.apply(this,arguments)},He=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())}))},Ge=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 Ke=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 Be(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:b("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 He(t,void 0,void 0,(function(){var t,o,i,s,a,c;return Ge(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:$e({},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:b("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}(m),Ve={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()}},Je=function(e,t){void 0===t&&(t={});var n=wx.connectSocket($e({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 Ye={genAdapter:function(){return{root:{},reqClass:Ke,wsClass:Je,localStorage:Ve,primaryStorage:y.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"},Ze=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},ze=Le.ERRORS,Xe={};function Qe(e,t){var n=t.name,r=t.namespace,o=t.entity,i=t.injectEvents,s=t.IIFE,a=void 0!==s&&s;if(Xe[n]||r&&e[r])throw new Error(JSON.stringify({code:ze.INVALID_OPERATION,msg:"Duplicate component "+n}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:ze.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(e)}if(Xe[n]=t,r?e.prototype[r]=o:et(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=Ze(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 et(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]=et(e[n],t[n]));return e}var tt={},nt=function(){return nt=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},nt.apply(this,arguments)},rt=je.CloudbaseCache,ot={},it={};function st(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};ot[t]?ot[t].updatePersistence(n):ot[t]=new rt(nt(nt({},e),{keys:o,platformInfo:r,alwaysLocalKeys:["anonymousUuidKey"]})),it[t]=it[t]||new rt(nt(nt({},e),{keys:o,platformInfo:r,persistence:"local"}))}function at(e){return ot[e]}function ct(e){return it[e]}var ut=Le.setSdkName,ft=Le.setProtocol,lt="",ht="@cloudbase/js-sdk";var pt,dt="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",yt="undefined"!=typeof process&&"e2e"===process.env.NODE_ENV&&"pre"===process.env.END_POINT?"//tcb-pre.tencentcloudapi.com/web":"//tcb-api.tencentcloudapi.com/web";function gt(e,t){yt=e,t&&(dt=t,ft(t))}function vt(){return{BASE_URL:yt,PROTOCOL:dt}}!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.CUSTOM="CUSTOM",e.NULL="NULL"}(pt||(pt={}));var mt="loginStateExpire",_t="refreshAccessToken",bt=function(){return bt=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},bt.apply(this,arguments)},wt=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())}))},Et=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])}}},St=Le.ERRORS,It=We.genSeqId,Ot=We.isFormData,At=We.formatUrl,Nt=We.createSign,Tt=Ce.RUNTIME,Rt=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function Pt(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(Ot(s))for(var e in o)s.append(e,o[e]);else t.data=bt(bt({},s),o)}(),t.headers=bt(bt({},t.headers||{}),i),r.call(e,t)}}function xt(){var e=It();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+lt,"x-seqid":e}}}var Lt=function(){function e(e){this._throwWhenRequestFail=!1,this.config=e,this._reqClass=new tt.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post"]}),this._throwWhenRequestFail=e.throw||!1,this._cache=at(this.config.env),this._localCache=ct(this.config.env),Pt(this._reqClass,"post",[xt]),Pt(this._reqClass,"upload",[xt]),Pt(this._reqClass,"download",[xt])}return e.prototype.post=function(e){return wt(this,void 0,void 0,(function(){return Et(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 wt(this,void 0,void 0,(function(){return Et(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 wt(this,void 0,void 0,(function(){return Et(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 wt(this,void 0,void 0,(function(){var e,t,n;return Et(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 wt(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a,c;return Et(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:St.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 wt(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 Et(this,(function(R){switch(R.label){case 0:return r="x-tcb-trace_"+this.config.env,o="application/x-www-form-urlencoded",i=bt({action:e,dataVersion:"2020-01-10",env:this.config.env},t),-1!==Rt.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),tt.runtime!==Tt.WEB&&(h=this.config,p=h.appSign,d=h.appSecret,y=Date.now(),g=d.appAccessKey,v=d.appAccessKeyId,m=Nt({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=bt(bt({},b),E)),S=vt(),I=S.BASE_URL,O=S.PROTOCOL,A=At(O,I,E),w&&(A+=w),[4,this.post(bt({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={}),wt(this,void 0,void 0,(function(){var n;return Et(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!==Rt.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:St.OPERATION_FAIL,msg:"["+n.data.code+"] "+n.data.message}));return[2,n.data]}}))}))},e.prototype._refreshAccessToken=function(e){return void 0===e&&(e=1),wt(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,u,f,l,h,p;return Et(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:St.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()===pt.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:St.OPERATION_FAIL,message:"重试获取 refresh token 失败"}));case 9:return Zt.fire(mt),[4,this._cache.removeStoreAsync(o)];case 10:d.sent(),d.label=11;case 11:throw new Error(JSON.stringify({code:St.NETWORK_ERROR,msg:"refresh access_token failed:"+u.data.code}));case 12:return u.data.access_token?(Zt.fire(_t),[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 wt(this,void 0,void 0,(function(){var t,n,r,o;return Et(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}(),kt={};var Ct=function(){return Ct=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},Ct.apply(this,arguments)},Dt=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},jt=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ut=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())}))},Mt=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])}}},qt=Ce.useAdapters,Wt=Ce.useDefaultAdapter,Ft=Ce.RUNTIME,Bt=Le.ERRORS,$t=Le.COMMUNITY_SITE_URL,Ht=We.printWarn,Gt=Pe.catchErrorsDecorator,Kt={timeout:15e3,persistence:"local"},Vt=6e5,Jt={},Yt=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 tt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return at(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return ct(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return e=this._config.env,kt[e];var e},enumerable:!1,configurable:!0}),e.prototype.init=function(t){if(!t.env)throw new Error(JSON.stringify({code:Bt.INVALID_PARAMS,msg:"env must not be specified"}));if(tt.adapter||this._useDefaultAdapter(),this.requestClient=new tt.adapter.reqClass({timeout:t.timeout||5e3,timeoutMsg:"["+ht+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+t.timeout/1e3+"s"}),tt.runtime!==Ft.WEB){if(!t.appSecret)throw new Error(JSON.stringify({code:Bt.INVALID_PARAMS,msg:"invalid appSecret"}));var n=tt.adapter.getAppSign?tt.adapter.getAppSign():"";if(t.appSign&&n&&t.appSign!==n)throw new Error(JSON.stringify({code:Bt.INVALID_PARAMS,msg:"invalid appSign"}));if(n&&(t.appSign=n),!t.appSign)throw new Error(JSON.stringify({code:Bt.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=Ct(Ct({},Kt),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;st({env:o,persistence:i,debug:s,platformInfo:this.platform}),function(e){kt[e.env]=new Lt(bt(bt({},e),{throw:!0}))}({env:o,region:t.region||"",timeout:a,appSecret:c,appSign:u}),t.region&&function(e,t,n){gt(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,st({env:this._config.env,persistence:t,debug:n,platformInfo:this.platform})},e.prototype.registerExtension=function(e){Jt[e.name]=e},e.prototype.invokeExtension=function(e,t){return Ut(this,void 0,void 0,(function(){var n;return Mt(this,(function(r){switch(r.label){case 0:if(!(n=Jt[e]))throw new Error(JSON.stringify({code:Bt.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=qt(e)||{},n=t.adapter,r=t.runtime;n&&(tt.adapter=n),r&&(tt.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:ze.INVALID_OPERATION,msg:"target:"+r+" is not exist"}));var o=e.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:ze.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,Ze([this],e)),o.call.apply(o,Ze([this],e))}}(e,t)},e.prototype.registerComponent=function(t){Qe(e,t)},e.prototype.registerVersion=function(e){!function(e){lt=e}(e)},e.prototype.registerSdkName=function(e){!function(e){ht=e,ut(e)}(e)},e.prototype.registerEndPoint=function(e,t){gt(e,t)},e.prototype._useDefaultAdapter=function(){var e=Wt(),t=e.adapter,n=e.runtime;tt.adapter=t,tt.runtime=n},e.prototype._formatTimeout=function(e){switch(!0){case e>Vt:return Ht(Bt.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),Vt;case e<100:return Ht(Bt.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},Dt([Gt({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+$t]}),jt("design:type",Function),jt("design:paramtypes",[Object]),jt("design:returntype",e)],e.prototype,"init",null),Dt([Gt({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+$t]}),jt("design:type",Function),jt("design:paramtypes",[String,Object]),jt("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}(),Zt=new Yt;Zt.useAdapters(Ye);var zt,Xt=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())}))},Qt=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])}}},en=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request}return e.prototype.checkLocalLoginState=function(){return Xt(this,void 0,void 0,(function(){var e,t,n,r,o,i;return Qt(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 Ur({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 Xt(this,void 0,void 0,(function(){var t,n,r,o;return Qt(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 Xt(this,void 0,void 0,(function(){var n,r,o;return Qt(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 Xt(this,void 0,void 0,(function(){var e;return Qt(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 Xt(this,void 0,void 0,(function(){var t;return Qt(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"}(zt||(zt={}));var 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)}}(),nn=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},rn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},on=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())}))},sn=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])}}},an=Le.getSdkName,cn=Le.ERRORS,un=Le.COMMUNITY_SITE_URL,fn=Ce.RUNTIME,ln=We.getQuery,hn=We.getHash,pn=We.removeParam,dn=We.printWarn,yn=Pe.catchErrorsDecorator,gn=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 tn(t,e),t.prototype.signIn=function(){return on(this,void 0,void 0,(function(){return sn(this,(function(e){return[2,dn(cn.OPERATION_FAIL,"API signIn has been deprecated, please use signInWithRedirect insteed")]}))}))},t.prototype.signInWithRedirect=function(){return on(this,void 0,void 0,(function(){return sn(this,(function(e){return[2,this._redirect()]}))}))},t.prototype.getRedirectResult=function(e){return on(this,void 0,void 0,(function(){var t;return sn(this,(function(n){return(t=vn())?[2,this._signInWithCode(t,e)]:[2,null]}))}))},t.prototype.getLinkRedirectResult=function(e){return void 0===e&&(e={}),on(this,void 0,void 0,(function(){var t,n,r,o,i,s;return sn(this,(function(a){return t=e.withUnionId,n=void 0!==t&&t,(r=vn())?(o=this._appid,c=this._scope,i="snsapi_login"===c?"WECHAT-OPEN":"WECHAT-PUBLIC",s=this._runtime===fn.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=pn("code",location.href);e=pn("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("["+an()+"]["+cn.UNKOWN_ERROR+"]"+e)}},t.prototype._signInWithCode=function(e,t){return on(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u;return sn(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 Dr.fire(qr.LOGIN_STATE_CHANGED),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:zt.WECHAT,persistence:this._config.persistence}),[4,this.refreshUserInfo()];case 7:return f.sent(),[4,(u=new Ur({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={}),on(this,void 0,void 0,(function(){var o,i,s,a,c,u;return sn(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===fn.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("["+an()+"]["+cn.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("["+an()+"]["+cn.OPERATION_FAIL+"] action:getJwt not return refreshToken")}))]}))}))},nn([yn({title:"跳转微信公众号授权失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().signInWithRedirect() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+un]}),rn("design:type",Function),rn("design:paramtypes",[]),rn("design:returntype",Promise)],t.prototype,"signInWithRedirect",null),nn([yn({title:"微信公众号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+un]}),rn("design:type",Function),rn("design:paramtypes",[Object]),rn("design:returntype",Promise)],t.prototype,"getRedirectResult",null),nn([yn({title:"获取微信重定向绑定结果",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getLinkRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+un]}),rn("design:type",Function),rn("design:paramtypes",[Object]),rn("design:returntype",Promise)],t.prototype,"getLinkRedirectResult",null),t}(en);function vn(){return ln("code")||hn("code")}var 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)}}(),_n=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},bn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},wn=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())}))},En=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])}}},Sn=Le.ERRORS,In=Le.COMMUNITY_SITE_URL,On=We.throwError,An=We.isString,Nn=Me.addEventListener,Tn=Pe.catchErrorsDecorator,Rn=function(e){function t(t){var n=e.call(this,t)||this;return n._onConverted=n._onConverted.bind(n),Nn(qr.ANONYMOUS_CONVERTED,n._onConverted),n}return mn(t,e),t.prototype.signIn=function(){return wn(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return En(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(),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:zt.ANONYMOUS,persistence:"local"}),Dr.fire(qr.LOGIN_STATE_CHANGED),[4,(s=new Ur({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:Sn.OPERATION_FAIL,msg:JSON.stringify(i)||"anonymous signIn failed"}))}}))}))},t.prototype.linkAndRetrieveDataWithTicket=function(e){return wn(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return En(this,(function(c){switch(c.label){case 0:return An(e)||On(Sn.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(),Dr.fire(qr.ANONYMOUS_CONVERTED,{env:this._config.env}),Dr.fire(qr.LOGIN_TYPE_CHANGED,{loginType:zt.CUSTOM,persistence:"local"}),[4,(a=new Ur({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 7:return c.sent(),[2,a];case 8:On(Sn.OPERATION_FAIL,JSON.stringify(s)||"linkAndRetrieveDataWithTicket failed"),c.label=9;case 9:return[2]}}))}))},t.prototype._setAnonymousUUID=function(e){return wn(this,void 0,void 0,(function(){var t,n,r;return En(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,zt.ANONYMOUS)];case 3:return o.sent(),[2]}}))}))},t.prototype._clearAnonymousUUID=function(){return wn(this,void 0,void 0,(function(){return En(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 wn(this,void 0,void 0,(function(){return En(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]}}))}))},_n([Tn({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().anonymouseProvider().signIn() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+In]}),bn("design:type",Function),bn("design:paramtypes",[]),bn("design:returntype",Promise)],t.prototype,"signIn",null),t}(en),Pn=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)}}(),xn=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},Ln=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},kn=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())}))},Cn=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])}}},Dn=Le.ERRORS,jn=Le.COMMUNITY_SITE_URL,Un=We.isString,Mn=Pe.catchErrorsDecorator,qn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Pn(t,e),t.prototype.signIn=function(e){return kn(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return Cn(this,(function(c){switch(c.label){case 0:if(!Un(e))throw new Error(JSON.stringify({code:Dn.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(),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:zt.CUSTOM,persistence:this._config.persistence}),Dr.fire(qr.LOGIN_STATE_CHANGED),[4,this.refreshUserInfo()];case 5:return c.sent(),[4,(a=new Ur({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:Dn.OPERATION_FAIL,msg:"custom signIn failed"}))}}))}))},xn([Mn({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().customAuthProvider().signIn() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+jn]}),Ln("design:type",Function),Ln("design:paramtypes",[String]),Ln("design:returntype",Promise)],t.prototype,"signIn",null),t}(en),Wn=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)}}(),Fn=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},Bn=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())}))},Hn=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])}}},Gn=We.throwError,Kn=We.isString,Vn=Le.ERRORS,Jn=Le.COMMUNITY_SITE_URL,Yn=Pe.catchErrorsDecorator,Zn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Wn(t,e),t.prototype.signIn=function(e,t){return $n(this,void 0,void 0,(function(){var n,r,o,i,s;return Hn(this,(function(a){switch(a.label){case 0:return Kn(e)||Gn(Vn.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(),Dr.fire(qr.LOGIN_STATE_CHANGED),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:zt.EMAIL,persistence:this._config.persistence}),[2,new Ur({envId:this._config.env,cache:this._cache,request:this._request})];case 8:r.code?Gn(Vn.OPERATION_FAIL,"Email login fail["+r.code+"] "+r.message):Gn(Vn.OPERATION_FAIL,"Email login fail"),a.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t){return $n(this,void 0,void 0,(function(){return Hn(this,(function(n){return[2,this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})]}))}))},t.prototype.resetPassword=function(e){return $n(this,void 0,void 0,(function(){return Hn(this,(function(t){return[2,this._request.send("auth.sendPasswordResetEmail",{email:e})]}))}))},t.prototype.resetPasswordWithToken=function(e,t){return $n(this,void 0,void 0,(function(){return Hn(this,(function(n){return[2,this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})]}))}))},t.prototype.activate=function(e){return $n(this,void 0,void 0,(function(){return Hn(this,(function(t){return[2,this._request.send("auth.activateEndUserMail",{token:e})]}))}))},Fn([Yn({title:"邮箱密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().emailAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 邮箱地址与密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Jn]}),Bn("design:type",Function),Bn("design:paramtypes",[String,String]),Bn("design:returntype",Promise)],t.prototype,"signIn",null),Fn([Yn({title:"邮箱注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithEmailAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Jn]}),Bn("design:type",Function),Bn("design:paramtypes",[String,String]),Bn("design:returntype",Promise)],t.prototype,"signUp",null),Fn([Yn({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用 auth().sendPasswordResetEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经与当前用户绑定"," 4 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Jn]}),Bn("design:type",Function),Bn("design:paramtypes",[String]),Bn("design:returntype",Promise)],t.prototype,"resetPassword",null),Fn([Yn({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Jn]}),Bn("design:type",Function),Bn("design:paramtypes",[String,String]),Bn("design:returntype",Promise)],t.prototype,"resetPasswordWithToken",null),Fn([Yn({title:"邮箱激活失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Jn]}),Bn("design:type",Function),Bn("design:paramtypes",[String]),Bn("design:returntype",Promise)],t.prototype,"activate",null),t}(en),zn=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)}}(),Xn=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},Qn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},er=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())}))},tr=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])}}},nr=We.printWarn,rr=Le.ERRORS,or=Le.COMMUNITY_SITE_URL,ir=Pe.catchErrorsDecorator,sr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return zn(t,e),t.prototype.signIn=function(e,t){return er(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u,f;return tr(this,(function(l){switch(l.label){case 0:if("string"!=typeof e)throw new Error(JSON.stringify({code:rr.INVALID_PARAMS,msg:"username must be a string"}));return"string"!=typeof t&&(t="",nr(rr.INVALID_PARAMS,"password is empty")),n=this._cache.keys.refreshTokenKey,i=(o=this._request).send,s=["auth.signIn"],a={loginType:zt.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(),Dr.fire(qr.LOGIN_STATE_CHANGED),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:zt.USERNAME,persistence:this._config.persistence}),[2,new Ur({envId:this._config.env,cache:this._cache,request:this._request})];case 9:throw r.code?new Error(JSON.stringify({code:rr.OPERATION_FAIL,msg:"login by username failed:["+r.code+"] "+r.message})):new Error(JSON.stringify({code:rr.OPERATION_FAIL,msg:"login by username failed"}));case 10:return[2]}}))}))},Xn([ir({title:"用户名密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().signInWithUsernameAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录"," 3 - 用户名密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+or]}),Qn("design:type",Function),Qn("design:paramtypes",[String,String]),Qn("design:returntype",Promise)],t.prototype,"signIn",null),t}(en),ar=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)}}(),cr=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},ur=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())}))},lr=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])}}},hr=We.throwError,pr=We.isString,dr=We.transformPhone,yr=Le.ERRORS,gr=Le.COMMUNITY_SITE_URL,vr=Pe.catchErrorsDecorator,mr="SIGNIN",_r="SIGNUP",br="FORCERESETPWD",wr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ar(t,e),t.prototype.signIn=function(e){return fr(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,u;return lr(this,(function(f){switch(f.label){case 0:return t=e.phoneNumber,n=e.phoneCode,r=e.password,o=e.signMethod,pr(t)||hr(yr.INVALID_PARAMS,"phoneNumber must be a string"),pr(n)||pr(r)||hr(yr.INVALID_PARAMS,"phoneCode or password must be a string"),o||(o=mr),i=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:zt.PHONE,phoneNumber:dr(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(),Dr.fire(qr.LOGIN_STATE_CHANGED),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:zt.PHONE,persistence:this._config.persistence}),[2,new Ur({envId:this._config.env,cache:this._cache,request:this._request})];case 8:s.code?hr(yr.OPERATION_FAIL,"Phone login fail["+s.code+"] "+s.message):hr(yr.OPERATION_FAIL,"Phone login fail"),f.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t,n){return fr(this,void 0,void 0,(function(){return lr(this,(function(r){return[2,this.signIn({phoneNumber:e,phoneCode:t,password:n,signMethod:_r})]}))}))},t.prototype.forceResetPwd=function(e,t,n){return fr(this,void 0,void 0,(function(){return lr(this,(function(r){return[2,this.signIn({phoneNumber:e,phoneCode:t,password:n,signMethod:br})]}))}))},cr([vr({title:"手机号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().SmsAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录"," 3 - 短信验证码/密码是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+gr]}),ur("design:type",Function),ur("design:paramtypes",[Object]),ur("design:returntype",Promise)],t.prototype,"signIn",null),cr([vr({title:"手机短信注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithPhoneCode() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+gr]}),ur("design:type",Function),ur("design:paramtypes",[String,String,String]),ur("design:returntype",Promise)],t.prototype,"signUp",null),cr([vr({title:"手机密码重置失败",messages:["请确认以下各项:"," 1 - 调用 auth().forceResetPwd() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+gr]}),ur("design:type",Function),ur("design:paramtypes",[String,String,String]),ur("design:returntype",Promise)],t.prototype,"forceResetPwd",null),t}(en),Er=function(){return Er=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},Er.apply(this,arguments)},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},Ir=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Or=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())}))},Ar=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])}}},Nr=Me.CloudbaseEventEmitter,Tr=Ce.RUNTIME,Rr=We.printWarn,Pr=We.throwError,xr=We.transformPhone,Lr=Le.ERRORS,kr=Le.COMMUNITY_SITE_URL,Cr=Pe.catchErrorsDecorator,Dr=new Nr,jr=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 Or(this,void 0,void 0,(function(){return Ar(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 Or(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 Ar(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 Or(this,void 0,void 0,(function(){var e,t,n,r,o,i;return Ar(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 Or(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return Ar(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&&Pr(Lr.INVALID_PARAMS,"username must be a string"),this._request.send("auth.updateUsername",{username:e})},e.prototype.refresh=function(){return Or(this,void 0,void 0,(function(){var e;return Ar(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 Or(this,void 0,void 0,(function(){return Ar(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:xr(e),phoneCode:t})]}))}))},e.prototype.updatePhoneNumber=function(e,t){return Or(this,void 0,void 0,(function(){return Ar(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:xr(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 Or(this,void 0,void 0,(function(){var t;return Ar(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()},Sr([Cr({title:"绑定自定义登录失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithTicket() 的语法或参数是否正确"," 2 - 此账户是否已经绑定自定义登录"," 3 - ticket 参数是否归属当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String]),Ir("design:returntype",Promise)],e.prototype,"linkWithTicket",null),Sr([Cr({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithRedirect() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方"," 3 - 此第三方是否已经授权","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[Object]),Ir("design:returntype",void 0)],e.prototype,"linkWithRedirect",null),Sr([Cr({title:"获取账户列表失败",messages:["请确认以下各项:"," 1 - 调用 User.getLinkedUidList() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[]),Ir("design:returntype",Promise)],e.prototype,"getLinkedUidList",null),Sr([Cr({title:"设置微信主账号失败",messages:["请确认以下各项:"," 1 - 调用 User.setPrimaryUid() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String]),Ir("design:returntype",void 0)],e.prototype,"setPrimaryUid",null),Sr([Cr({title:"接触绑定失败",messages:["请确认以下各项:"," 1 - 调用 User.unlink() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String]),Ir("design:returntype",void 0)],e.prototype,"unlink",null),Sr([Cr({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[Object]),Ir("design:returntype",Promise)],e.prototype,"update",null),Sr([Cr({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String,String]),Ir("design:returntype",void 0)],e.prototype,"updatePassword",null),Sr([Cr({title:"更新邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 User.updateEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String,String]),Ir("design:returntype",void 0)],e.prototype,"updateEmail",null),Sr([Cr({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String]),Ir("design:returntype",void 0)],e.prototype,"updateUsername",null),Sr([Cr({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[]),Ir("design:returntype",Promise)],e.prototype,"refresh",null),Sr([Cr({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().linkWithPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String,String]),Ir("design:returntype",Promise)],e.prototype,"linkWithPhoneNumber",null),Sr([Cr({title:"更新手机号失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String,String]),Ir("design:returntype",Promise)],e.prototype,"updatePhoneNumber",null),e}(),Ur=function(){function e(e){var t=e.envId,n=e.cache,r=e.request;t||Pr(Lr.INVALID_PARAMS,"envId is not defined"),this._cache=n,this.user=new jr({cache:n,request:r})}return e.prototype.checkLocalState=function(){return Or(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Ar(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 Or(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a;return Ar(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===zt.ANONYMOUS},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCustomAuth",{get:function(){return this.loginType===zt.CUSTOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isWeixinAuth",{get:function(){return this.loginType===zt.WECHAT||this.loginType===zt.WECHAT_OPEN||this.loginType===zt.WECHAT_PUBLIC},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsernameAuth",{get:function(){return this.loginType===zt.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===zt.PHONE},enumerable:!1,configurable:!0}),e}(),Mr=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request,this._runtime=e.runtime||Tr.WEB,Dr.on(qr.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}Rr(Lr.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 Or(this,void 0,void 0,(function(){var e;return Ar(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 Or(this,void 0,void 0,(function(){return Ar(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 Or(this,void 0,void 0,(function(){var e;return Ar(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 gn(Er(Er({},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 Rn(Er(Er({},this._config),{cache:this._cache,request:this._request}))),this._anonymousAuthProvider},e.prototype.customAuthProvider=function(){return this._customAuthProvider||(this._customAuthProvider=new qn(Er(Er({},this._config),{cache:this._cache,request:this._request}))),this._customAuthProvider},e.prototype.emailAuthProvider=function(){return this._emailAuthProvider||(this._emailAuthProvider=new Zn(Er(Er({},this._config),{cache:this._cache,request:this._request}))),this._emailAuthProvider},e.prototype.usernameAuthProvider=function(){return this._usernameAuthProvider||(this._usernameAuthProvider=new sr(Er(Er({},this._config),{cache:this._cache,request:this._request}))),this._usernameAuthProvider},e.prototype.phoneAuthProvider=function(){return this._phoneAuthProvider||(this._phoneAuthProvider=new wr(Er(Er({},this._config),{cache:this._cache,request:this._request}))),this._phoneAuthProvider},e.prototype.signInWithUsernameAndPassword=function(e,t){return Or(this,void 0,void 0,(function(){return Ar(this,(function(n){return[2,this.usernameAuthProvider().signIn(e,t)]}))}))},e.prototype.isUsernameRegistered=function(e){return Or(this,void 0,void 0,(function(){var t;return Ar(this,(function(n){switch(n.label){case 0:return"string"!=typeof e&&Pr(Lr.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 Or(this,void 0,void 0,(function(){return Ar(this,(function(n){return[2,this.emailAuthProvider().signIn(e,t)]}))}))},e.prototype.signUpWithEmailAndPassword=function(e,t){return Or(this,void 0,void 0,(function(){return Ar(this,(function(n){return[2,this.emailAuthProvider().signUp(e,t)]}))}))},e.prototype.sendPasswordResetEmail=function(e){return Or(this,void 0,void 0,(function(){return Ar(this,(function(t){return[2,this.emailAuthProvider().resetPassword(e)]}))}))},e.prototype.signOut=function(){return Or(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Ar(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),Dr.fire(qr.LOGIN_STATE_CHANGED),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:zt.NULL,persistence:this._config.persistence}),[2,s]}}))}))},e.prototype.onLoginStateChanged=function(e){return Or(this,void 0,void 0,(function(){var t,n=this;return Ar(this,(function(r){switch(r.label){case 0:return Dr.on(qr.LOGIN_STATE_CHANGED,(function(){return Or(n,void 0,void 0,(function(){var t;return Ar(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){Dr.on(qr.LOGIN_STATE_EXPIRED,e.bind(this))},e.prototype.onAccessTokenRefreshed=function(e){Dr.on(qr.ACCESS_TOKEN_REFRESHD,e.bind(this))},e.prototype.onAnonymousConverted=function(e){Dr.on(qr.ANONYMOUS_CONVERTED,e.bind(this))},e.prototype.onLoginTypeChanged=function(e){var t=this;Dr.on(qr.LOGIN_TYPE_CHANGED,(function(){return Or(t,void 0,void 0,(function(){var t;return Ar(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 Ur({envId:this._config.env,cache:this._cache,request:this._request});return t.checkLocalState(),t}return null}Rr(Lr.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},e.prototype.getLoginState=function(){return Or(this,void 0,void 0,(function(){var e,t;return Ar(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 Ur({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 Or(this,void 0,void 0,(function(){var e;return Ar(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,Er(Er({},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 Or(this,void 0,void 0,(function(){var e,t,n,r;return Ar(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 Or(this,void 0,void 0,(function(){return Ar(this,(function(t){switch(t.label){case 0:return[4,this._request.send("auth.sendPhoneCode",{phoneNumber:xr(e)})];case 1:return[2,"Ok"===t.sent().data.SendStatus]}}))}))},e.prototype.signUpWithPhoneCode=function(e,t,n){return Or(this,void 0,void 0,(function(){return Ar(this,(function(r){return[2,this.phoneAuthProvider().signUp(e,t,n)]}))}))},e.prototype.signInWithPhoneCodeOrPassword=function(e){return Or(this,void 0,void 0,(function(){return Ar(this,(function(t){return[2,this.phoneAuthProvider().signIn(e)]}))}))},e.prototype.forceResetPwdByPhoneCode=function(e){return Or(this,void 0,void 0,(function(){return Ar(this,(function(t){return[2,this.phoneAuthProvider().signIn(Er(Er({},e),{signMethod:br}))]}))}))},e.prototype._onLoginTypeChanged=function(e){return Or(this,void 0,void 0,(function(){var t,n,r;return Ar(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]}}))}))},Sr([Cr({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[]),Ir("design:returntype",Promise)],e.prototype,"getCurrenUser",null),Sr([Cr({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String]),Ir("design:returntype",Promise)],e.prototype,"isUsernameRegistered",null),Sr([Cr({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[]),Ir("design:returntype",Promise)],e.prototype,"signOut",null),Sr([Cr({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[]),Ir("design:returntype",Promise)],e.prototype,"getLoginState",null),Sr([Cr({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[]),Ir("design:returntype",Promise)],e.prototype,"getUserInfo",null),Sr([Cr({title:"发送短信验证码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String]),Ir("design:returntype",Promise)],e.prototype,"sendPhoneCode",null),e}(),qr={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRED:"loginStateExpire",LOGIN_TYPE_CHANGED:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",ACCESS_TOKEN_REFRESHD:"refreshAccessToken"},Wr={name:"auth",namespace:"auth",injectEvents:{bus:Dr,events:[qr.LOGIN_TYPE_CHANGED,qr.LOGIN_STATE_EXPIRED,qr.LOGIN_STATE_CHANGED,qr.ACCESS_TOKEN_REFRESHD,qr.ANONYMOUS_CONVERTED]},entity:function(e){if(void 0===e&&(e={region:"",persistence:"local"}),this.authInstance)return Rr(Lr.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 Mr({env:s,region:e.region,persistence:a,debug:c,cache:this.cache,request:this.request,runtime:r}),this.authInstance}};try{cloudbase.registerComponent(Wr)}catch(e){}var Fr=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},Br=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},$r=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())}))},Hr=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])}}},Gr=Le.getSdkName,Kr=Le.ERRORS,Vr=Le.COMMUNITY_SITE_URL,Jr=We.execCallback,Yr=Pe.catchErrorsDecorator,Zr="functions",zr=function(){function e(){}return e.prototype.callFunction=function(e,t){return $r(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u,f,l,h,p;return Hr(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:Kr.INVALID_PARAMS,msg:"["+Zr+".callFunction] invalid function name"}));try{a=r?JSON.stringify(r):""}catch(e){throw new Error(JSON.stringify({code:Kr.INVALID_PARAMS,msg:"["+Zr+".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,Jr(t,null,l)];if(h=l.data.response_data,i)return[2,Jr(t,null,{result:h,requestId:l.requestId})];try{return h=JSON.parse(l.data.response_data),[2,Jr(t,null,{result:h,requestId:l.requestId})]}catch(e){Jr(t,new Error("["+Gr()+"]["+Kr.INVALID_PARAMS+"]["+Zr+".callFunction] response data must be json"))}return[3,4];case 3:return p=d.sent(),Jr(t,p),[3,4];case 4:return[2]}}))}))},Fr([Yr({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Vr]}),Br("design:type",Function),Br("design:paramtypes",[Object,Function]),Br("design:returntype",Promise)],e.prototype,"callFunction",null),e}(),Xr=new zr,Qr={name:Zr,entity:{callFunction:Xr.callFunction}};try{cloudbase.registerComponent(Qr)}catch(e){}var eo=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},to=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},no=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())}))},ro=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])}}},oo=Le.getSdkName,io=Le.ERRORS,so=Le.COMMUNITY_SITE_URL,ao=We.isArray,co=We.isString,uo=We.isPalinObject,fo=We.execCallback,lo=Pe.catchErrorsDecorator,ho="storage",po=function(){function e(){}return e.prototype.uploadFile=function(e,t){return no(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u,f,l,h,p,d,y,g;return ro(this,(function(v){switch(v.label){case 0:if(n=e.cloudPath,r=e.filePath,o=e.onUploadProgress,!co(n)||!r)throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".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,fo(t,null,{fileID:l,download_url:p,requestId:d})]:[2,fo(t,new Error("["+oo()+"]["+io.OPERATION_FAIL+"]["+ho+"]:"+g.data))]}}))}))},e.prototype.getUploadMetadata=function(e,t){return no(this,void 0,void 0,(function(){var n,r,o,i,s;return ro(this,(function(a){switch(a.label){case 0:if(n=e.cloudPath,!co(n))throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".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,fo(t,null,i)];case 3:return s=a.sent(),[2,fo(t,s)];case 4:return[2]}}))}))},e.prototype.deleteFile=function(e,t){return no(this,void 0,void 0,(function(){var n,r,o,i,s,a;return ro(this,(function(c){switch(c.label){case 0:if(!(n=e.fileList)||!ao(n)||0===n.length)throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".deleteFile] fileList must not be empty"}));for(r=0,o=n;r<o.length;r++)if(!(i=o[r])||!co(i))throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".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,fo(t,null,s)]:(a={fileList:s.data.delete_list,requestId:s.requestId},[2,fo(t,null,a)])}}))}))},e.prototype.getTempFileURL=function(e,t){return no(this,void 0,void 0,(function(){var n,r,o,i,s,a;return ro(this,(function(c){switch(c.label){case 0:if(!(n=e.fileList)||!ao(n)||0===n.length)throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".getTempFileURL] fileList must not be empty"}));for(r=[],o=0,i=n;o<i.length;o++)if(s=i[o],uo(s)){if(!s.hasOwnProperty("fileID")||!s.hasOwnProperty("maxAge"))throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".getTempFileURL] file info must include fileID and maxAge"}));r.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!co(s))throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".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,fo(t,null,a)]:[2,fo(t,null,{fileList:a.data.download_list,requestId:a.requestId})]}}))}))},e.prototype.downloadFile=function(e,t){return no(this,void 0,void 0,(function(){var n,r,o,i,s,a;return ro(this,(function(c){switch(c.label){case 0:if(n=e.fileID,!co(n))throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".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,fo(t,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return a=c.sent(),[2,fo(t,null,a)]}}))}))},eo([lo({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+so]}),to("design:type",Function),to("design:paramtypes",[Object,Function]),to("design:returntype",Promise)],e.prototype,"uploadFile",null),eo([lo({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+so]}),to("design:type",Function),to("design:paramtypes",[Object,Function]),to("design:returntype",Promise)],e.prototype,"getUploadMetadata",null),eo([lo({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+so]}),to("design:type",Function),to("design:paramtypes",[Object,Function]),to("design:returntype",Promise)],e.prototype,"deleteFile",null),eo([lo({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+so]}),to("design:type",Function),to("design:paramtypes",[Object,Function]),to("design:returntype",Promise)],e.prototype,"getTempFileURL",null),eo([lo({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+so]}),to("design:type",Function),to("design:paramtypes",[Object,Function]),to("design:returntype",Promise)],e.prototype,"downloadFile",null),e}(),yo=new po,go={name:ho,entity:{uploadFile:yo.uploadFile,deleteFile:yo.deleteFile,getTempFileURL:yo.getTempFileURL,downloadFile:yo.downloadFile,getUploadMetadata:yo.getUploadMetadata}};try{cloudbase.registerComponent(go)}catch(e){}var vo="__lodash_hash_undefined__",mo=1/0,_o=9007199254740991,bo="[object Function]",wo="[object GeneratorFunction]",Eo="[object Symbol]",So=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Io=/^\w*$/,Oo=/^\./,Ao=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,No=/\\(\\)?/g,To=/^\[object .+?Constructor\]$/,Ro=/^(?:0|[1-9]\d*)$/,Po="object"==typeof s&&s&&s.Object===Object&&s,xo="object"==typeof self&&self&&self.Object===Object&&self,Lo=Po||xo||Function("return this")();var ko,Co=Array.prototype,Do=Function.prototype,jo=Object.prototype,Uo=Lo["__core-js_shared__"],Mo=(ko=/[^.]+$/.exec(Uo&&Uo.keys&&Uo.keys.IE_PROTO||""))?"Symbol(src)_1."+ko:"",qo=Do.toString,Wo=jo.hasOwnProperty,Fo=jo.toString,Bo=RegExp("^"+qo.call(Wo).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),$o=Lo.Symbol,Ho=Co.splice,Go=ri(Lo,"Map"),Ko=ri(Object,"create"),Vo=$o?$o.prototype:void 0,Jo=Vo?Vo.toString:void 0;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){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){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Xo(e,t,n){var r=e[t];Wo.call(e,t)&&ci(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function Qo(e,t){for(var n=e.length;n--;)if(ci(e[n][0],t))return n;return-1}function ei(e){if(!fi(e)||(t=e,Mo&&Mo in t))return!1;var t,n=function(e){var t=fi(e)?Fo.call(e):"";return t==bo||t==wo}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Bo:To;return n.test(function(e){if(null!=e){try{return qo.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function ti(e,t,n,r){if(!fi(e))return e;t=function(e,t){if(ui(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||li(e))return!0;return Io.test(e)||!So.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:function(e){return ui(e)?e:ii(e)}(t);for(var o=-1,i=t.length,s=i-1,a=e;null!=a&&++o<i;){var c=si(t[o]),u=n;if(o!=s){var f=a[c];void 0===(u=r?r(f,c,a):void 0)&&(u=fi(f)?f:oi(t[o+1])?[]:{})}Xo(a,c,u),a=a[c]}return e}function ni(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 ri(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return ei(n)?n:void 0}function oi(e,t){return!!(t=null==t?_o:t)&&("number"==typeof e||Ro.test(e))&&e>-1&&e%1==0&&e<t}Yo.prototype.clear=function(){this.__data__=Ko?Ko(null):{}},Yo.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Yo.prototype.get=function(e){var t=this.__data__;if(Ko){var n=t[e];return n===vo?void 0:n}return Wo.call(t,e)?t[e]:void 0},Yo.prototype.has=function(e){var t=this.__data__;return Ko?void 0!==t[e]:Wo.call(t,e)},Yo.prototype.set=function(e,t){return this.__data__[e]=Ko&&void 0===t?vo:t,this},Zo.prototype.clear=function(){this.__data__=[]},Zo.prototype.delete=function(e){var t=this.__data__,n=Qo(t,e);return!(n<0)&&(n==t.length-1?t.pop():Ho.call(t,n,1),!0)},Zo.prototype.get=function(e){var t=this.__data__,n=Qo(t,e);return n<0?void 0:t[n][1]},Zo.prototype.has=function(e){return Qo(this.__data__,e)>-1},Zo.prototype.set=function(e,t){var n=this.__data__,r=Qo(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},zo.prototype.clear=function(){this.__data__={hash:new Yo,map:new(Go||Zo),string:new Yo}},zo.prototype.delete=function(e){return ni(this,e).delete(e)},zo.prototype.get=function(e){return ni(this,e).get(e)},zo.prototype.has=function(e){return ni(this,e).has(e)},zo.prototype.set=function(e,t){return ni(this,e).set(e,t),this};var ii=ai((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(li(e))return Jo?Jo.call(e):"";var t=e+"";return"0"==t&&1/e==-mo?"-0":t}(t);var n=[];return Oo.test(e)&&n.push(""),e.replace(Ao,(function(e,t,r,o){n.push(r?o.replace(No,"$1"):t||e)})),n}));function si(e){if("string"==typeof e||li(e))return e;var t=e+"";return"0"==t&&1/e==-mo?"-0":t}function ai(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(ai.Cache||zo),n}function ci(e,t){return e===t||e!=e&&t!=t}ai.Cache=zo;var ui=Array.isArray;function fi(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function li(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&Fo.call(e)==Eo}var hi=a((function(e,t,n){return null==e?e:ti(e,t,n)})),pi="__lodash_hash_undefined__",di=1/0,yi="[object Function]",gi="[object GeneratorFunction]",vi="[object Symbol]",mi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_i=/^\w*$/,bi=/^\./,wi=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ei=/\\(\\)?/g,Si=/^\[object .+?Constructor\]$/,Ii="object"==typeof s&&s&&s.Object===Object&&s,Oi="object"==typeof self&&self&&self.Object===Object&&self,Ai=Ii||Oi||Function("return this")();var Ni=Array.prototype,Ti=Function.prototype,Ri=Object.prototype,Pi=Ai["__core-js_shared__"],xi=function(){var e=/[^.]+$/.exec(Pi&&Pi.keys&&Pi.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Li=Ti.toString,ki=Ri.hasOwnProperty,Ci=Ri.toString,Di=RegExp("^"+Li.call(ki).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ji=Ai.Symbol,Ui=Ni.splice,Mi=Zi(Ai,"Map"),qi=Zi(Object,"create"),Wi=ji?ji.prototype:void 0,Fi=Wi?Wi.toString:void 0;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){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Hi(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 Gi(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 Ki(e){if(!ns(e)||(t=e,xi&&xi in t))return!1;var t,n=function(e){var t=ns(e)?Ci.call(e):"";return t==yi||t==gi}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Di:Si;return n.test(function(e){if(null!=e){try{return Li.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function Vi(e,t){e=function(e,t){return 1==t.length?e:function(e,t){for(var n=0,r=(t=zi(t,e)?[t]:Ji(t)).length;null!=e&&n<r;)e=e[Qi(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=zi(t,e)?[t]:Ji(t));var n,r,o=Qi((r=(n=t)?n.length:0)?n[r-1]:void 0);return!(null!=e&&ki.call(e,o))||delete e[o]}function Ji(e){return ts(e)?e:Xi(e)}function Yi(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 Zi(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Ki(n)?n:void 0}function zi(e,t){if(ts(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!rs(e))||(_i.test(e)||!mi.test(e)||null!=t&&e in Object(t))}Bi.prototype.clear=function(){this.__data__=qi?qi(null):{}},Bi.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Bi.prototype.get=function(e){var t=this.__data__;if(qi){var n=t[e];return n===pi?void 0:n}return ki.call(t,e)?t[e]:void 0},Bi.prototype.has=function(e){var t=this.__data__;return qi?void 0!==t[e]:ki.call(t,e)},Bi.prototype.set=function(e,t){return this.__data__[e]=qi&&void 0===t?pi:t,this},$i.prototype.clear=function(){this.__data__=[]},$i.prototype.delete=function(e){var t=this.__data__,n=Gi(t,e);return!(n<0)&&(n==t.length-1?t.pop():Ui.call(t,n,1),!0)},$i.prototype.get=function(e){var t=this.__data__,n=Gi(t,e);return n<0?void 0:t[n][1]},$i.prototype.has=function(e){return Gi(this.__data__,e)>-1},$i.prototype.set=function(e,t){var n=this.__data__,r=Gi(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Hi.prototype.clear=function(){this.__data__={hash:new Bi,map:new(Mi||$i),string:new Bi}},Hi.prototype.delete=function(e){return Yi(this,e).delete(e)},Hi.prototype.get=function(e){return Yi(this,e).get(e)},Hi.prototype.has=function(e){return Yi(this,e).has(e)},Hi.prototype.set=function(e,t){return Yi(this,e).set(e,t),this};var Xi=es((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(rs(e))return Fi?Fi.call(e):"";var t=e+"";return"0"==t&&1/e==-di?"-0":t}(t);var n=[];return bi.test(e)&&n.push(""),e.replace(wi,(function(e,t,r,o){n.push(r?o.replace(Ei,"$1"):t||e)})),n}));function Qi(e){if("string"==typeof e||rs(e))return e;var t=e+"";return"0"==t&&1/e==-di?"-0":t}function es(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(es.Cache||Hi),n}es.Cache=Hi;var ts=Array.isArray;function ns(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function rs(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&Ci.call(e)==vi}var os=a((function(e,t){return null==e||Vi(e,t)})),is={exports:{}};!function(e,t){var n="__lodash_hash_undefined__",r=9007199254740991,o="[object Arguments]",i="[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*)$/,k={};k[o]=k["[object Array]"]=k[_]=k[b]=k[i]=k[a]=k[w]=k[E]=k[S]=k[I]=k[O]=k[f]=k[l]=k[h]=k[d]=k[y]=k[g]=k[v]=k[A]=k[N]=k[T]=k[R]=!0,k["[object Error]"]=k[c]=k[m]=!1;var C="object"==typeof s&&s&&s.Object===Object&&s,D="object"==typeof self&&self&&self.Object===Object&&self,j=C||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__"],z=function(){var e=/[^.]+$/.exec(Z&&Z.keys&&Z.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),X=J.toString,Q=Y.hasOwnProperty,ee=Y.toString,te=RegExp("^"+X.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)==o)}(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,i=!!r;for(var s in e)!t&&!Q.call(e,s)||i&&("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,s,p,m){var x;if(r&&(x=p?r(e,s,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 C=qe(e),D=C==c||C==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(C==h||C==o||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(!k[C])return p?e:{};x=function(e,t,n,r){var o=e.constructor;switch(t){case _:return Ce(e);case i:case a:return new o(+e);case b:return function(e,t){var n=t?Ce(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?Ce(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 s=e,Ie?Object(Ie.call(s)):{}}var s}(e,C,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 ke(e){return!(!Je(e)||(t=e,z&&z in t))&&(Ve(e)||$(e)?te:x).test(Be(e));var t}function Ce(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 ke(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?r: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 X.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<=r}(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)}}(is,is.exports);var ss=a(is.exports);function as(e){return void 0===e&&(e=""),(e?e+"_":"")+ +new Date+"_"+Math.random()}var cs,us=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}})},fs=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}})},ls=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)}}(),hs=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 ls(t,e),t}(Error),ps=function(e){return null==e?void 0:e.isRealtimeErrorMessageError},ds=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 ls(t,e),t}(Error),ys=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 ls(t,e),t}(Error),gs=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+" "+(vs[this.errCode]||"")+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e}}}),n.errCode=t.errCode||"UNKNOWN_ERROR",n.errMsg=t.errMsg,n}return ls(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),vs={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"},ms=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},_s=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())}))},bs=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])}}},ws=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"}(cs||(cs={}));var Es=function(){function e(e){var t=this;this.watchStatus=cs.INITING,this._login=function(e,n){return _s(t,void 0,void 0,(function(){var t;return bs(this,(function(r){switch(r.label){case 0:return this.watchStatus=cs.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 _s(t,void 0,void 0,(function(){var t,n=this;return bs(this,(function(r){switch(r.label){case 0:if(this._initWatchPromise)return[2,this._initWatchPromise];this._initWatchPromise=new Promise((function(t,r){return _s(n,void 0,void 0,(function(){var n,o,i,s,a,c,u,f,l,h;return bs(this,(function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),this.watchStatus===cs.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===cs.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(this.watchStatus=cs.INITING,o={watchId:this.watchId,requestId:as(),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 fs({id:c,docChanges:[],docs:[],type:"init"}),this.listener.onChange(l),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=cs.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 _s(t,void 0,void 0,(function(){var t,n=this;return bs(this,(function(r){switch(r.label){case 0:if(this._rebuildWatchPromise)return[2,this._rebuildWatchPromise];this._rebuildWatchPromise=new Promise((function(t,r){return _s(n,void 0,void 0,(function(){var n,o,i,s;return bs(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===cs.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===cs.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):(this.watchStatus=cs.REBUILDING,o={watchId:this.watchId,requestId:as(),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=cs.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 _s(t,void 0,void 0,(function(){var t,r,o,i=this;return bs(this,(function(s){return t="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new gs({errCode:t?vs.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:vs.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 _s(i,void 0,void 0,(function(){var e,t=this;return bs(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),e=function(){return _s(t,void 0,void 0,(function(){return bs(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,ms(100)];case 3:return r.sent(),this.watchStatus!==cs.PAUSED?[3,4]:(n.reject(new ys(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 _s(t,void 0,void 0,(function(){var e,t,n;return bs(this,(function(r){switch(r.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==cs.ACTIVE)return this.watchStatus=cs.CLOSED,this.onWatchClose(this,e),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=cs.CLOSING,t={watchId:this.watchId,requestId:as(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=cs.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new gs({errCode:vs.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 _s(t,void 0,void 0,(function(){var e,t,n;return bs(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==cs.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(e={watchId:this.watchId,requestId:as(),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(),ps(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 gs({errCode:vs.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 gs({errCode:vs.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if(ps(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 us({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 cs.PAUSED:if("ERROR"!==e.msgType)return;break;case cs.LOGGINGIN:case cs.INITING:case cs.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while "+this.watchStatus);case cs.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case cs.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 gs({errCode:vs.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=cs.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=cs.PAUSED,console.log("[realtime] client paused ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.resume=function(){return _s(this,void 0,void 0,(function(){var e;return bs(this,(function(t){switch(t.label){case 0:this.watchStatus=cs.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 _s(this,void 0,void 0,(function(){var t;return bs(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 _s(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,u,f,l,h;return bs(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(Ss)}catch(e){return this.closeWithError(new gs({errCode:vs.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}s=ws(o.currentDocs),a=!1,c=function(n,c){var f,l,h,p,d,y,g,v,m,_,b;return bs(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=ss(l),f.updatedFields)for(d in f.updatedFields)hi(y,d,f.updatedFields[d]);if(f.removedFields)for(h=0,p=f.removedFields;h<p.length;h++)d=p[h],os(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 gs({errCode:vs.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 gs({errCode:vs.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 gs({errCode:vs.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=ws(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 fs({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 Ss(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 Is,Os={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"}(Is||(Is={}));var As=function(e,t){var n=Os[e],r=n?n.name+", code "+e+", reason "+(t||n.description):"code "+e;return new gs({errCode:vs.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},Ns=null,Ts="web";function Rs(){return Ns}function Ps(){return Ts}function xs(e){Ts=e}var Ls=function(){return Ls=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},Ls.apply(this,arguments)},ks=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())}))},Cs=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])}}},Ds=1,js=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 ks(t,void 0,void 0,(function(){var t=this;return Cs(this,(function(n){return[2,new Promise((function(n,r){return ks(t,void 0,void 0,(function(){var t,o,i,s,a,c,u,f=this;return Cs(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 ks(f,void 0,void 0,(function(){return Cs(this,(function(e){switch(e.label){case 0:return o&&i?[3,2]:[4,ms(0)];case 1:e.sent(),o&&i||a(new ds("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!==Ds)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),ks(t,void 0,void 0,(function(){var t=this;return Cs(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(Is.ReconnectWebSocket),this._wsInitPromise=new Promise((function(r,o){return ks(t,void 0,void 0,(function(){var t,i,s=this;return Cs(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=Rs();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,ms(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 gs({errCode:vs.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 gs({errCode:vs.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 Is.ReconnectWebSocket:case Is.NoRealtimeListeners:break;case Is.HeartbeatPingError:case Is.HeartbeatPongTimeoutError:case Is.NormalClosure:case Is.AbnormalClosure:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(As(e.code));break;case Is.NoAuthentication:t.closeAllClients(As(e.code,e.reason));break;default:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(As(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 hs(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===Ds)},this.onceWSConnected=function(){return ks(t,void 0,void 0,(function(){var e=this;return Cs(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 ks(t,void 0,void 0,(function(){var t,r,o,i,s,a,c,u,f=this;return Cs(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 ks(f,void 0,void 0,(function(){var n,r,o,i,s;return Cs(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:as(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:Ps(),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 ks(t,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Cs(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:Ps()})]);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 ks(t,void 0,void 0,(function(){var e;return Cs(this,(function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:as(),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(Is.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,Os[e].name),this._ws=void 0)},e.prototype.watch=function(e){this._ws||this._wsInitPromise||this.initWebSocketConnection(!1);var t=new Es(Ls(Ls({},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 ks(t,void 0,void 0,(function(){var e=this;return Cs(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this._ws&&this._ws.readyState===Ds?(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(Is.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),e?0:this._context.appConfig.realtimePingInterval)},e}(),Us={target:"database",entity:function(){var e,t=this.platform,n=t.adapter,r=t.runtime;e=n.wsClass,Ns=e,xs(r)}},Ms={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=js}};try{cloudbase.registerComponent(Ms),cloudbase.registerHook(Us)}catch(e){}var qs=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},Ws=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Fs=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())}))},Bs=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=Le.ERRORS,Hs=Le.COMMUNITY_SITE_URL,Gs=Pe.catchErrorsDecorator,Ks="analytics",Vs=["mall"];var Js,Ys,Zs=new(function(){function e(){}return e.prototype.analytics=function(e){return Fs(this,void 0,void 0,(function(){var t,n,r;return Bs(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!==Vs.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:$s.INVALID_PARAMS,msg:"["+Ks+".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]}))}))},qs([Gs({customInfo:{className:"Cloudbase",methodName:"analytics"},title:"上报调用失败",messages:["请确认以下各项:"," 1 - 调用 analytics() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Hs]}),Ws("design:type",Function),Ws("design:paramtypes",[Object]),Ws("design:returntype",Promise)],e.prototype,"analytics",null),e}()),zs={name:Ks,entity:{analytics:Zs.analytics}};try{cloudbase.registerComponent(zs)}catch(e){}!function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined"}(Ys||(Ys={}));var Xs,Qs,ea="Number",ta="Object",na="Array",ra="GeoPoint",oa="GeoLineString",ia="GeoPolygon",sa="GeoMultiPoint",aa="GeoMultiLineString",ca="GeoMultiPolygon",ua="Date",fa="ServerDate",la="BsonDate",ha=["desc","asc"],pa=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(Xs||(Xs={})),(Js={})[Xs.eq]="$eq",Js[Xs.lt]="$lt",Js[Xs.lte]="$lte",Js[Xs.gt]="$gt",Js[Xs.gte]="$gte",function(e){e.WHERE="WHERE",e.DOC="DOC"}(Qs||(Qs={}));var da=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)}}(),ya=[],ga={},va=function(e){function t(t,n){if(n!==ga)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return da(t,e),t.for=function(e){for(var n=0,r=ya.length;n<r;n++)if(ya[n].target===e)return ya[n].instance;var o=new t(e,ga);return ya.push({target:e,instance:o}),o},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),ma=va,_a=ma.for("UNSET_FIELD_NAME"),ba=ma.for("UPDATE_COMMAND"),wa=ma.for("QUERY_COMMAND"),Ea=ma.for("LOGIC_COMMAND"),Sa=ma.for("GEO_POINT"),Ia=ma.for("SYMBOL_GEO_LINE_STRING"),Oa=ma.for("SYMBOL_GEO_POLYGON"),Aa=ma.for("SYMBOL_GEO_MULTI_POINT"),Na=ma.for("SYMBOL_GEO_MULTI_LINE_STRING"),Ta=ma.for("SYMBOL_GEO_MULTI_POLYGON"),Ra=ma.for("SERVER_DATE"),Pa=ma.for("REGEXP"),xa=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 Ra},enumerable:!0,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function La(e){return new xa(e)}var ka,Ca=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},Da=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 ra:o=new Ha(i.coordinates[0],i.coordinates[1]);break;case oa:o=new Ka(i.coordinates.map((function(e){return new Ha(e[0],e[1])})));break;case ia:o=new Ja(i.coordinates.map((function(e){return new Ka(e.map((function(e){var t=Ca(e,2),n=t[0],r=t[1];return new Ha(n,r)})))})));break;case sa:o=new Za(i.coordinates.map((function(e){return new Ha(e[0],e[1])})));break;case aa:o=new Xa(i.coordinates.map((function(e){return new Ka(e.map((function(e){var t=Ca(e,2),n=t[0],r=t[1];return new Ha(n,r)})))})));break;case ca:o=new ec(i.coordinates.map((function(e){return new Ja(e.map((function(e){return new Ka(e.map((function(e){var t=Ca(e,2),n=t[0],r=t[1];return new Ha(n,r)})))})))})));break;case ua:o=new Date(1e3*i.$timestamp);break;case ta:case na:o=e.formatField(i);break;case fa: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===ua)return la;if(t===ta){if(e instanceof Ha)return ra;if(e instanceof Date)return ua;if(e instanceof xa)return fa;e.$timestamp?t=ua:e.$date?t=fa:Ha.validate(e)?t=ra:Ka.validate(e)?t=oa:Ja.validate(e)?t=ia:Za.validate(e)?t=sa:Xa.validate(e)?t=aa:ec.validate(e)&&(t=ca)}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}(),ja=function(){function e(){}return e.isGeopoint=function(e,t){if(Da.whichType(t)!==ea)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+Ys.IntergerError);return!0},e.isFieldOrder=function(e){if(-1===ha.indexOf(e))throw new Error(Ys.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===pa.indexOf(e))throw new Error(Ys.OpStrError);return!0},e.isCollName=function(e){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e))throw new Error(Ys.CollNameError);return!0},e.isDocID=function(e){if(!/^([a-fA-F0-9]){24}$/.test(e))throw new Error(Ys.DocIDError);return!0},e}(),Ua=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},Ma=function(e){return"object"===Ua(e)},qa=function(e){return"number"===Ua(e)},Wa=function(e){return Array.isArray(e)},Fa=function(e){return"date"===Ua(e)},Ba=function(e){return"regexp"===Ua(e)},$a=function(e){return e&&e._internalType instanceof va},Ha=function(){function e(e,t){ja.isGeopoint("longitude",e),ja.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&&Wa(e.coordinates)&&ja.isGeopoint("longitude",e.coordinates[0])&&ja.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Sa},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(!Wa(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 Ha))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||!Wa(e.coordinates))return!1;try{for(var r=Ga(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!qa(i[0])||!qa(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 Ia},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(!Wa(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 Ka))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]");if(!Ka.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||!Wa(e.coordinates))return!1;try{for(var i=Va(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,Va(a)),u=c.next();!u.done;u=c.next()){var f=u.value;if(!qa(f[0])||!qa(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 Ta},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(!Wa(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 Ha))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||!Wa(e.coordinates))return!1;try{for(var r=Ya(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!qa(i[0])||!qa(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 Aa},enumerable:!0,configurable:!0}),e}(),za=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.")},Xa=function(){function e(e){if(!Wa(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 Ka))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||!Wa(e.coordinates))return!1;try{for(var i=za(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var c=(r=void 0,za(a)),u=c.next();!u.done;u=c.next()){var f=u.value;if(!qa(f[0])||!qa(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 Na},enumerable:!0,configurable:!0}),e}(),Qa=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.")},ec=function(){function e(e){var t,n;if(!Wa(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=Qa(e),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof Ja))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||!Wa(e.coordinates))return!1;try{for(var a=Qa(e.coordinates),c=a.next();!c.done;c=a.next()){var u=c.value;try{for(var f=(r=void 0,Qa(u)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,Qa(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!qa(y[0])||!qa(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 Oa},enumerable:!0,configurable:!0}),e}(),tc=Object.freeze({__proto__:null,LineString:Ka,MultiLineString:Xa,MultiPoint:Za,MultiPolygon:ec,Point:Ha,Polygon:Ja}),nc=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"}(ka||(ka={}));var rc,oc=function(){function e(e,t,n){this._internalType=ba,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||_a}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function ic(e){return e&&e instanceof oc&&e._internalType===ba}!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(rc||(rc={}));var sc=function(){function e(e,t,n){if(this._internalType=Ea,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||_a,this.fieldName!==_a)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var r=0,o=t.length;r<o;r++){(ac(i=t[r])||lc(i))&&(t[r]=i._setFieldName(this.fieldName))}}else{var i;(ac(i=t)||lc(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(rc.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(rc.OR,t,this.fieldName)},e}();function ac(e){return e&&e instanceof sc&&e._internalType===Ea}var cc,uc=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"}(cc||(cc={}));var fc=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.operator=t,o._internalType=wa,o}return uc(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case cc.IN:case cc.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(cc.EQ,[e],this.fieldName);return this.and(n)},t.prototype.neq=function(e){var n=new t(cc.NEQ,[e],this.fieldName);return this.and(n)},t.prototype.gt=function(e){var n=new t(cc.GT,[e],this.fieldName);return this.and(n)},t.prototype.gte=function(e){var n=new t(cc.GTE,[e],this.fieldName);return this.and(n)},t.prototype.lt=function(e){var n=new t(cc.LT,[e],this.fieldName);return this.and(n)},t.prototype.lte=function(e){var n=new t(cc.LTE,[e],this.fieldName);return this.and(n)},t.prototype.in=function(e){var n=new t(cc.IN,e,this.fieldName);return this.and(n)},t.prototype.nin=function(e){var n=new t(cc.NIN,e,this.fieldName);return this.and(n)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof Ha))throw new TypeError('"geometry" must be of type Point. Received type '+typeof e.geometry);if(void 0!==e.maxDistance&&!qa(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof e.maxDistance);if(void 0!==e.minDistance&&!qa(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof e.minDistance);var n=new t(cc.GEO_NEAR,[e],this.fieldName);return this.and(n)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof ec||e.geometry instanceof Ja))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof e.geometry);var n=new t(cc.GEO_WITHIN,[e],this.fieldName);return this.and(n)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof Ha||e.geometry instanceof Ka||e.geometry instanceof Ja||e.geometry instanceof Za||e.geometry instanceof Xa||e.geometry instanceof ec))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof e.geometry);var n=new t(cc.GEO_INTERSECTS,[e],this.fieldName);return this.and(n)},t}(sc);function lc(e){return e&&e instanceof fc&&e._internalType===wa}function hc(e){return lc(e)}var pc={};for(var dc in cc)pc[dc]="$"+dc;for(var dc in rc)pc[dc]="$"+dc;for(var dc in ka)pc[dc]="$"+dc;function yc(e){return pc[e]||"$"+e}pc[cc.NEQ]="$ne",pc[ka.REMOVE]="$unset",pc[ka.SHIFT]="$pop",pc[ka.UNSHIFT]="$push";var gc=function(){return gc=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},gc.apply(this,arguments)},vc=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},mc=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(vc(arguments[t]));return e};function _c(e){return bc(e,[e])}function bc(e,t){if(!$a(e)){if(Fa(e))return{$date:+e};if(Ba(e))return{$regex:e.source,$options:e.flags};if(Wa(e))return e.map((function(e){if(t.indexOf(e)>-1)throw new Error("Cannot convert circular structure to JSON");return bc(e,mc(t,[e]))}));if(Ma(e)){var n=gc({},e);for(var r in n){if(t.indexOf(n[r])>-1)throw new Error("Cannot convert circular structure to JSON");n[r]=bc(n[r],mc(t,[n[r]]))}return n}return e}switch(e._internalType){case Sa:return e.toJSON();case Ra:case Pa:return e.parse();default:return e.toJSON?e.toJSON():e}}var wc=function(){return wc=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},wc.apply(this,arguments)},Ec=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},Sc=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ec(arguments[t]));return e};function Ic(e,t,n,r){var o=wc({},e);for(var i in e)if(!/^\$/.test(i)){var s=e[i];if(s&&Ma(s)&&!t(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Ic(s,t,Sc(n,[i]),Sc(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 Oc(e){return Ic(e,Nc,[],[e])}function Ac(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Wa(e[r])?e[r].push(t[r]):Ma(e[r])?Ma(t[r])?Object.assign(e[r],t[r]):(console.warn("unmergable condition, query is object but condition is "+Ua(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+Ua(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]}function Nc(e){return $a(e)||Fa(e)||Ba(e)}function Tc(e){return _c(e)}var Rc=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.prototype.encodeUpdate=function(e){return ic(e)?this.encodeUpdateCommand(e):"object"===Ua(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===_a)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case ka.PUSH:case ka.PULL:case ka.PULL_ALL:case ka.POP:case ka.SHIFT:case ka.UNSHIFT:case ka.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,n,r,o,i=yc(e.operator);return e.operator===ka.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=yc(e.operator);switch(e.operator){case ka.PUSH:var h=void 0;return h=Wa(e.operands)?{$each:e.operands.map(Tc)}:e.operands,(t={})[l]=((n={})[e.fieldName]=h,n),t;case ka.UNSHIFT:h={$each:e.operands.map(Tc),$position:0};return(r={})[l]=((o={})[e.fieldName]=h,o),r;case ka.POP:return(i={})[l]=((s={})[e.fieldName]=1,s),i;case ka.SHIFT:return(a={})[l]=((c={})[e.fieldName]=-1,c),a;default:return(u={})[l]=((f={})[e.fieldName]=Tc(e.operands),f),u}},e.prototype.encodeUpdateObject=function(e){var t=Oc(e);for(var n in t)if(!/^\$/.test(n)){var r=t[n];if(ic(r)){t[n]=r._setFieldName(n),Ac(t,this.encodeUpdateCommand(t[n]),n)}else{t[n]=r=Tc(r);var o=new oc(ka.SET,[r],n);Ac(t,this.encodeUpdateCommand(o),n)}}return t},e}(),Pc={};function xc(e){if(!Ef.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return Pc[t]||(Pc[t]=new Ef.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new Ef.reqClass(e.config)}}})),Pc[t]}var Lc=function(){return Lc=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},Lc.apply(this,arguments)},kc=function(){function e(e,t,n,r){var o=this;void 0===r&&(r={}),this.watch=function(e){return xc(o._db).watch(Lc(Lc({},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 Ef.reqClass(this._db.config),this.projection=r}return e.prototype.create=function(e,t){t=t||nc();var n={collectionName:this._coll,data:_c(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||nc(),!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 oc?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:Qs.DOC,data:_c(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||nc(),!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:Rc.encode(e),query:n,queryType:Qs.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||nc();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:Qs.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||nc();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:Qs.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=Da.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}(),Cc=function(){function e(){}return e.encode=function(e){return(new Dc).encodeQuery(e)},e}(),Dc=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var n;return Nc(e)?ac(e)?this.encodeLogicCommand(e):lc(e)?this.encodeQueryCommand(e):((n={})[t]=this.encodeQueryObject(e),n):Ma(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 rc.NOR:case rc.AND:case rc.OR:var u=yc(e.operator),f=e.operands.map((function(t){return c.encodeQuery(t,e.fieldName)}));return(t={})[u]=f,t;case rc.NOT:u=yc(e.operator);var l=e.operands[0];if(Ba(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=yc(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 hc(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,n,r,o,i,s,a,c,u;if(e.fieldName===_a)throw new Error("Cannot encode a comparison command with unset field name");var f=yc(e.operator);switch(e.operator){case cc.EQ:case cc.NEQ:case cc.LT:case cc.LTE:case cc.GT:case cc.GTE:case cc.ELEM_MATCH:case cc.EXISTS:case cc.SIZE:case cc.MOD:return(t={})[e.fieldName]=((n={})[f]=Tc(e.operands[0]),n),t;case cc.IN:case cc.NIN:case cc.ALL:return(r={})[e.fieldName]=((o={})[f]=Tc(e.operands),o),r;case cc.GEO_NEAR:var l=e.operands[0];return(i={})[e.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case cc.GEO_WITHIN:l=e.operands[0];return(s={})[e.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case cc.GEO_INTERSECTS:l=e.operands[0];return(a={})[e.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(c={})[e.fieldName]=((u={})[f]=Tc(e.operands[0]),u),c}},e.prototype.encodeQueryObject=function(e){var t=Oc(e);for(var n in t){var r=t[n];if(ac(r)){t[n]=r._setFieldName(n);var o=this.encodeLogicCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else if(hc(r)){t[n]=r._setFieldName(n);o=this.encodeComparisonCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else Nc(r)&&(t[n]=Tc(r))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Wa(e[r])?e[r]=e[r].concat(t[r]):Ma(e[r])?Ma(t[r])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is "+Ua(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+Ua(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]},e}(),jc=function(){return jc=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},jc.apply(this,arguments)},Uc=function(){function e(e,t,n,r,o){var i=this;this.watch=function(e){return xc(i._db).watch(jc(jc({},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 Ef.reqClass(this._db.config)}return e.prototype.get=function(e){e=e||nc();var t=[];this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)}));var n={collectionName:this._coll,queryType:Qs.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:Da.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||nc();var t={collectionName:this._coll,queryType:Qs.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(Ys.QueryParamTypeError);var n=Object.keys(t),r=n.some((function(e){return void 0!==t[e]}));if(n.length&&!r)throw Error(Ys.QueryParamValueError);return new e(this._db,this._coll,Cc.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,n){ja.isFieldPath(t),ja.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){ja.isInteger("limit",t);var n=jc({},this._queryOptions);return n.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.skip=function(t){ja.isInteger("offset",t);var n=jc({},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||nc(),!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:Qs.WHERE,multi:!0,merge:!0,upsert:!1,data:Rc.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=jc({},this._queryOptions);return r.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.remove=function(e){e=e||nc(),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:Cc.encode(this._fieldFilters),queryType:Qs.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}(),Mc=function(e,t){return Mc=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])},Mc(e,t)};function qc(e,t){function n(){this.constructor=e}Mc(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Wc=function(e){function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return qc(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),t}(Error),Fc=function(e){function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return qc(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),t}(TypeError);function Bc(e){return e&&e.Math==Math&&e}function $c(){return Bc("object"==typeof globalThis&&globalThis)||Bc("object"==typeof window&&window)||Bc("object"==typeof self&&self)||Bc("object"==typeof global&&global)||Function("return this")()}var Hc=function(t){var n,r="object"==typeof(n=$c()).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},Gc=function(){var e=void 0;try{e=require("crypto").randomBytes}catch(e){}return e||Hc}();function Kc(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)}function Vc(e){return"object"==typeof e&&null!==e}function Jc(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 Yc(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 Fc("Must use either Buffer or TypedArray")}var Zc=/^(?:[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,zc=function(e){return"string"==typeof e&&Zc.test(e)},Xc=function(t){if(!zc(t))throw new Fc('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")},Qc=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")},eu=Math.pow(2,53),tu=-Math.pow(2,53),nu=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 Fc("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=Yc(n),this.position=this.buffer.byteLength)}return t.prototype.put=function(n){if("string"==typeof n&&1!==n.length)throw new Fc("only accepts single character String");if("number"!=typeof n&&1!==n.length)throw new Fc("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 Fc("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(Yc(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 ru(this.buffer.slice(0,this.position));throw new Wc('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=Xc(n.$uuid)),!o)throw new Fc("Unexpected Binary Extended JSON format ".concat(JSON.stringify(n)));return 4===i?new ru(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(nu.prototype,"_bsontype",{value:"Binary"});var ru=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=Yc(r);else{if("string"!=typeof r)throw new Fc("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=Xc(r)}return(s=t.call(this,o,4)||this).__id=i,s}return qc(n,t),Object.defineProperty(n.prototype,"id",{get:function(){return this.buffer},set:function(e){this.buffer=e,n.cacheHexString&&(this.__id=Qc(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=Qc(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 nu(this.id,nu.SUBTYPE_UUID)},n.generate=function(){var t=Gc(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?zc(e):!!Kc(e)&&(16===e.length&&(64==(240&e[6])&&128==(128&e[8])))))},n.createFromHexString=function(e){return new n(Xc(e))},n.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},n.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},n}(nu),ou=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(ou.prototype,"_bsontype",{value:"Code"});var iu=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(iu.prototype,"_bsontype",{value:"DBRef"});var su=void 0;try{su=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(Js){}var au=4294967296,cu=0x10000000000000000,uu=cu/2,fu={},lu={},hu=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=lu[t])?o:(r=e.fromBits(t,(0|t)<0?-1:0,!0),i&&(lu[t]=r),r):(i=-128<=(t|=0)&&t<128)&&(o=fu[t])?o:(r=e.fromBits(t,t<0?-1:0,!1),i&&(fu[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>=cu)return e.MAX_UNSIGNED_VALUE}else{if(t<=-uu)return e.MIN_VALUE;if(t+1>=uu)return e.MAX_VALUE}return t<0?e.fromNumber(-t,n).neg():e.fromBits(t%au|0,t/au|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 Vc(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(su){if(!this.unsigned&&-2147483648===this.high&&-1===t.low&&-1===t.high)return this;var n=(this.unsigned?su.div_u:su.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(n,su.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)),su){var n=(this.unsigned?su.rem_u:su.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(n,su.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)),su){var n=su.mul(this.low,this.high,t.low,t.high);return e.fromBits(n,su.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)*au+(this.low>>>0):this.high*au+(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(hu.prototype,"__isLong__",{value:!0}),Object.defineProperty(hu.prototype,"_bsontype",{value:"Long"});var pu=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,du=/^(\+|-)?(Infinity|inf)$/i,yu=/^(\+|-)?NaN$/i,gu=6111,vu=-6176,mu=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),_u=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),bu=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),wu=/^([-+])?(\d+)?$/;function Eu(e){return!isNaN(parseInt(e,10))}function Su(e){var t=hu.fromNumber(1e9),n=hu.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 hu(e.parts[r],0)),e.parts[r]=n.div(t).low,n=n.modulo(t);return{quotient:e,rem:n}}function Iu(e,t){throw new Fc('"'.concat(e,'" is not a valid Decimal128 string - ').concat(t))}var Ou=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!Kc(e))throw new Fc("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new Fc("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 hu(0,0),b=new hu(0,0),w=0;if(n.length>=7e3)throw new Fc(n+" not a valid Decimal128 string");var E=n.match(pu),S=n.match(du),I=n.match(yu);if(!E&&!S&&!I||0===n.length)throw new Fc(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&&Iu(n,"missing exponent power"),A&&void 0===O&&Iu(n,"missing exponent base"),void 0===A&&(N||T)&&Iu(n,"missing e before exponent")}if("+"!==n[w]&&"-"!==n[w]||(o="-"===n[w++]),!Eu(n[w])&&"."!==n[w]){if("i"===n[w]||"I"===n[w])return new t(e.from(o?_u:bu));if("N"===n[w])return new t(e.from(mu))}for(;Eu(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&&Iu(n,"contains multiple periods"),i=!0,w+=1);if(i&&!c)throw new Fc(n+" not a valid Decimal128 string");if("e"===n[w]||"E"===n[w]){var R=n.substr(++w).match(wu);if(!R||!R[2])return new t(e.from(mu));v=parseInt(R[0],10),w+=R[0].length}if(n[w])return new t(e.from(mu));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=vu:v-=f;v>gu;){if((g+=1)-y>34){if(h.join("").match(/^0+$/)){v=gu;break}Iu(n,"overflow")}v-=1}for(;v<vu||p<u;){if(0===g&&a<p){v=vu,a=0;break}if(p<u?u-=1:g-=1,v<gu)v+=1;else{if(h.join("").match(/^0+$/)){v=gu;break}Iu(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 k=g;k>=0;k--)if(++h[k]>9&&(h[k]=0,0===k)){if(!(v<gu))return new t(e.from(o?_u:bu));v+=1,h[k]=1}}if(_=hu.fromNumber(0),b=hu.fromNumber(0),0===a)_=hu.fromNumber(0),b=hu.fromNumber(0);else if(g-y<17){k=y;for(b=hu.fromNumber(h[k++]),_=new hu(0,0);k<=g;k++)b=(b=b.multiply(hu.fromNumber(10))).add(hu.fromNumber(h[k]))}else{k=y;for(_=hu.fromNumber(h[k++]);k<=g-17;k++)_=(_=_.multiply(hu.fromNumber(10))).add(hu.fromNumber(h[k]));for(b=hu.fromNumber(h[k++]);k<=g;k++)b=(b=b.multiply(hu.fromNumber(10))).add(hu.fromNumber(h[k]))}var C,D,j,U,M=function(e,t){if(!e&&!t)return{high:hu.fromNumber(0),low:hu.fromNumber(0)};var n=e.shiftRightUnsigned(32),r=new hu(e.getLowBits(),0),o=t.shiftRightUnsigned(32),i=new hu(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 hu(a.getLowBits(),0).add(c).add(u.shiftRightUnsigned(32)),{high:s=s.add(a.shiftRightUnsigned(32)),low:u=a.shiftLeft(32).add(new hu(u.getLowBits(),0))}}(_,hu.fromString("100000000000000000"));M.low=M.low.add(b),C=M.low,D=b,j=C.high>>>0,U=D.high>>>0,(j<U||j===U&&C.low>>>0<D.low>>>0)&&(M.high=M.high.add(hu.fromNumber(1))),r=v+6176;var q={low:hu.fromNumber(0),high:hu.fromNumber(0)};M.high.shiftRightUnsigned(49).and(hu.fromNumber(1)).equals(hu.fromNumber(1))?(q.high=q.high.or(hu.fromNumber(3).shiftLeft(61)),q.high=q.high.or(hu.fromNumber(r).and(hu.fromNumber(16383).shiftLeft(47))),q.high=q.high.or(M.high.and(hu.fromNumber(0x7fffffffffff)))):(q.high=q.high.or(hu.fromNumber(16383&r).shiftLeft(49)),q.high=q.high.or(M.high.and(hu.fromNumber(562949953421311)))),q.low=M.low,o&&(q.high=q.high.or(hu.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 hu(h,p),high:new hu(d,y)}.high.lessThan(hu.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,_=Su(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(Ou.prototype,"_bsontype",{value:"Decimal128"});var Au=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(Au.prototype,"_bsontype",{value:"Double"});var Nu=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(Nu.prototype,"_bsontype",{value:"Int32"});var Tu=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(Tu.prototype,"_bsontype",{value:"MaxKey"});var Ru=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(Ru.prototype,"_bsontype",{value:"MinKey"});var Pu=new RegExp("^[0-9a-fA-F]{24}$"),xu=null,Lu=Symbol("id"),ku=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 Fc("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[Lu]=t.generate("number"==typeof r?r:void 0);else if(ArrayBuffer.isView(r)&&12===r.byteLength)this[Lu]=r instanceof e?r:Yc(r);else{if("string"!=typeof r)throw new Fc("Argument passed in does not match the accepted types");if(12===r.length){var o=e.from(r);if(12!==o.byteLength)throw new Fc("Argument passed in must be a string of 12 bytes");this[Lu]=o}else{if(24!==r.length||!Pu.test(r))throw new Fc("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[Lu]=e.from(r,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[Lu]},set:function(e){this[Lu]=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===xu&&(xu=Gc(5)),o[4]=xu[0],o[5]=xu[1],o[6]=xu[2],o[7]=xu[3],o[8]=xu[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[Lu][11]===n[Lu][11]&&this[Lu].equals(n[Lu]);if("string"==typeof n&&t.isValid(n)&&12===n.length&&Kc(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 Fc("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(ku.prototype,"generate",{value:Jc((function(e){return ku.generate(e)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(ku.prototype,"getInc",{value:Jc((function(){return ku.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(ku.prototype,"get_inc",{value:Jc((function(){return ku.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(ku,"get_inc",{value:Jc((function(){return ku.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(ku.prototype,"_bsontype",{value:"ObjectID"});var Cu=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 Wc("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new Wc("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 Wc("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 Fc("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(t)))},e}();Object.defineProperty(Cu.prototype,"_bsontype",{value:"BSONRegExp"});var Du=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(Du.prototype,"_bsontype",{value:"Symbol"});var ju=function(e){function t(n,r){var o=this;return o instanceof t?(o=hu.isLong(n)?e.call(this,n.low,n.high,!0)||this:Vc(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 qc(t,e),t.prototype.toJSON=function(){return{$timestamp:this.toString()}},t.fromInt=function(e){return new t(hu.fromInt(e,!0))},t.fromNumber=function(e){return new t(hu.fromNumber(e,!0))},t.fromBits=function(e,n){return new t(e,n)},t.fromString=function(e,n){return new t(hu.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=hu.MAX_UNSIGNED_VALUE,t}(hu);var Uu=2147483647,Mu=-2147483648,qu=0x8000000000000000,Wu=-0x8000000000000000,Fu={$oid:ku,$binary:nu,$uuid:nu,$symbol:Du,$numberInt:Nu,$numberDecimal:Ou,$numberDouble:Au,$numberLong:hu,$minKey:Ru,$maxKey:Tu,$regex:Cu,$regularExpression:Cu,$timestamp:ju};function Bu(e,t){if(void 0===t&&(t={}),"number"==typeof e){if(t.relaxed||t.legacy)return e;if(Math.floor(e)===e){if(e>=Mu&&e<=Uu)return new Nu(e);if(e>=Wu&&e<=qu)return hu.fromNumber(e)}return new Au(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=Fu[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)):hu.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=Bu(e.$scope)),ou.fromExtendedJSON(e)}if(function(e){return Vc(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 iu)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 iu.fromExtendedJSON(c)}return e}function $u(e){var t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function Hu(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 Fc("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 Hu(e,t)}finally{t.seenObjects.pop()}}))}(e,t);if(void 0===e)return null;if(e instanceof Date||Vc(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:$u(e)}:t.relaxed&&l?{$date:$u(e)}:{$date:{$numberLong:e.getTime().toString()}}}var h;if(!("number"!=typeof e||t.relaxed&&isFinite(e))){if(Math.floor(e)===e){var p=e>=Wu&&e<=qu;if(e>=Mu&&e<=Uu)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 Cu(e.source,d).toExtendedJSON(t)}return null!=e&&"object"==typeof e?function(e,t){if(null==e||"object"!=typeof e)throw new Wc("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=Hu(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 Vc(e)&&Reflect.has(e,"_bsontype")&&"string"==typeof e._bsontype}(e)){var s=e;if("function"!=typeof s.toExtendedJSON){var a=Ku[e._bsontype];if(!a)throw new Fc("Unrecognized or invalid _bsontype: "+e._bsontype);s=a(s)}return"Code"===n&&s.scope?s=new ou(s.code,Hu(s.scope,t)):"DBRef"===n&&s.oid&&(s=new iu(Hu(s.collection,t),Hu(s.oid,t),Hu(s.db,t),Hu(s.fields,t))),s.toExtendedJSON(t)}throw new Wc("_bsontype must be a string, but was: "+typeof n)}(e,t):e}var Gu,Ku={Binary:function(e){return new nu(e.value(),e.sub_type)},Code:function(e){return new ou(e.code,e.scope)},DBRef:function(e){return new iu(e.collection||e.namespace,e.oid,e.db,e.fields)},Decimal128:function(e){return new Ou(e.bytes)},Double:function(e){return new Au(e.value)},Int32:function(e){return new Nu(e.value)},Long:function(e){return hu.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 Tu},MinKey:function(){return new Ru},ObjectID:function(e){return new ku(e)},ObjectId:function(e){return new ku(e)},BSONRegExp:function(e){return new Cu(e.pattern,e.options)},Symbol:function(e){return new Du(e.value)},Timestamp:function(e){return ju.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 Wc("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(e)));return Bu(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=Hu(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)}}(Gu||(Gu={}));var Vu=$c();Vu.Map?Vu.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})}(),hu.fromNumber(eu),hu.fromNumber(tu);var Ju=new Uint8Array(8);new DataView(Ju.buffer,Ju.byteOffset,Ju.byteLength);e.alloc(17825792);var Yu=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())}))},Zu=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])}}},zu=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=new Ef.reqClass(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return Yu(this,void 0,void 0,(function(){var e;return Zu(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(Gu.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",Cc.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}(),Xu=zu,Qu=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)}}(),ef=function(e){function t(t,n){return e.call(this,t,n)||this}return Qu(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 kc(this._db,this._coll,e)},t.prototype.add=function(e,t){return new kc(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new Xu(this._db,this._coll)},t}(Uc),tf={eq:function(e){return new fc(cc.EQ,[e])},neq:function(e){return new fc(cc.NEQ,[e])},lt:function(e){return new fc(cc.LT,[e])},lte:function(e){return new fc(cc.LTE,[e])},gt:function(e){return new fc(cc.GT,[e])},gte:function(e){return new fc(cc.GTE,[e])},in:function(e){return new fc(cc.IN,e)},nin:function(e){return new fc(cc.NIN,e)},all:function(e){return new fc(cc.ALL,e)},elemMatch:function(e){return new fc(cc.ELEM_MATCH,[e])},exists:function(e){return new fc(cc.EXISTS,[e])},size:function(e){return new fc(cc.SIZE,[e])},mod:function(e){return new fc(cc.MOD,[e])},geoNear:function(e){return new fc(cc.GEO_NEAR,[e])},geoWithin:function(e){return new fc(cc.GEO_WITHIN,[e])},geoIntersects:function(e){return new fc(cc.GEO_INTERSECTS,[e])},and:function(){var e=Wa(arguments[0])?arguments[0]:Array.from(arguments);return new sc(rc.AND,e)},nor:function(){var e=Wa(arguments[0])?arguments[0]:Array.from(arguments);return new sc(rc.NOR,e)},or:function(){var e=Wa(arguments[0])?arguments[0]:Array.from(arguments);return new sc(rc.OR,e)},not:function(){var e=Wa(arguments[0])?arguments[0]:Array.from(arguments);return new sc(rc.NOT,e)},set:function(e){return new oc(ka.SET,[e])},remove:function(){return new oc(ka.REMOVE,[])},inc:function(e){return new oc(ka.INC,[e])},mul:function(e){return new oc(ka.MUL,[e])},push:function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(Ma(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=Wa(t[0])?t[0]:Array.from(t);return new oc(ka.PUSH,e)},pull:function(e){return new oc(ka.PULL,e)},pullAll:function(e){return new oc(ka.PULL_ALL,e)},pop:function(){return new oc(ka.POP,[])},shift:function(){return new oc(ka.SHIFT,[])},unshift:function(){var e=Wa(arguments[0])?arguments[0]:Array.from(arguments);return new oc(ka.UNSHIFT,e)},addToSet:function(e){return new oc(ka.ADD_TO_SET,e)},rename:function(e){return new oc(ka.RENAME,[e])},bit:function(e){return new oc(ka.BIT,[e])},max:function(e){return new oc(ka.MAX,[e])},min:function(e){return new oc(ka.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===Ua(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new Xu},abs:function(e){return new nf("abs",e)},add:function(e){return new nf("add",e)},ceil:function(e){return new nf("ceil",e)},divide:function(e){return new nf("divide",e)},exp:function(e){return new nf("exp",e)},floor:function(e){return new nf("floor",e)},ln:function(e){return new nf("ln",e)},log:function(e){return new nf("log",e)},log10:function(e){return new nf("log10",e)},mod:function(e){return new nf("mod",e)},multiply:function(e){return new nf("multiply",e)},pow:function(e){return new nf("pow",e)},sqrt:function(e){return new nf("sqrt",e)},subtract:function(e){return new nf("subtract",e)},trunc:function(e){return new nf("trunc",e)},arrayElemAt:function(e){return new nf("arrayElemAt",e)},arrayToObject:function(e){return new nf("arrayToObject",e)},concatArrays:function(e){return new nf("concatArrays",e)},filter:function(e){return new nf("filter",e)},in:function(e){return new nf("in",e)},indexOfArray:function(e){return new nf("indexOfArray",e)},isArray:function(e){return new nf("isArray",e)},map:function(e){return new nf("map",e)},range:function(e){return new nf("range",e)},reduce:function(e){return new nf("reduce",e)},reverseArray:function(e){return new nf("reverseArray",e)},size:function(e){return new nf("size",e)},slice:function(e){return new nf("slice",e)},zip:function(e){return new nf("zip",e)},and:function(e){return new nf("and",e)},not:function(e){return new nf("not",e)},or:function(e){return new nf("or",e)},cmp:function(e){return new nf("cmp",e)},eq:function(e){return new nf("eq",e)},gt:function(e){return new nf("gt",e)},gte:function(e){return new nf("gte",e)},lt:function(e){return new nf("lt",e)},lte:function(e){return new nf("lte",e)},neq:function(e){return new nf("ne",e)},cond:function(e){return new nf("cond",e)},ifNull:function(e){return new nf("ifNull",e)},switch:function(e){return new nf("switch",e)},dateFromParts:function(e){return new nf("dateFromParts",e)},dateFromString:function(e){return new nf("dateFromString",e)},dayOfMonth:function(e){return new nf("dayOfMonth",e)},dayOfWeek:function(e){return new nf("dayOfWeek",e)},dayOfYear:function(e){return new nf("dayOfYear",e)},isoDayOfWeek:function(e){return new nf("isoDayOfWeek",e)},isoWeek:function(e){return new nf("isoWeek",e)},isoWeekYear:function(e){return new nf("isoWeekYear",e)},millisecond:function(e){return new nf("millisecond",e)},minute:function(e){return new nf("minute",e)},month:function(e){return new nf("month",e)},second:function(e){return new nf("second",e)},hour:function(e){return new nf("hour",e)},week:function(e){return new nf("week",e)},year:function(e){return new nf("year",e)},literal:function(e){return new nf("literal",e)},mergeObjects:function(e){return new nf("mergeObjects",e)},objectToArray:function(e){return new nf("objectToArray",e)},allElementsTrue:function(e){return new nf("allElementsTrue",e)},anyElementTrue:function(e){return new nf("anyElementTrue",e)},setDifference:function(e){return new nf("setDifference",e)},setEquals:function(e){return new nf("setEquals",e)},setIntersection:function(e){return new nf("setIntersection",e)},setIsSubset:function(e){return new nf("setIsSubset",e)},setUnion:function(e){return new nf("setUnion",e)},concat:function(e){return new nf("concat",e)},dateToString:function(e){return new nf("dateToString",e)},indexOfBytes:function(e){return new nf("indexOfBytes",e)},indexOfCP:function(e){return new nf("indexOfCP",e)},split:function(e){return new nf("split",e)},strLenBytes:function(e){return new nf("strLenBytes",e)},strLenCP:function(e){return new nf("strLenCP",e)},strcasecmp:function(e){return new nf("strcasecmp",e)},substr:function(e){return new nf("substr",e)},substrBytes:function(e){return new nf("substrBytes",e)},substrCP:function(e){return new nf("substrCP",e)},toLower:function(e){return new nf("toLower",e)},toUpper:function(e){return new nf("toUpper",e)},meta:function(e){return new nf("meta",e)},addToSet:function(e){return new nf("addToSet",e)},avg:function(e){return new nf("avg",e)},first:function(e){return new nf("first",e)},last:function(e){return new nf("last",e)},max:function(e){return new nf("max",e)},min:function(e){return new nf("min",e)},push:function(e){return new nf("push",e)},stdDevPop:function(e){return new nf("stdDevPop",e)},stdDevSamp:function(e){return new nf("stdDevSamp",e)},sum:function(e){return new nf("sum",e)},let:function(e){return new nf("let",e)}},project:{slice:function(e){return new rf("slice",e)},elemMatch:function(e){return new rf("elemMatch",e)}}},nf=function(e,t){this["$"+e]=t},rf=function(e,t){this["$"+e]=t},of=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 Pa},enumerable:!0,configurable:!0}),e}();function sf(e){return new of(e)}var af={code:"INSERT_DOC_FAIL",message:"insert document failed"},cf={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},uf=function(){return uf=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},uf.apply(this,arguments)},ff=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())}))},lf=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])}}},hf="database.updateDocInTransaction",pf=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 ff(this,void 0,void 0,(function(){var t,n,r,o;return lf(this,(function(i){switch(i.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:Gu.stringify(_c(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=Gu.parse(n.inserted),1==(o=Gu.parse(n.ok))&&1==r)return[2,uf(uf({},n),{ok:o,inserted:r})];throw new Error(af.message)}}))}))},e.prototype.get=function(){return ff(this,void 0,void 0,(function(){var e,t;return lf(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?Da.formatField(Gu.parse(t.data)):Gu.parse(t.data),requestId:t.requestId}]}}))}))},e.prototype.set=function(e){return ff(this,void 0,void 0,(function(){var t,n;return lf(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Gu.stringify(_c(e),{relaxed:!1}),upsert:!0},[4,this._request.send(hf,t)];case 1:if((n=r.sent()).code)throw n;return[2,uf(uf({},n),{updated:Gu.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},e.prototype.update=function(e){return ff(this,void 0,void 0,(function(){var t,n;return lf(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Gu.stringify(Rc.encode(e),{relaxed:!1})},[4,this._request.send(hf,t)];case 1:if((n=r.sent()).code)throw n;return[2,uf(uf({},n),{updated:Gu.parse(n.updated)})]}}))}))},e.prototype.delete=function(){return ff(this,void 0,void 0,(function(){var e,t;return lf(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,uf(uf({},t),{deleted:Gu.parse(t.deleted)})]}}))}))},e}(),df=function(e,t){this._coll=t,this._transaction=e},yf=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)}}(),gf=function(e){function t(t,n){return e.call(this,t,n)||this}return yf(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 pf(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new pf(this._transaction,this._coll,t).create(e)},t}(df),vf=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())}))},mf=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])}}},_f=function(){function e(e){this._db=e,this._request=new Ef.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return vf(this,void 0,void 0,(function(){var e;return mf(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 gf(this,e)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return vf(this,void 0,void 0,(function(){var e,t;return mf(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 vf(this,void 0,void 0,(function(){var t,n;return mf(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 bf(){return vf(this,void 0,void 0,(function(){var e;return mf(this,(function(t){switch(t.label){case 0:return[4,(e=new _f(this)).init()];case 1:return t.sent(),[2,e]}}))}))}function wf(e,t){return void 0===t&&(t=3),vf(this,void 0,void 0,(function(){var n,r,o,i,s=this;return mf(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new _f(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 vf(s,void 0,void 0,(function(){return mf(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===cf.code?[4,wf.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 Ef=function(){function e(e){this.config=e,this.Geo=tc,this.serverDate=La,this.command=tf,this.RegExp=sf,this.startTransaction=bf,this.runTransaction=wf,this.logicCommand=sc,this.updateCommand=oc,this.queryCommand=fc}return e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new ef(this,e)},e.prototype.createCollection=function(t){var n={collectionName:t};return new e.reqClass(this.config).send("database.addCollection",n)},e}(),Sf=function(){return Sf=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},Sf.apply(this,arguments)};var If={name:"database",entity:{database:function(e){var t=this.platform,n=t.adapter,r=t.runtime;return Ef.reqClass=this.request.constructor,Ef.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},Ef.runtime=r,this.wsClientClass&&(Ef.wsClass=n.wsClass,Ef.wsClientClass=this.wsClientClass),Ef.ws||(Ef.ws=null),new Ef(Sf(Sf({},this.config),e))}}};try{cloudbase.registerComponent(If)}catch(e){}var Of,Af="1.7.2";Zt.registerVersion(Af);try{!function(e){try{e.registerComponent(Wr)}catch(e){console.warn(e)}}(Zt),function(e){try{e.registerComponent(Qr)}catch(e){console.warn(e)}}(Zt),function(e){try{e.registerComponent(go)}catch(e){console.warn(e)}}(Zt),function(e){try{e.registerComponent(If)}catch(e){console.warn(e)}}(Zt),function(e){try{e.registerComponent(Ms),e.registerHook(Us)}catch(e){console.warn(e)}}(Zt),function(e){try{e.registerComponent(zs)}catch(e){console.warn(e)}}(Zt)}catch(e){}try{window.cloudbase=Zt}catch(e){}!function(e){e.development="dev-1gpp53ju3ceb46c7",e.testing="dev-1gpp53ju3ceb46c7",e.production="release-7gvojkxi667a3f26"}(Of||(Of={}));var Nf={ENV:Of[process.env.NODE_ENV],REGION:"ap-shanghai"},Tf={region:Nf.REGION,env:Nf.ENV},Rf=Zt.init(Tf);function Pf(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,Rf.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)}))]}}))}))}var xf=t.create();function Lf(e){return function(e){!e.method&&e.data&&(e.method="post"),e.method||e.data||(e.method="get")}(e),function(e){e.requestInterceptors&&"function"==typeof e.requestInterceptors&&xf.interceptors.request.use(e.requestInterceptors),e.responseInterceptors&&"function"==typeof e.responseInterceptors&&xf.interceptors.response.use(e.responseInterceptors)}(e),new Promise((function(t,n){xf.request({method:e.method,url:e.url,headers:(null==e?void 0:e.headers)||{},data:null==e?void 0:e.data,params:null==e?void 0:e.params,timeout:(null==e?void 0:e.timeout)||8e3}).then((function(e){if(200===e.status){var r=e.data;t(r)}else{r=e.data;n(r)}})).catch((function(t){var r=(null==t?void 0:t.response)||{};(null==e?void 0:e.catchCallback)&&"function"==typeof(null==e?void 0:e.catchCallback)&&(null==e||e.catchCallback(t));var o=null==r?void 0:r.data;n(o)}))}))}var kf=function(){function e(){this.token=null,this.loginPath="",this.instance=t.create(),this.setupInterceptors()}return e.prototype.setupTokenListener=function(e){var t=this;window.addEventListener("storage",(function(n){if("string"==typeof e&&n.key===e&&n.newValue&&t.setToken(n.newValue),"function"==typeof e){var r=e();t.setToken(r)}}));var n="string"==typeof e?window.localStorage.getItem(e):"function"==typeof e?e():null;n&&this.setToken(n)},e.prototype.setupLoingPath=function(e){this.loginPath=e},e.prototype.encryptToken=function(e){if(!e){var t=e+"|+|"+(new Date).getTime();return r.AES.encrypt(t,"214c!dsf1").toString()}},e.prototype.setToken=function(e){this.token=e},e.prototype.setupInterceptors=function(){var e=this;this.instance.interceptors.request.use((function(t){return e.token&&(t.headers["x-belink-authorization"]=e.encryptToken(e.token)),t}))},e.prototype.setRequestMethod=function(e){e&&!(null==e?void 0:e.method)&&(e.method=(null==e?void 0:e.data)?"post":"get")},e.prototype.setInterceptors=function(e){"function"==typeof e.requestInterceptors&&this.instance.interceptors.request.use(e.requestInterceptors),"function"==typeof e.responseInterceptors&&this.instance.interceptors.response.use(e.responseInterceptors)},e.prototype.request=function(e){return o(this,void 0,void 0,(function(){var t=this;return i(this,(function(r){return this.setRequestMethod(e),this.setInterceptors(e),[2,new Promise((function(r,o){t.instance.request({method:e.method,url:e.url,headers:e.headers,data:e.data,params:e.params,timeout:e.timeout||8e3}).then((function(e){200===e.status?r(e.data):o(e.data)})).catch((function(r){var i,s=null==r?void 0:r.response;s&&401===s.status?t.loginPath&&location.replace(t.loginPath):(e.catchCallback&&r instanceof n&&e.catchCallback(r),o((null===(i=r.response)||void 0===i?void 0:i.data)||r))}))}))]}))}))},e}(),Cf=new kf;export{Cf as beLinkRequest,Pf as callFunction,Lf as request};
|
|
1
|
+
import{Buffer as e}from"buffer";import t,{AxiosError as n}from"axios";import r from"crypto-js";function o(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 i(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 s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function c(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 u={},f={},l={};Object.defineProperty(l,"__esModule",{value:!0}),l.COMMUNITY_SITE_URL=l.IS_DEBUG_MODE=l.getProtocol=l.setProtocol=l.getSdkName=l.setSdkName=void 0;var h="@cloudbase/js-sdk";l.setSdkName=function(e){h=e},l.getSdkName=function(){return h};var p="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";l.setProtocol=function(e){p=e},l.getProtocol=function(){return p},l.IS_DEBUG_MODE="development"===process.env.NODE_ENV,l.COMMUNITY_SITE_URL="https://support.qq.com/products/148793";var d={};Object.defineProperty(d,"__esModule",{value:!0}),d.ERRORS=void 0,d.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=s&&s.__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=s&&s.__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(l,e),n(d,e)}(f);var y,g={},v={};!function(e){e.local="local",e.none="none",e.session="session"}(y||(y={}));var m=function(){},_=function(){};function b(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 w,E=c(Object.freeze({__proto__:null,AbstractSDKRequest:m,AbstractStorage:_,get StorageType(){return y},formatUrl:b})),S={},I={exports:{}},O={exports:{}};function A(){return w||(w=1,O.exports=function(){var 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);return e}()),O.exports}var N,T={exports:{}};function R(){return N||(N=1,T.exports=function(e){return 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}(A())),T.exports}var P,x,L,k,C={exports:{}};I.exports=function(e){return e.HmacSHA256}(A(),R(),P||(P=1,C.exports=(L=(x=A()).lib.Base,k=x.enc.Utf8,void(x.algo.HMAC=L.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=k.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 D=I.exports,j={exports:{}};j.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}(A());var U=j.exports,M={exports:{}};M.exports=function(e){return e.enc.Utf8}(A());var q=M.exports,W=s&&s.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(S,"__esModule",{value:!0}),S.transformPhone=S.sleep=S.printGroupLog=S.throwError=S.printInfo=S.printError=S.printWarn=S.execCallback=S.createPromiseCallback=S.removeParam=S.getHash=S.getQuery=S.toQueryString=S.createSign=S.formatUrl=S.genSeqId=S.isFormData=S.isInstanceOf=S.isNull=S.isPalinObject=S.isUndefined=S.isString=S.isArray=void 0;var F=W(D),B=W(U),$=W(q),H=f;function G(e){var t=B.default.stringify(e);return t=(t=(t=t.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}S.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},S.isString=function(e){return"string"==typeof e},S.isUndefined=function(e){return void 0===e},S.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},S.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},S.isInstanceOf=function(e,t){return e instanceof t},S.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},S.genSeqId=function(){return Math.random().toString(16).slice(2)},S.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},S.createSign=function(e,t){var n=G($.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+G($.default.parse(JSON.stringify(e)));return n+"."+G(F.default(n,t))},S.toQueryString=function(e){void 0===e&&(e={});var t=[];for(var n in e)t.push(n+"="+encodeURIComponent(e[n]));return t.join("&")},S.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]:""},S.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]"+e+"=([^&#]*)"));return t?t[1]:""},S.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},S.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},S.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},S.printWarn=function(e,t){console.warn("["+H.getSdkName()+"]["+e+"]:"+t)},S.printError=function(e,t){console.error({code:e,msg:"["+H.getSdkName()+"]["+e+"]:"+t})},S.printInfo=function(e,t){console.log("["+H.getSdkName()+"]["+e+"]:"+t)},S.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"["+H.getSdkName()+"]["+e+"]:"+t}))},S.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()},S.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},S.transformPhone=function(e){return"+86"+e};var K,V=s&&s.__extends||(K=function(e,t){return K=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])},K(e,t)},function(e,t){function n(){this.constructor=e}K(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),J=s&&s.__assign||function(){return J=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},J.apply(this,arguments)},Y=s&&s.__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())}))},z=s&&s.__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(v,"__esModule",{value:!0}),v.WebRequest=v.genAdapter=void 0;var Z=S,X=l,Q=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 V(t,e),t.prototype.get=function(e){return this._request(J(J({},e),{method:"get"}),this._restrictedMethods.includes("get"))},t.prototype.post=function(e){return this._request(J(J({},e),{method:"post"}),this._restrictedMethods.includes("post"))},t.prototype.put=function(e){return this._request(J(J({},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(J(J({},e),{data:o,method:"post"}),this._restrictedMethods.includes("upload"))},t.prototype.download=function(e){return Y(this,void 0,void 0,(function(){var t,n,r,o;return z(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(J(J({},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=Z.formatUrl(X.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=Z.isFormData(f)?f:"application/x-www-form-urlencoded"===u["content-type"]?Z.toQueryString(f):p||(f?JSON.stringify(f):void 0),h&&(g.withCredentials=!0),g.send(s)}))},t}(E.AbstractSDKRequest);v.WebRequest=Q,v.genAdapter=function(){return{root:window,reqClass:Q,wsClass:WebSocket,localStorage:localStorage,sessionStorage:sessionStorage}},function(e){var t=s&&s.__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=s&&s.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=s&&s.__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 o,i=r(v),a=S;!function(e){e.WEB="web",e.WX_MP="wx_mp"}(o=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:i.genAdapter(),runtime:o.WEB}}}(g);var ee={},te=s&&s.__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)}}(),ne=s&&s.__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())}))},re=s&&s.__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(ee,"__esModule",{value:!0}),ee.CloudbaseCache=void 0;var oe=S,ie=f,se=function(e){function t(t){var n=e.call(this)||this;return n._root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return te(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}(E.AbstractStorage);function ae(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:(oe.printWarn(ie.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new se(t.root));case"none":return new se(t.root);case"session":return t.sessionStorage?t.sessionStorage:(oe.printWarn(ie.ERRORS.INVALID_PARAMS,"sessionStorage is not supported on current platform"),new se(t.root))}}var ce=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=ae(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=ae(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);oe.isUndefined(i)||oe.isNull(i)||(n.setItem(o,i),this._storage.removeItem(o))}}this._storage=n}}else oe.printWarn(ie.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use updatePersistenceAsync insteed")},e.prototype.updatePersistenceAsync=function(e){return ne(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c;return re(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=ae(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(),oe.isUndefined(c)||oe.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:ie.ERRORS.OPERATION_FAIL,msg:"["+ie.getSdkName()+"]["+ie.ERRORS.OPERATION_FAIL+"]setStore failed",info:e}))}}else oe.printWarn(ie.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,n){return ne(this,void 0,void 0,(function(){var r;return re(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:""}oe.printWarn(ie.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var n;return ne(this,void 0,void 0,(function(){var r;return re(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):oe.printWarn(ie.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return ne(this,void 0,void 0,(function(){return re(this,(function(t){switch(t.label){case 0:return[4,this._storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}();ee.CloudbaseCache=ce;var ue={},fe=s&&s.__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)}}(),le=s&&s.__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(ue,"__esModule",{value:!0}),ue.removeEventListener=ue.activateEvent=ue.addEventListener=ue.CloudbaseEventEmitter=ue.IErrorEvent=ue.CloudbaseEvent=void 0;var he=S;var pe=function(e,t){this.data=t||null,this.name=e};ue.CloudbaseEvent=pe;var de=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return fe(t,e),t}(pe);ue.IErrorEvent=de;var ye=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(he.isInstanceOf(e,de))return console.error(e.error),this;var n=he.isString(e)?new pe(e,t||{}):e,r=n.name;if(this._listens(r)){n.target=this;for(var o=0,i=this._listeners[r]?le(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}();ue.CloudbaseEventEmitter=ye;var ge=new ye;ue.addEventListener=function(e,t){ge.on(e,t)},ue.activateEvent=function(e,t){void 0===t&&(t={}),ge.fire(e,t)},ue.removeEventListener=function(e,t){ge.off(e,t)};var ve={},me={},_e=s&&s.__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())}))},be=s&&s.__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(me,"__esModule",{value:!0}),me.catchErrorsDecorator=void 0;var we=S,Ee=f,Se=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(Se=-1!==navigator.userAgent.indexOf("Firefox"));var Ie=Se?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,Oe=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function Ae(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=Se?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]\\s*\\(.*\\)$"),c=Se?/^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(Oe,o)),(i=new Error).stack=(Se?"@debugger":"Error")+"\n"+f.join("\n")}return i}me.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(Ee.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 Ie.test(e)}));if(-1!==r){var o=Oe.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=Ae({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 we.printGroupLog(l),r}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return _e(this,void 0,void 0,(function(){var t,n,r,o,l,h;return be(this,(function(p){switch(p.label){case 0:t=Ae({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}})))),we.printGroupLog(l),r;case 4:return[2]}}))}))}}}},function(e){var t=s&&s.__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=s&&s.__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(me,e)}(ve);var Ne=s&&s.__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]}),Te=s&&s.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Re=s&&s.__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)&&Ne(t,e,n);return Te(t,e),t};Object.defineProperty(u,"__esModule",{value:!0});var Pe=u.helpers=u.utils=u.events=u.cache=u.adapters=u.constants=void 0,xe=Re(f),Le=u.constants=xe,ke=Re(g),Ce=u.adapters=ke,De=Re(ee),je=u.cache=De,Ue=Re(ue),Me=u.events=Ue,qe=Re(S),We=u.utils=qe,Fe=Re(ve);Pe=u.helpers=Fe;var Be=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)}}(),$e=function(){return $e=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},$e.apply(this,arguments)},He=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())}))},Ge=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 Ke=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 Be(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:b("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 He(t,void 0,void 0,(function(){var t,o,i,s,a,c;return Ge(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:$e({},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:b("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}(m),Ve={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()}},Je=function(e,t){void 0===t&&(t={});var n=wx.connectSocket($e({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 Ye={genAdapter:function(){return{root:{},reqClass:Ke,wsClass:Je,localStorage:Ve,primaryStorage:y.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"},ze=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},Ze=Le.ERRORS,Xe={};function Qe(e,t){var n=t.name,r=t.namespace,o=t.entity,i=t.injectEvents,s=t.IIFE,a=void 0!==s&&s;if(Xe[n]||r&&e[r])throw new Error(JSON.stringify({code:Ze.INVALID_OPERATION,msg:"Duplicate component "+n}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:Ze.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(e)}if(Xe[n]=t,r?e.prototype[r]=o:et(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=ze(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 et(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]=et(e[n],t[n]));return e}var tt={},nt=function(){return nt=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},nt.apply(this,arguments)},rt=je.CloudbaseCache,ot={},it={};function st(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};ot[t]?ot[t].updatePersistence(n):ot[t]=new rt(nt(nt({},e),{keys:o,platformInfo:r,alwaysLocalKeys:["anonymousUuidKey"]})),it[t]=it[t]||new rt(nt(nt({},e),{keys:o,platformInfo:r,persistence:"local"}))}function at(e){return ot[e]}function ct(e){return it[e]}var ut=Le.setSdkName,ft=Le.setProtocol,lt="",ht="@cloudbase/js-sdk";var pt,dt="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",yt="undefined"!=typeof process&&"e2e"===process.env.NODE_ENV&&"pre"===process.env.END_POINT?"//tcb-pre.tencentcloudapi.com/web":"//tcb-api.tencentcloudapi.com/web";function gt(e,t){yt=e,t&&(dt=t,ft(t))}function vt(){return{BASE_URL:yt,PROTOCOL:dt}}!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.CUSTOM="CUSTOM",e.NULL="NULL"}(pt||(pt={}));var mt="loginStateExpire",_t="refreshAccessToken",bt=function(){return bt=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},bt.apply(this,arguments)},wt=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())}))},Et=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])}}},St=Le.ERRORS,It=We.genSeqId,Ot=We.isFormData,At=We.formatUrl,Nt=We.createSign,Tt=Ce.RUNTIME,Rt=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function Pt(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(Ot(s))for(var e in o)s.append(e,o[e]);else t.data=bt(bt({},s),o)}(),t.headers=bt(bt({},t.headers||{}),i),r.call(e,t)}}function xt(){var e=It();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+lt,"x-seqid":e}}}var Lt=function(){function e(e){this._throwWhenRequestFail=!1,this.config=e,this._reqClass=new tt.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post"]}),this._throwWhenRequestFail=e.throw||!1,this._cache=at(this.config.env),this._localCache=ct(this.config.env),Pt(this._reqClass,"post",[xt]),Pt(this._reqClass,"upload",[xt]),Pt(this._reqClass,"download",[xt])}return e.prototype.post=function(e){return wt(this,void 0,void 0,(function(){return Et(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 wt(this,void 0,void 0,(function(){return Et(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 wt(this,void 0,void 0,(function(){return Et(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 wt(this,void 0,void 0,(function(){var e,t,n;return Et(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 wt(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a,c;return Et(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:St.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 wt(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 Et(this,(function(R){switch(R.label){case 0:return r="x-tcb-trace_"+this.config.env,o="application/x-www-form-urlencoded",i=bt({action:e,dataVersion:"2020-01-10",env:this.config.env},t),-1!==Rt.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),tt.runtime!==Tt.WEB&&(h=this.config,p=h.appSign,d=h.appSecret,y=Date.now(),g=d.appAccessKey,v=d.appAccessKeyId,m=Nt({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=bt(bt({},b),E)),S=vt(),I=S.BASE_URL,O=S.PROTOCOL,A=At(O,I,E),w&&(A+=w),[4,this.post(bt({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={}),wt(this,void 0,void 0,(function(){var n;return Et(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!==Rt.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:St.OPERATION_FAIL,msg:"["+n.data.code+"] "+n.data.message}));return[2,n.data]}}))}))},e.prototype._refreshAccessToken=function(e){return void 0===e&&(e=1),wt(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,u,f,l,h,p;return Et(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:St.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()===pt.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:St.OPERATION_FAIL,message:"重试获取 refresh token 失败"}));case 9:return zt.fire(mt),[4,this._cache.removeStoreAsync(o)];case 10:d.sent(),d.label=11;case 11:throw new Error(JSON.stringify({code:St.NETWORK_ERROR,msg:"refresh access_token failed:"+u.data.code}));case 12:return u.data.access_token?(zt.fire(_t),[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 wt(this,void 0,void 0,(function(){var t,n,r,o;return Et(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}(),kt={};var Ct=function(){return Ct=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},Ct.apply(this,arguments)},Dt=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},jt=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ut=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())}))},Mt=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])}}},qt=Ce.useAdapters,Wt=Ce.useDefaultAdapter,Ft=Ce.RUNTIME,Bt=Le.ERRORS,$t=Le.COMMUNITY_SITE_URL,Ht=We.printWarn,Gt=Pe.catchErrorsDecorator,Kt={timeout:15e3,persistence:"local"},Vt=6e5,Jt={},Yt=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 tt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return at(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return ct(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return e=this._config.env,kt[e];var e},enumerable:!1,configurable:!0}),e.prototype.init=function(t){if(!t.env)throw new Error(JSON.stringify({code:Bt.INVALID_PARAMS,msg:"env must not be specified"}));if(tt.adapter||this._useDefaultAdapter(),this.requestClient=new tt.adapter.reqClass({timeout:t.timeout||5e3,timeoutMsg:"["+ht+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+t.timeout/1e3+"s"}),tt.runtime!==Ft.WEB){if(!t.appSecret)throw new Error(JSON.stringify({code:Bt.INVALID_PARAMS,msg:"invalid appSecret"}));var n=tt.adapter.getAppSign?tt.adapter.getAppSign():"";if(t.appSign&&n&&t.appSign!==n)throw new Error(JSON.stringify({code:Bt.INVALID_PARAMS,msg:"invalid appSign"}));if(n&&(t.appSign=n),!t.appSign)throw new Error(JSON.stringify({code:Bt.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=Ct(Ct({},Kt),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;st({env:o,persistence:i,debug:s,platformInfo:this.platform}),function(e){kt[e.env]=new Lt(bt(bt({},e),{throw:!0}))}({env:o,region:t.region||"",timeout:a,appSecret:c,appSign:u}),t.region&&function(e,t,n){gt(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,st({env:this._config.env,persistence:t,debug:n,platformInfo:this.platform})},e.prototype.registerExtension=function(e){Jt[e.name]=e},e.prototype.invokeExtension=function(e,t){return Ut(this,void 0,void 0,(function(){var n;return Mt(this,(function(r){switch(r.label){case 0:if(!(n=Jt[e]))throw new Error(JSON.stringify({code:Bt.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=qt(e)||{},n=t.adapter,r=t.runtime;n&&(tt.adapter=n),r&&(tt.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:Ze.INVALID_OPERATION,msg:"target:"+r+" is not exist"}));var o=e.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:Ze.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,ze([this],e)),o.call.apply(o,ze([this],e))}}(e,t)},e.prototype.registerComponent=function(t){Qe(e,t)},e.prototype.registerVersion=function(e){!function(e){lt=e}(e)},e.prototype.registerSdkName=function(e){!function(e){ht=e,ut(e)}(e)},e.prototype.registerEndPoint=function(e,t){gt(e,t)},e.prototype._useDefaultAdapter=function(){var e=Wt(),t=e.adapter,n=e.runtime;tt.adapter=t,tt.runtime=n},e.prototype._formatTimeout=function(e){switch(!0){case e>Vt:return Ht(Bt.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),Vt;case e<100:return Ht(Bt.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},Dt([Gt({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+$t]}),jt("design:type",Function),jt("design:paramtypes",[Object]),jt("design:returntype",e)],e.prototype,"init",null),Dt([Gt({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+$t]}),jt("design:type",Function),jt("design:paramtypes",[String,Object]),jt("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}(),zt=new Yt;zt.useAdapters(Ye);var Zt,Xt=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())}))},Qt=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])}}},en=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request}return e.prototype.checkLocalLoginState=function(){return Xt(this,void 0,void 0,(function(){var e,t,n,r,o,i;return Qt(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 Ur({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 Xt(this,void 0,void 0,(function(){var t,n,r,o;return Qt(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 Xt(this,void 0,void 0,(function(){var n,r,o;return Qt(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 Xt(this,void 0,void 0,(function(){var e;return Qt(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 Xt(this,void 0,void 0,(function(){var t;return Qt(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"}(Zt||(Zt={}));var 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)}}(),nn=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},rn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},on=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())}))},sn=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])}}},an=Le.getSdkName,cn=Le.ERRORS,un=Le.COMMUNITY_SITE_URL,fn=Ce.RUNTIME,ln=We.getQuery,hn=We.getHash,pn=We.removeParam,dn=We.printWarn,yn=Pe.catchErrorsDecorator,gn=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 tn(t,e),t.prototype.signIn=function(){return on(this,void 0,void 0,(function(){return sn(this,(function(e){return[2,dn(cn.OPERATION_FAIL,"API signIn has been deprecated, please use signInWithRedirect insteed")]}))}))},t.prototype.signInWithRedirect=function(){return on(this,void 0,void 0,(function(){return sn(this,(function(e){return[2,this._redirect()]}))}))},t.prototype.getRedirectResult=function(e){return on(this,void 0,void 0,(function(){var t;return sn(this,(function(n){return(t=vn())?[2,this._signInWithCode(t,e)]:[2,null]}))}))},t.prototype.getLinkRedirectResult=function(e){return void 0===e&&(e={}),on(this,void 0,void 0,(function(){var t,n,r,o,i,s;return sn(this,(function(a){return t=e.withUnionId,n=void 0!==t&&t,(r=vn())?(o=this._appid,c=this._scope,i="snsapi_login"===c?"WECHAT-OPEN":"WECHAT-PUBLIC",s=this._runtime===fn.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=pn("code",location.href);e=pn("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("["+an()+"]["+cn.UNKOWN_ERROR+"]"+e)}},t.prototype._signInWithCode=function(e,t){return on(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u;return sn(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 Dr.fire(qr.LOGIN_STATE_CHANGED),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Zt.WECHAT,persistence:this._config.persistence}),[4,this.refreshUserInfo()];case 7:return f.sent(),[4,(u=new Ur({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={}),on(this,void 0,void 0,(function(){var o,i,s,a,c,u;return sn(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===fn.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("["+an()+"]["+cn.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("["+an()+"]["+cn.OPERATION_FAIL+"] action:getJwt not return refreshToken")}))]}))}))},nn([yn({title:"跳转微信公众号授权失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().signInWithRedirect() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+un]}),rn("design:type",Function),rn("design:paramtypes",[]),rn("design:returntype",Promise)],t.prototype,"signInWithRedirect",null),nn([yn({title:"微信公众号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+un]}),rn("design:type",Function),rn("design:paramtypes",[Object]),rn("design:returntype",Promise)],t.prototype,"getRedirectResult",null),nn([yn({title:"获取微信重定向绑定结果",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getLinkRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+un]}),rn("design:type",Function),rn("design:paramtypes",[Object]),rn("design:returntype",Promise)],t.prototype,"getLinkRedirectResult",null),t}(en);function vn(){return ln("code")||hn("code")}var 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)}}(),_n=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},bn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},wn=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())}))},En=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])}}},Sn=Le.ERRORS,In=Le.COMMUNITY_SITE_URL,On=We.throwError,An=We.isString,Nn=Me.addEventListener,Tn=Pe.catchErrorsDecorator,Rn=function(e){function t(t){var n=e.call(this,t)||this;return n._onConverted=n._onConverted.bind(n),Nn(qr.ANONYMOUS_CONVERTED,n._onConverted),n}return mn(t,e),t.prototype.signIn=function(){return wn(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return En(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(),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Zt.ANONYMOUS,persistence:"local"}),Dr.fire(qr.LOGIN_STATE_CHANGED),[4,(s=new Ur({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:Sn.OPERATION_FAIL,msg:JSON.stringify(i)||"anonymous signIn failed"}))}}))}))},t.prototype.linkAndRetrieveDataWithTicket=function(e){return wn(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return En(this,(function(c){switch(c.label){case 0:return An(e)||On(Sn.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(),Dr.fire(qr.ANONYMOUS_CONVERTED,{env:this._config.env}),Dr.fire(qr.LOGIN_TYPE_CHANGED,{loginType:Zt.CUSTOM,persistence:"local"}),[4,(a=new Ur({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 7:return c.sent(),[2,a];case 8:On(Sn.OPERATION_FAIL,JSON.stringify(s)||"linkAndRetrieveDataWithTicket failed"),c.label=9;case 9:return[2]}}))}))},t.prototype._setAnonymousUUID=function(e){return wn(this,void 0,void 0,(function(){var t,n,r;return En(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,Zt.ANONYMOUS)];case 3:return o.sent(),[2]}}))}))},t.prototype._clearAnonymousUUID=function(){return wn(this,void 0,void 0,(function(){return En(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 wn(this,void 0,void 0,(function(){return En(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]}}))}))},_n([Tn({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().anonymouseProvider().signIn() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+In]}),bn("design:type",Function),bn("design:paramtypes",[]),bn("design:returntype",Promise)],t.prototype,"signIn",null),t}(en),Pn=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)}}(),xn=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},Ln=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},kn=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())}))},Cn=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])}}},Dn=Le.ERRORS,jn=Le.COMMUNITY_SITE_URL,Un=We.isString,Mn=Pe.catchErrorsDecorator,qn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Pn(t,e),t.prototype.signIn=function(e){return kn(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return Cn(this,(function(c){switch(c.label){case 0:if(!Un(e))throw new Error(JSON.stringify({code:Dn.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(),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Zt.CUSTOM,persistence:this._config.persistence}),Dr.fire(qr.LOGIN_STATE_CHANGED),[4,this.refreshUserInfo()];case 5:return c.sent(),[4,(a=new Ur({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:Dn.OPERATION_FAIL,msg:"custom signIn failed"}))}}))}))},xn([Mn({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().customAuthProvider().signIn() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+jn]}),Ln("design:type",Function),Ln("design:paramtypes",[String]),Ln("design:returntype",Promise)],t.prototype,"signIn",null),t}(en),Wn=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)}}(),Fn=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},Bn=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())}))},Hn=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])}}},Gn=We.throwError,Kn=We.isString,Vn=Le.ERRORS,Jn=Le.COMMUNITY_SITE_URL,Yn=Pe.catchErrorsDecorator,zn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Wn(t,e),t.prototype.signIn=function(e,t){return $n(this,void 0,void 0,(function(){var n,r,o,i,s;return Hn(this,(function(a){switch(a.label){case 0:return Kn(e)||Gn(Vn.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(),Dr.fire(qr.LOGIN_STATE_CHANGED),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Zt.EMAIL,persistence:this._config.persistence}),[2,new Ur({envId:this._config.env,cache:this._cache,request:this._request})];case 8:r.code?Gn(Vn.OPERATION_FAIL,"Email login fail["+r.code+"] "+r.message):Gn(Vn.OPERATION_FAIL,"Email login fail"),a.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t){return $n(this,void 0,void 0,(function(){return Hn(this,(function(n){return[2,this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})]}))}))},t.prototype.resetPassword=function(e){return $n(this,void 0,void 0,(function(){return Hn(this,(function(t){return[2,this._request.send("auth.sendPasswordResetEmail",{email:e})]}))}))},t.prototype.resetPasswordWithToken=function(e,t){return $n(this,void 0,void 0,(function(){return Hn(this,(function(n){return[2,this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})]}))}))},t.prototype.activate=function(e){return $n(this,void 0,void 0,(function(){return Hn(this,(function(t){return[2,this._request.send("auth.activateEndUserMail",{token:e})]}))}))},Fn([Yn({title:"邮箱密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().emailAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 邮箱地址与密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Jn]}),Bn("design:type",Function),Bn("design:paramtypes",[String,String]),Bn("design:returntype",Promise)],t.prototype,"signIn",null),Fn([Yn({title:"邮箱注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithEmailAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Jn]}),Bn("design:type",Function),Bn("design:paramtypes",[String,String]),Bn("design:returntype",Promise)],t.prototype,"signUp",null),Fn([Yn({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用 auth().sendPasswordResetEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经与当前用户绑定"," 4 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Jn]}),Bn("design:type",Function),Bn("design:paramtypes",[String]),Bn("design:returntype",Promise)],t.prototype,"resetPassword",null),Fn([Yn({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Jn]}),Bn("design:type",Function),Bn("design:paramtypes",[String,String]),Bn("design:returntype",Promise)],t.prototype,"resetPasswordWithToken",null),Fn([Yn({title:"邮箱激活失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Jn]}),Bn("design:type",Function),Bn("design:paramtypes",[String]),Bn("design:returntype",Promise)],t.prototype,"activate",null),t}(en),Zn=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)}}(),Xn=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},Qn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},er=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())}))},tr=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])}}},nr=We.printWarn,rr=Le.ERRORS,or=Le.COMMUNITY_SITE_URL,ir=Pe.catchErrorsDecorator,sr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Zn(t,e),t.prototype.signIn=function(e,t){return er(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u,f;return tr(this,(function(l){switch(l.label){case 0:if("string"!=typeof e)throw new Error(JSON.stringify({code:rr.INVALID_PARAMS,msg:"username must be a string"}));return"string"!=typeof t&&(t="",nr(rr.INVALID_PARAMS,"password is empty")),n=this._cache.keys.refreshTokenKey,i=(o=this._request).send,s=["auth.signIn"],a={loginType:Zt.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(),Dr.fire(qr.LOGIN_STATE_CHANGED),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Zt.USERNAME,persistence:this._config.persistence}),[2,new Ur({envId:this._config.env,cache:this._cache,request:this._request})];case 9:throw r.code?new Error(JSON.stringify({code:rr.OPERATION_FAIL,msg:"login by username failed:["+r.code+"] "+r.message})):new Error(JSON.stringify({code:rr.OPERATION_FAIL,msg:"login by username failed"}));case 10:return[2]}}))}))},Xn([ir({title:"用户名密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().signInWithUsernameAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录"," 3 - 用户名密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+or]}),Qn("design:type",Function),Qn("design:paramtypes",[String,String]),Qn("design:returntype",Promise)],t.prototype,"signIn",null),t}(en),ar=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)}}(),cr=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},ur=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())}))},lr=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])}}},hr=We.throwError,pr=We.isString,dr=We.transformPhone,yr=Le.ERRORS,gr=Le.COMMUNITY_SITE_URL,vr=Pe.catchErrorsDecorator,mr="SIGNIN",_r="SIGNUP",br="FORCERESETPWD",wr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ar(t,e),t.prototype.signIn=function(e){return fr(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,u;return lr(this,(function(f){switch(f.label){case 0:return t=e.phoneNumber,n=e.phoneCode,r=e.password,o=e.signMethod,pr(t)||hr(yr.INVALID_PARAMS,"phoneNumber must be a string"),pr(n)||pr(r)||hr(yr.INVALID_PARAMS,"phoneCode or password must be a string"),o||(o=mr),i=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:Zt.PHONE,phoneNumber:dr(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(),Dr.fire(qr.LOGIN_STATE_CHANGED),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Zt.PHONE,persistence:this._config.persistence}),[2,new Ur({envId:this._config.env,cache:this._cache,request:this._request})];case 8:s.code?hr(yr.OPERATION_FAIL,"Phone login fail["+s.code+"] "+s.message):hr(yr.OPERATION_FAIL,"Phone login fail"),f.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t,n){return fr(this,void 0,void 0,(function(){return lr(this,(function(r){return[2,this.signIn({phoneNumber:e,phoneCode:t,password:n,signMethod:_r})]}))}))},t.prototype.forceResetPwd=function(e,t,n){return fr(this,void 0,void 0,(function(){return lr(this,(function(r){return[2,this.signIn({phoneNumber:e,phoneCode:t,password:n,signMethod:br})]}))}))},cr([vr({title:"手机号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().SmsAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录"," 3 - 短信验证码/密码是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+gr]}),ur("design:type",Function),ur("design:paramtypes",[Object]),ur("design:returntype",Promise)],t.prototype,"signIn",null),cr([vr({title:"手机短信注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithPhoneCode() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+gr]}),ur("design:type",Function),ur("design:paramtypes",[String,String,String]),ur("design:returntype",Promise)],t.prototype,"signUp",null),cr([vr({title:"手机密码重置失败",messages:["请确认以下各项:"," 1 - 调用 auth().forceResetPwd() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+gr]}),ur("design:type",Function),ur("design:paramtypes",[String,String,String]),ur("design:returntype",Promise)],t.prototype,"forceResetPwd",null),t}(en),Er=function(){return Er=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},Er.apply(this,arguments)},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},Ir=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Or=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())}))},Ar=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])}}},Nr=Me.CloudbaseEventEmitter,Tr=Ce.RUNTIME,Rr=We.printWarn,Pr=We.throwError,xr=We.transformPhone,Lr=Le.ERRORS,kr=Le.COMMUNITY_SITE_URL,Cr=Pe.catchErrorsDecorator,Dr=new Nr,jr=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 Or(this,void 0,void 0,(function(){return Ar(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 Or(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 Ar(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 Or(this,void 0,void 0,(function(){var e,t,n,r,o,i;return Ar(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 Or(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return Ar(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&&Pr(Lr.INVALID_PARAMS,"username must be a string"),this._request.send("auth.updateUsername",{username:e})},e.prototype.refresh=function(){return Or(this,void 0,void 0,(function(){var e;return Ar(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 Or(this,void 0,void 0,(function(){return Ar(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:xr(e),phoneCode:t})]}))}))},e.prototype.updatePhoneNumber=function(e,t){return Or(this,void 0,void 0,(function(){return Ar(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:xr(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 Or(this,void 0,void 0,(function(){var t;return Ar(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()},Sr([Cr({title:"绑定自定义登录失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithTicket() 的语法或参数是否正确"," 2 - 此账户是否已经绑定自定义登录"," 3 - ticket 参数是否归属当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String]),Ir("design:returntype",Promise)],e.prototype,"linkWithTicket",null),Sr([Cr({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithRedirect() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方"," 3 - 此第三方是否已经授权","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[Object]),Ir("design:returntype",void 0)],e.prototype,"linkWithRedirect",null),Sr([Cr({title:"获取账户列表失败",messages:["请确认以下各项:"," 1 - 调用 User.getLinkedUidList() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[]),Ir("design:returntype",Promise)],e.prototype,"getLinkedUidList",null),Sr([Cr({title:"设置微信主账号失败",messages:["请确认以下各项:"," 1 - 调用 User.setPrimaryUid() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String]),Ir("design:returntype",void 0)],e.prototype,"setPrimaryUid",null),Sr([Cr({title:"接触绑定失败",messages:["请确认以下各项:"," 1 - 调用 User.unlink() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String]),Ir("design:returntype",void 0)],e.prototype,"unlink",null),Sr([Cr({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[Object]),Ir("design:returntype",Promise)],e.prototype,"update",null),Sr([Cr({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String,String]),Ir("design:returntype",void 0)],e.prototype,"updatePassword",null),Sr([Cr({title:"更新邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 User.updateEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String,String]),Ir("design:returntype",void 0)],e.prototype,"updateEmail",null),Sr([Cr({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String]),Ir("design:returntype",void 0)],e.prototype,"updateUsername",null),Sr([Cr({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[]),Ir("design:returntype",Promise)],e.prototype,"refresh",null),Sr([Cr({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().linkWithPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String,String]),Ir("design:returntype",Promise)],e.prototype,"linkWithPhoneNumber",null),Sr([Cr({title:"更新手机号失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String,String]),Ir("design:returntype",Promise)],e.prototype,"updatePhoneNumber",null),e}(),Ur=function(){function e(e){var t=e.envId,n=e.cache,r=e.request;t||Pr(Lr.INVALID_PARAMS,"envId is not defined"),this._cache=n,this.user=new jr({cache:n,request:r})}return e.prototype.checkLocalState=function(){return Or(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Ar(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 Or(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a;return Ar(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===Zt.ANONYMOUS},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCustomAuth",{get:function(){return this.loginType===Zt.CUSTOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isWeixinAuth",{get:function(){return this.loginType===Zt.WECHAT||this.loginType===Zt.WECHAT_OPEN||this.loginType===Zt.WECHAT_PUBLIC},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsernameAuth",{get:function(){return this.loginType===Zt.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===Zt.PHONE},enumerable:!1,configurable:!0}),e}(),Mr=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request,this._runtime=e.runtime||Tr.WEB,Dr.on(qr.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}Rr(Lr.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 Or(this,void 0,void 0,(function(){var e;return Ar(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 Or(this,void 0,void 0,(function(){return Ar(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 Or(this,void 0,void 0,(function(){var e;return Ar(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 gn(Er(Er({},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 Rn(Er(Er({},this._config),{cache:this._cache,request:this._request}))),this._anonymousAuthProvider},e.prototype.customAuthProvider=function(){return this._customAuthProvider||(this._customAuthProvider=new qn(Er(Er({},this._config),{cache:this._cache,request:this._request}))),this._customAuthProvider},e.prototype.emailAuthProvider=function(){return this._emailAuthProvider||(this._emailAuthProvider=new zn(Er(Er({},this._config),{cache:this._cache,request:this._request}))),this._emailAuthProvider},e.prototype.usernameAuthProvider=function(){return this._usernameAuthProvider||(this._usernameAuthProvider=new sr(Er(Er({},this._config),{cache:this._cache,request:this._request}))),this._usernameAuthProvider},e.prototype.phoneAuthProvider=function(){return this._phoneAuthProvider||(this._phoneAuthProvider=new wr(Er(Er({},this._config),{cache:this._cache,request:this._request}))),this._phoneAuthProvider},e.prototype.signInWithUsernameAndPassword=function(e,t){return Or(this,void 0,void 0,(function(){return Ar(this,(function(n){return[2,this.usernameAuthProvider().signIn(e,t)]}))}))},e.prototype.isUsernameRegistered=function(e){return Or(this,void 0,void 0,(function(){var t;return Ar(this,(function(n){switch(n.label){case 0:return"string"!=typeof e&&Pr(Lr.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 Or(this,void 0,void 0,(function(){return Ar(this,(function(n){return[2,this.emailAuthProvider().signIn(e,t)]}))}))},e.prototype.signUpWithEmailAndPassword=function(e,t){return Or(this,void 0,void 0,(function(){return Ar(this,(function(n){return[2,this.emailAuthProvider().signUp(e,t)]}))}))},e.prototype.sendPasswordResetEmail=function(e){return Or(this,void 0,void 0,(function(){return Ar(this,(function(t){return[2,this.emailAuthProvider().resetPassword(e)]}))}))},e.prototype.signOut=function(){return Or(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Ar(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),Dr.fire(qr.LOGIN_STATE_CHANGED),Dr.fire(qr.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:Zt.NULL,persistence:this._config.persistence}),[2,s]}}))}))},e.prototype.onLoginStateChanged=function(e){return Or(this,void 0,void 0,(function(){var t,n=this;return Ar(this,(function(r){switch(r.label){case 0:return Dr.on(qr.LOGIN_STATE_CHANGED,(function(){return Or(n,void 0,void 0,(function(){var t;return Ar(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){Dr.on(qr.LOGIN_STATE_EXPIRED,e.bind(this))},e.prototype.onAccessTokenRefreshed=function(e){Dr.on(qr.ACCESS_TOKEN_REFRESHD,e.bind(this))},e.prototype.onAnonymousConverted=function(e){Dr.on(qr.ANONYMOUS_CONVERTED,e.bind(this))},e.prototype.onLoginTypeChanged=function(e){var t=this;Dr.on(qr.LOGIN_TYPE_CHANGED,(function(){return Or(t,void 0,void 0,(function(){var t;return Ar(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 Ur({envId:this._config.env,cache:this._cache,request:this._request});return t.checkLocalState(),t}return null}Rr(Lr.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},e.prototype.getLoginState=function(){return Or(this,void 0,void 0,(function(){var e,t;return Ar(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 Ur({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 Or(this,void 0,void 0,(function(){var e;return Ar(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,Er(Er({},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 Or(this,void 0,void 0,(function(){var e,t,n,r;return Ar(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 Or(this,void 0,void 0,(function(){return Ar(this,(function(t){switch(t.label){case 0:return[4,this._request.send("auth.sendPhoneCode",{phoneNumber:xr(e)})];case 1:return[2,"Ok"===t.sent().data.SendStatus]}}))}))},e.prototype.signUpWithPhoneCode=function(e,t,n){return Or(this,void 0,void 0,(function(){return Ar(this,(function(r){return[2,this.phoneAuthProvider().signUp(e,t,n)]}))}))},e.prototype.signInWithPhoneCodeOrPassword=function(e){return Or(this,void 0,void 0,(function(){return Ar(this,(function(t){return[2,this.phoneAuthProvider().signIn(e)]}))}))},e.prototype.forceResetPwdByPhoneCode=function(e){return Or(this,void 0,void 0,(function(){return Ar(this,(function(t){return[2,this.phoneAuthProvider().signIn(Er(Er({},e),{signMethod:br}))]}))}))},e.prototype._onLoginTypeChanged=function(e){return Or(this,void 0,void 0,(function(){var t,n,r;return Ar(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]}}))}))},Sr([Cr({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[]),Ir("design:returntype",Promise)],e.prototype,"getCurrenUser",null),Sr([Cr({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String]),Ir("design:returntype",Promise)],e.prototype,"isUsernameRegistered",null),Sr([Cr({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[]),Ir("design:returntype",Promise)],e.prototype,"signOut",null),Sr([Cr({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[]),Ir("design:returntype",Promise)],e.prototype,"getLoginState",null),Sr([Cr({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[]),Ir("design:returntype",Promise)],e.prototype,"getUserInfo",null),Sr([Cr({title:"发送短信验证码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+kr]}),Ir("design:type",Function),Ir("design:paramtypes",[String]),Ir("design:returntype",Promise)],e.prototype,"sendPhoneCode",null),e}(),qr={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRED:"loginStateExpire",LOGIN_TYPE_CHANGED:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",ACCESS_TOKEN_REFRESHD:"refreshAccessToken"},Wr={name:"auth",namespace:"auth",injectEvents:{bus:Dr,events:[qr.LOGIN_TYPE_CHANGED,qr.LOGIN_STATE_EXPIRED,qr.LOGIN_STATE_CHANGED,qr.ACCESS_TOKEN_REFRESHD,qr.ANONYMOUS_CONVERTED]},entity:function(e){if(void 0===e&&(e={region:"",persistence:"local"}),this.authInstance)return Rr(Lr.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 Mr({env:s,region:e.region,persistence:a,debug:c,cache:this.cache,request:this.request,runtime:r}),this.authInstance}};try{cloudbase.registerComponent(Wr)}catch(e){}var Fr=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},Br=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},$r=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())}))},Hr=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])}}},Gr=Le.getSdkName,Kr=Le.ERRORS,Vr=Le.COMMUNITY_SITE_URL,Jr=We.execCallback,Yr=Pe.catchErrorsDecorator,zr="functions",Zr=function(){function e(){}return e.prototype.callFunction=function(e,t){return $r(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u,f,l,h,p;return Hr(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:Kr.INVALID_PARAMS,msg:"["+zr+".callFunction] invalid function name"}));try{a=r?JSON.stringify(r):""}catch(e){throw new Error(JSON.stringify({code:Kr.INVALID_PARAMS,msg:"["+zr+".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,Jr(t,null,l)];if(h=l.data.response_data,i)return[2,Jr(t,null,{result:h,requestId:l.requestId})];try{return h=JSON.parse(l.data.response_data),[2,Jr(t,null,{result:h,requestId:l.requestId})]}catch(e){Jr(t,new Error("["+Gr()+"]["+Kr.INVALID_PARAMS+"]["+zr+".callFunction] response data must be json"))}return[3,4];case 3:return p=d.sent(),Jr(t,p),[3,4];case 4:return[2]}}))}))},Fr([Yr({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Vr]}),Br("design:type",Function),Br("design:paramtypes",[Object,Function]),Br("design:returntype",Promise)],e.prototype,"callFunction",null),e}(),Xr=new Zr,Qr={name:zr,entity:{callFunction:Xr.callFunction}};try{cloudbase.registerComponent(Qr)}catch(e){}var eo=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},to=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},no=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())}))},ro=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])}}},oo=Le.getSdkName,io=Le.ERRORS,so=Le.COMMUNITY_SITE_URL,ao=We.isArray,co=We.isString,uo=We.isPalinObject,fo=We.execCallback,lo=Pe.catchErrorsDecorator,ho="storage",po=function(){function e(){}return e.prototype.uploadFile=function(e,t){return no(this,void 0,void 0,(function(){var n,r,o,i,s,a,c,u,f,l,h,p,d,y,g;return ro(this,(function(v){switch(v.label){case 0:if(n=e.cloudPath,r=e.filePath,o=e.onUploadProgress,!co(n)||!r)throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".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,fo(t,null,{fileID:l,download_url:p,requestId:d})]:[2,fo(t,new Error("["+oo()+"]["+io.OPERATION_FAIL+"]["+ho+"]:"+g.data))]}}))}))},e.prototype.getUploadMetadata=function(e,t){return no(this,void 0,void 0,(function(){var n,r,o,i,s;return ro(this,(function(a){switch(a.label){case 0:if(n=e.cloudPath,!co(n))throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".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,fo(t,null,i)];case 3:return s=a.sent(),[2,fo(t,s)];case 4:return[2]}}))}))},e.prototype.deleteFile=function(e,t){return no(this,void 0,void 0,(function(){var n,r,o,i,s,a;return ro(this,(function(c){switch(c.label){case 0:if(!(n=e.fileList)||!ao(n)||0===n.length)throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".deleteFile] fileList must not be empty"}));for(r=0,o=n;r<o.length;r++)if(!(i=o[r])||!co(i))throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".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,fo(t,null,s)]:(a={fileList:s.data.delete_list,requestId:s.requestId},[2,fo(t,null,a)])}}))}))},e.prototype.getTempFileURL=function(e,t){return no(this,void 0,void 0,(function(){var n,r,o,i,s,a;return ro(this,(function(c){switch(c.label){case 0:if(!(n=e.fileList)||!ao(n)||0===n.length)throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".getTempFileURL] fileList must not be empty"}));for(r=[],o=0,i=n;o<i.length;o++)if(s=i[o],uo(s)){if(!s.hasOwnProperty("fileID")||!s.hasOwnProperty("maxAge"))throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".getTempFileURL] file info must include fileID and maxAge"}));r.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!co(s))throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".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,fo(t,null,a)]:[2,fo(t,null,{fileList:a.data.download_list,requestId:a.requestId})]}}))}))},e.prototype.downloadFile=function(e,t){return no(this,void 0,void 0,(function(){var n,r,o,i,s,a;return ro(this,(function(c){switch(c.label){case 0:if(n=e.fileID,!co(n))throw new Error(JSON.stringify({code:io.INVALID_PARAMS,msg:"["+ho+".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,fo(t,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return a=c.sent(),[2,fo(t,null,a)]}}))}))},eo([lo({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+so]}),to("design:type",Function),to("design:paramtypes",[Object,Function]),to("design:returntype",Promise)],e.prototype,"uploadFile",null),eo([lo({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+so]}),to("design:type",Function),to("design:paramtypes",[Object,Function]),to("design:returntype",Promise)],e.prototype,"getUploadMetadata",null),eo([lo({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+so]}),to("design:type",Function),to("design:paramtypes",[Object,Function]),to("design:returntype",Promise)],e.prototype,"deleteFile",null),eo([lo({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+so]}),to("design:type",Function),to("design:paramtypes",[Object,Function]),to("design:returntype",Promise)],e.prototype,"getTempFileURL",null),eo([lo({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+so]}),to("design:type",Function),to("design:paramtypes",[Object,Function]),to("design:returntype",Promise)],e.prototype,"downloadFile",null),e}(),yo=new po,go={name:ho,entity:{uploadFile:yo.uploadFile,deleteFile:yo.deleteFile,getTempFileURL:yo.getTempFileURL,downloadFile:yo.downloadFile,getUploadMetadata:yo.getUploadMetadata}};try{cloudbase.registerComponent(go)}catch(e){}var vo="__lodash_hash_undefined__",mo=1/0,_o=9007199254740991,bo="[object Function]",wo="[object GeneratorFunction]",Eo="[object Symbol]",So=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Io=/^\w*$/,Oo=/^\./,Ao=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,No=/\\(\\)?/g,To=/^\[object .+?Constructor\]$/,Ro=/^(?:0|[1-9]\d*)$/,Po="object"==typeof s&&s&&s.Object===Object&&s,xo="object"==typeof self&&self&&self.Object===Object&&self,Lo=Po||xo||Function("return this")();var ko,Co=Array.prototype,Do=Function.prototype,jo=Object.prototype,Uo=Lo["__core-js_shared__"],Mo=(ko=/[^.]+$/.exec(Uo&&Uo.keys&&Uo.keys.IE_PROTO||""))?"Symbol(src)_1."+ko:"",qo=Do.toString,Wo=jo.hasOwnProperty,Fo=jo.toString,Bo=RegExp("^"+qo.call(Wo).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),$o=Lo.Symbol,Ho=Co.splice,Go=ri(Lo,"Map"),Ko=ri(Object,"create"),Vo=$o?$o.prototype:void 0,Jo=Vo?Vo.toString:void 0;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){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){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Xo(e,t,n){var r=e[t];Wo.call(e,t)&&ci(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function Qo(e,t){for(var n=e.length;n--;)if(ci(e[n][0],t))return n;return-1}function ei(e){if(!fi(e)||(t=e,Mo&&Mo in t))return!1;var t,n=function(e){var t=fi(e)?Fo.call(e):"";return t==bo||t==wo}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Bo:To;return n.test(function(e){if(null!=e){try{return qo.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function ti(e,t,n,r){if(!fi(e))return e;t=function(e,t){if(ui(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||li(e))return!0;return Io.test(e)||!So.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:function(e){return ui(e)?e:ii(e)}(t);for(var o=-1,i=t.length,s=i-1,a=e;null!=a&&++o<i;){var c=si(t[o]),u=n;if(o!=s){var f=a[c];void 0===(u=r?r(f,c,a):void 0)&&(u=fi(f)?f:oi(t[o+1])?[]:{})}Xo(a,c,u),a=a[c]}return e}function ni(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 ri(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return ei(n)?n:void 0}function oi(e,t){return!!(t=null==t?_o:t)&&("number"==typeof e||Ro.test(e))&&e>-1&&e%1==0&&e<t}Yo.prototype.clear=function(){this.__data__=Ko?Ko(null):{}},Yo.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Yo.prototype.get=function(e){var t=this.__data__;if(Ko){var n=t[e];return n===vo?void 0:n}return Wo.call(t,e)?t[e]:void 0},Yo.prototype.has=function(e){var t=this.__data__;return Ko?void 0!==t[e]:Wo.call(t,e)},Yo.prototype.set=function(e,t){return this.__data__[e]=Ko&&void 0===t?vo:t,this},zo.prototype.clear=function(){this.__data__=[]},zo.prototype.delete=function(e){var t=this.__data__,n=Qo(t,e);return!(n<0)&&(n==t.length-1?t.pop():Ho.call(t,n,1),!0)},zo.prototype.get=function(e){var t=this.__data__,n=Qo(t,e);return n<0?void 0:t[n][1]},zo.prototype.has=function(e){return Qo(this.__data__,e)>-1},zo.prototype.set=function(e,t){var n=this.__data__,r=Qo(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Zo.prototype.clear=function(){this.__data__={hash:new Yo,map:new(Go||zo),string:new Yo}},Zo.prototype.delete=function(e){return ni(this,e).delete(e)},Zo.prototype.get=function(e){return ni(this,e).get(e)},Zo.prototype.has=function(e){return ni(this,e).has(e)},Zo.prototype.set=function(e,t){return ni(this,e).set(e,t),this};var ii=ai((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(li(e))return Jo?Jo.call(e):"";var t=e+"";return"0"==t&&1/e==-mo?"-0":t}(t);var n=[];return Oo.test(e)&&n.push(""),e.replace(Ao,(function(e,t,r,o){n.push(r?o.replace(No,"$1"):t||e)})),n}));function si(e){if("string"==typeof e||li(e))return e;var t=e+"";return"0"==t&&1/e==-mo?"-0":t}function ai(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(ai.Cache||Zo),n}function ci(e,t){return e===t||e!=e&&t!=t}ai.Cache=Zo;var ui=Array.isArray;function fi(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function li(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&Fo.call(e)==Eo}var hi=a((function(e,t,n){return null==e?e:ti(e,t,n)})),pi="__lodash_hash_undefined__",di=1/0,yi="[object Function]",gi="[object GeneratorFunction]",vi="[object Symbol]",mi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_i=/^\w*$/,bi=/^\./,wi=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ei=/\\(\\)?/g,Si=/^\[object .+?Constructor\]$/,Ii="object"==typeof s&&s&&s.Object===Object&&s,Oi="object"==typeof self&&self&&self.Object===Object&&self,Ai=Ii||Oi||Function("return this")();var Ni=Array.prototype,Ti=Function.prototype,Ri=Object.prototype,Pi=Ai["__core-js_shared__"],xi=function(){var e=/[^.]+$/.exec(Pi&&Pi.keys&&Pi.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Li=Ti.toString,ki=Ri.hasOwnProperty,Ci=Ri.toString,Di=RegExp("^"+Li.call(ki).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ji=Ai.Symbol,Ui=Ni.splice,Mi=zi(Ai,"Map"),qi=zi(Object,"create"),Wi=ji?ji.prototype:void 0,Fi=Wi?Wi.toString:void 0;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){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Hi(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 Gi(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 Ki(e){if(!ns(e)||(t=e,xi&&xi in t))return!1;var t,n=function(e){var t=ns(e)?Ci.call(e):"";return t==yi||t==gi}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Di:Si;return n.test(function(e){if(null!=e){try{return Li.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function Vi(e,t){e=function(e,t){return 1==t.length?e:function(e,t){for(var n=0,r=(t=Zi(t,e)?[t]:Ji(t)).length;null!=e&&n<r;)e=e[Qi(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=Zi(t,e)?[t]:Ji(t));var n,r,o=Qi((r=(n=t)?n.length:0)?n[r-1]:void 0);return!(null!=e&&ki.call(e,o))||delete e[o]}function Ji(e){return ts(e)?e:Xi(e)}function Yi(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 zi(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Ki(n)?n:void 0}function Zi(e,t){if(ts(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!rs(e))||(_i.test(e)||!mi.test(e)||null!=t&&e in Object(t))}Bi.prototype.clear=function(){this.__data__=qi?qi(null):{}},Bi.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Bi.prototype.get=function(e){var t=this.__data__;if(qi){var n=t[e];return n===pi?void 0:n}return ki.call(t,e)?t[e]:void 0},Bi.prototype.has=function(e){var t=this.__data__;return qi?void 0!==t[e]:ki.call(t,e)},Bi.prototype.set=function(e,t){return this.__data__[e]=qi&&void 0===t?pi:t,this},$i.prototype.clear=function(){this.__data__=[]},$i.prototype.delete=function(e){var t=this.__data__,n=Gi(t,e);return!(n<0)&&(n==t.length-1?t.pop():Ui.call(t,n,1),!0)},$i.prototype.get=function(e){var t=this.__data__,n=Gi(t,e);return n<0?void 0:t[n][1]},$i.prototype.has=function(e){return Gi(this.__data__,e)>-1},$i.prototype.set=function(e,t){var n=this.__data__,r=Gi(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Hi.prototype.clear=function(){this.__data__={hash:new Bi,map:new(Mi||$i),string:new Bi}},Hi.prototype.delete=function(e){return Yi(this,e).delete(e)},Hi.prototype.get=function(e){return Yi(this,e).get(e)},Hi.prototype.has=function(e){return Yi(this,e).has(e)},Hi.prototype.set=function(e,t){return Yi(this,e).set(e,t),this};var Xi=es((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(rs(e))return Fi?Fi.call(e):"";var t=e+"";return"0"==t&&1/e==-di?"-0":t}(t);var n=[];return bi.test(e)&&n.push(""),e.replace(wi,(function(e,t,r,o){n.push(r?o.replace(Ei,"$1"):t||e)})),n}));function Qi(e){if("string"==typeof e||rs(e))return e;var t=e+"";return"0"==t&&1/e==-di?"-0":t}function es(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(es.Cache||Hi),n}es.Cache=Hi;var ts=Array.isArray;function ns(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function rs(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&Ci.call(e)==vi}var os=a((function(e,t){return null==e||Vi(e,t)})),is={exports:{}};!function(e,t){var n="__lodash_hash_undefined__",r=9007199254740991,o="[object Arguments]",i="[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*)$/,k={};k[o]=k["[object Array]"]=k[_]=k[b]=k[i]=k[a]=k[w]=k[E]=k[S]=k[I]=k[O]=k[f]=k[l]=k[h]=k[d]=k[y]=k[g]=k[v]=k[A]=k[N]=k[T]=k[R]=!0,k["[object Error]"]=k[c]=k[m]=!1;var C="object"==typeof s&&s&&s.Object===Object&&s,D="object"==typeof self&&self&&self.Object===Object&&self,j=C||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__"],Z=function(){var e=/[^.]+$/.exec(z&&z.keys&&z.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),X=J.toString,Q=Y.hasOwnProperty,ee=Y.toString,te=RegExp("^"+X.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)==o)}(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,i=!!r;for(var s in e)!t&&!Q.call(e,s)||i&&("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,s,p,m){var x;if(r&&(x=p?r(e,s,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 C=qe(e),D=C==c||C==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(C==h||C==o||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(!k[C])return p?e:{};x=function(e,t,n,r){var o=e.constructor;switch(t){case _:return Ce(e);case i:case a:return new o(+e);case b:return function(e,t){var n=t?Ce(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?Ce(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 s=e,Ie?Object(Ie.call(s)):{}}var s}(e,C,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 ke(e){return!(!Je(e)||(t=e,Z&&Z in t))&&(Ve(e)||$(e)?te:x).test(Be(e));var t}function Ce(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 ke(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?r: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 X.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<=r}(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)}}(is,is.exports);var ss=a(is.exports);function as(e){return void 0===e&&(e=""),(e?e+"_":"")+ +new Date+"_"+Math.random()}var cs,us=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}})},fs=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}})},ls=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)}}(),hs=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 ls(t,e),t}(Error),ps=function(e){return null==e?void 0:e.isRealtimeErrorMessageError},ds=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 ls(t,e),t}(Error),ys=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 ls(t,e),t}(Error),gs=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+" "+(vs[this.errCode]||"")+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e}}}),n.errCode=t.errCode||"UNKNOWN_ERROR",n.errMsg=t.errMsg,n}return ls(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),vs={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"},ms=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},_s=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())}))},bs=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])}}},ws=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"}(cs||(cs={}));var Es=function(){function e(e){var t=this;this.watchStatus=cs.INITING,this._login=function(e,n){return _s(t,void 0,void 0,(function(){var t;return bs(this,(function(r){switch(r.label){case 0:return this.watchStatus=cs.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 _s(t,void 0,void 0,(function(){var t,n=this;return bs(this,(function(r){switch(r.label){case 0:if(this._initWatchPromise)return[2,this._initWatchPromise];this._initWatchPromise=new Promise((function(t,r){return _s(n,void 0,void 0,(function(){var n,o,i,s,a,c,u,f,l,h;return bs(this,(function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),this.watchStatus===cs.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===cs.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(this.watchStatus=cs.INITING,o={watchId:this.watchId,requestId:as(),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 fs({id:c,docChanges:[],docs:[],type:"init"}),this.listener.onChange(l),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=cs.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 _s(t,void 0,void 0,(function(){var t,n=this;return bs(this,(function(r){switch(r.label){case 0:if(this._rebuildWatchPromise)return[2,this._rebuildWatchPromise];this._rebuildWatchPromise=new Promise((function(t,r){return _s(n,void 0,void 0,(function(){var n,o,i,s;return bs(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===cs.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===cs.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):(this.watchStatus=cs.REBUILDING,o={watchId:this.watchId,requestId:as(),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=cs.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 _s(t,void 0,void 0,(function(){var t,r,o,i=this;return bs(this,(function(s){return t="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new gs({errCode:t?vs.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:vs.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 _s(i,void 0,void 0,(function(){var e,t=this;return bs(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),e=function(){return _s(t,void 0,void 0,(function(){return bs(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,ms(100)];case 3:return r.sent(),this.watchStatus!==cs.PAUSED?[3,4]:(n.reject(new ys(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 _s(t,void 0,void 0,(function(){var e,t,n;return bs(this,(function(r){switch(r.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==cs.ACTIVE)return this.watchStatus=cs.CLOSED,this.onWatchClose(this,e),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=cs.CLOSING,t={watchId:this.watchId,requestId:as(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=cs.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new gs({errCode:vs.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 _s(t,void 0,void 0,(function(){var e,t,n;return bs(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==cs.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(e={watchId:this.watchId,requestId:as(),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(),ps(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 gs({errCode:vs.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 gs({errCode:vs.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if(ps(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 us({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 cs.PAUSED:if("ERROR"!==e.msgType)return;break;case cs.LOGGINGIN:case cs.INITING:case cs.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while "+this.watchStatus);case cs.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case cs.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 gs({errCode:vs.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=cs.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=cs.PAUSED,console.log("[realtime] client paused ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.resume=function(){return _s(this,void 0,void 0,(function(){var e;return bs(this,(function(t){switch(t.label){case 0:this.watchStatus=cs.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 _s(this,void 0,void 0,(function(){var t;return bs(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 _s(this,void 0,void 0,(function(){var t,n,r,o,i,s,a,c,u,f,l,h;return bs(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(Ss)}catch(e){return this.closeWithError(new gs({errCode:vs.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}s=ws(o.currentDocs),a=!1,c=function(n,c){var f,l,h,p,d,y,g,v,m,_,b;return bs(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=ss(l),f.updatedFields)for(d in f.updatedFields)hi(y,d,f.updatedFields[d]);if(f.removedFields)for(h=0,p=f.removedFields;h<p.length;h++)d=p[h],os(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 gs({errCode:vs.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 gs({errCode:vs.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 gs({errCode:vs.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=ws(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 fs({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 Ss(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 Is,Os={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"}(Is||(Is={}));var As=function(e,t){var n=Os[e],r=n?n.name+", code "+e+", reason "+(t||n.description):"code "+e;return new gs({errCode:vs.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},Ns=null,Ts="web";function Rs(){return Ns}function Ps(){return Ts}function xs(e){Ts=e}var Ls=function(){return Ls=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},Ls.apply(this,arguments)},ks=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())}))},Cs=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])}}},Ds=1,js=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 ks(t,void 0,void 0,(function(){var t=this;return Cs(this,(function(n){return[2,new Promise((function(n,r){return ks(t,void 0,void 0,(function(){var t,o,i,s,a,c,u,f=this;return Cs(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 ks(f,void 0,void 0,(function(){return Cs(this,(function(e){switch(e.label){case 0:return o&&i?[3,2]:[4,ms(0)];case 1:e.sent(),o&&i||a(new ds("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!==Ds)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),ks(t,void 0,void 0,(function(){var t=this;return Cs(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(Is.ReconnectWebSocket),this._wsInitPromise=new Promise((function(r,o){return ks(t,void 0,void 0,(function(){var t,i,s=this;return Cs(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=Rs();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,ms(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 gs({errCode:vs.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 gs({errCode:vs.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 Is.ReconnectWebSocket:case Is.NoRealtimeListeners:break;case Is.HeartbeatPingError:case Is.HeartbeatPongTimeoutError:case Is.NormalClosure:case Is.AbnormalClosure:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(As(e.code));break;case Is.NoAuthentication:t.closeAllClients(As(e.code,e.reason));break;default:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(As(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 hs(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===Ds)},this.onceWSConnected=function(){return ks(t,void 0,void 0,(function(){var e=this;return Cs(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 ks(t,void 0,void 0,(function(){var t,r,o,i,s,a,c,u,f=this;return Cs(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 ks(f,void 0,void 0,(function(){var n,r,o,i,s;return Cs(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:as(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:Ps(),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 ks(t,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Cs(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:Ps()})]);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 ks(t,void 0,void 0,(function(){var e;return Cs(this,(function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:as(),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(Is.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,Os[e].name),this._ws=void 0)},e.prototype.watch=function(e){this._ws||this._wsInitPromise||this.initWebSocketConnection(!1);var t=new Es(Ls(Ls({},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 ks(t,void 0,void 0,(function(){var e=this;return Cs(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this._ws&&this._ws.readyState===Ds?(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(Is.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),e?0:this._context.appConfig.realtimePingInterval)},e}(),Us={target:"database",entity:function(){var e,t=this.platform,n=t.adapter,r=t.runtime;e=n.wsClass,Ns=e,xs(r)}},Ms={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=js}};try{cloudbase.registerComponent(Ms),cloudbase.registerHook(Us)}catch(e){}var qs=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},Ws=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Fs=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())}))},Bs=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=Le.ERRORS,Hs=Le.COMMUNITY_SITE_URL,Gs=Pe.catchErrorsDecorator,Ks="analytics",Vs=["mall"];var Js,Ys,zs=new(function(){function e(){}return e.prototype.analytics=function(e){return Fs(this,void 0,void 0,(function(){var t,n,r;return Bs(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!==Vs.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:$s.INVALID_PARAMS,msg:"["+Ks+".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]}))}))},qs([Gs({customInfo:{className:"Cloudbase",methodName:"analytics"},title:"上报调用失败",messages:["请确认以下各项:"," 1 - 调用 analytics() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Hs]}),Ws("design:type",Function),Ws("design:paramtypes",[Object]),Ws("design:returntype",Promise)],e.prototype,"analytics",null),e}()),Zs={name:Ks,entity:{analytics:zs.analytics}};try{cloudbase.registerComponent(Zs)}catch(e){}!function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined"}(Ys||(Ys={}));var Xs,Qs,ea="Number",ta="Object",na="Array",ra="GeoPoint",oa="GeoLineString",ia="GeoPolygon",sa="GeoMultiPoint",aa="GeoMultiLineString",ca="GeoMultiPolygon",ua="Date",fa="ServerDate",la="BsonDate",ha=["desc","asc"],pa=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(Xs||(Xs={})),(Js={})[Xs.eq]="$eq",Js[Xs.lt]="$lt",Js[Xs.lte]="$lte",Js[Xs.gt]="$gt",Js[Xs.gte]="$gte",function(e){e.WHERE="WHERE",e.DOC="DOC"}(Qs||(Qs={}));var da=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)}}(),ya=[],ga={},va=function(e){function t(t,n){if(n!==ga)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return da(t,e),t.for=function(e){for(var n=0,r=ya.length;n<r;n++)if(ya[n].target===e)return ya[n].instance;var o=new t(e,ga);return ya.push({target:e,instance:o}),o},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),ma=va,_a=ma.for("UNSET_FIELD_NAME"),ba=ma.for("UPDATE_COMMAND"),wa=ma.for("QUERY_COMMAND"),Ea=ma.for("LOGIC_COMMAND"),Sa=ma.for("GEO_POINT"),Ia=ma.for("SYMBOL_GEO_LINE_STRING"),Oa=ma.for("SYMBOL_GEO_POLYGON"),Aa=ma.for("SYMBOL_GEO_MULTI_POINT"),Na=ma.for("SYMBOL_GEO_MULTI_LINE_STRING"),Ta=ma.for("SYMBOL_GEO_MULTI_POLYGON"),Ra=ma.for("SERVER_DATE"),Pa=ma.for("REGEXP"),xa=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 Ra},enumerable:!0,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function La(e){return new xa(e)}var ka,Ca=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},Da=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 ra:o=new Ha(i.coordinates[0],i.coordinates[1]);break;case oa:o=new Ka(i.coordinates.map((function(e){return new Ha(e[0],e[1])})));break;case ia:o=new Ja(i.coordinates.map((function(e){return new Ka(e.map((function(e){var t=Ca(e,2),n=t[0],r=t[1];return new Ha(n,r)})))})));break;case sa:o=new za(i.coordinates.map((function(e){return new Ha(e[0],e[1])})));break;case aa:o=new Xa(i.coordinates.map((function(e){return new Ka(e.map((function(e){var t=Ca(e,2),n=t[0],r=t[1];return new Ha(n,r)})))})));break;case ca:o=new ec(i.coordinates.map((function(e){return new Ja(e.map((function(e){return new Ka(e.map((function(e){var t=Ca(e,2),n=t[0],r=t[1];return new Ha(n,r)})))})))})));break;case ua:o=new Date(1e3*i.$timestamp);break;case ta:case na:o=e.formatField(i);break;case fa: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===ua)return la;if(t===ta){if(e instanceof Ha)return ra;if(e instanceof Date)return ua;if(e instanceof xa)return fa;e.$timestamp?t=ua:e.$date?t=fa:Ha.validate(e)?t=ra:Ka.validate(e)?t=oa:Ja.validate(e)?t=ia:za.validate(e)?t=sa:Xa.validate(e)?t=aa:ec.validate(e)&&(t=ca)}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}(),ja=function(){function e(){}return e.isGeopoint=function(e,t){if(Da.whichType(t)!==ea)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+Ys.IntergerError);return!0},e.isFieldOrder=function(e){if(-1===ha.indexOf(e))throw new Error(Ys.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===pa.indexOf(e))throw new Error(Ys.OpStrError);return!0},e.isCollName=function(e){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e))throw new Error(Ys.CollNameError);return!0},e.isDocID=function(e){if(!/^([a-fA-F0-9]){24}$/.test(e))throw new Error(Ys.DocIDError);return!0},e}(),Ua=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},Ma=function(e){return"object"===Ua(e)},qa=function(e){return"number"===Ua(e)},Wa=function(e){return Array.isArray(e)},Fa=function(e){return"date"===Ua(e)},Ba=function(e){return"regexp"===Ua(e)},$a=function(e){return e&&e._internalType instanceof va},Ha=function(){function e(e,t){ja.isGeopoint("longitude",e),ja.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&&Wa(e.coordinates)&&ja.isGeopoint("longitude",e.coordinates[0])&&ja.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Sa},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(!Wa(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 Ha))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||!Wa(e.coordinates))return!1;try{for(var r=Ga(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!qa(i[0])||!qa(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 Ia},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(!Wa(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 Ka))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]");if(!Ka.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||!Wa(e.coordinates))return!1;try{for(var i=Va(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,Va(a)),u=c.next();!u.done;u=c.next()){var f=u.value;if(!qa(f[0])||!qa(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 Ta},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(!Wa(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 Ha))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||!Wa(e.coordinates))return!1;try{for(var r=Ya(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!qa(i[0])||!qa(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 Aa},enumerable:!0,configurable:!0}),e}(),Za=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.")},Xa=function(){function e(e){if(!Wa(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 Ka))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||!Wa(e.coordinates))return!1;try{for(var i=Za(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var c=(r=void 0,Za(a)),u=c.next();!u.done;u=c.next()){var f=u.value;if(!qa(f[0])||!qa(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 Na},enumerable:!0,configurable:!0}),e}(),Qa=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.")},ec=function(){function e(e){var t,n;if(!Wa(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=Qa(e),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof Ja))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||!Wa(e.coordinates))return!1;try{for(var a=Qa(e.coordinates),c=a.next();!c.done;c=a.next()){var u=c.value;try{for(var f=(r=void 0,Qa(u)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,Qa(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!qa(y[0])||!qa(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 Oa},enumerable:!0,configurable:!0}),e}(),tc=Object.freeze({__proto__:null,LineString:Ka,MultiLineString:Xa,MultiPoint:za,MultiPolygon:ec,Point:Ha,Polygon:Ja}),nc=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"}(ka||(ka={}));var rc,oc=function(){function e(e,t,n){this._internalType=ba,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||_a}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function ic(e){return e&&e instanceof oc&&e._internalType===ba}!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(rc||(rc={}));var sc=function(){function e(e,t,n){if(this._internalType=Ea,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||_a,this.fieldName!==_a)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var r=0,o=t.length;r<o;r++){(ac(i=t[r])||lc(i))&&(t[r]=i._setFieldName(this.fieldName))}}else{var i;(ac(i=t)||lc(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(rc.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(rc.OR,t,this.fieldName)},e}();function ac(e){return e&&e instanceof sc&&e._internalType===Ea}var cc,uc=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"}(cc||(cc={}));var fc=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.operator=t,o._internalType=wa,o}return uc(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case cc.IN:case cc.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(cc.EQ,[e],this.fieldName);return this.and(n)},t.prototype.neq=function(e){var n=new t(cc.NEQ,[e],this.fieldName);return this.and(n)},t.prototype.gt=function(e){var n=new t(cc.GT,[e],this.fieldName);return this.and(n)},t.prototype.gte=function(e){var n=new t(cc.GTE,[e],this.fieldName);return this.and(n)},t.prototype.lt=function(e){var n=new t(cc.LT,[e],this.fieldName);return this.and(n)},t.prototype.lte=function(e){var n=new t(cc.LTE,[e],this.fieldName);return this.and(n)},t.prototype.in=function(e){var n=new t(cc.IN,e,this.fieldName);return this.and(n)},t.prototype.nin=function(e){var n=new t(cc.NIN,e,this.fieldName);return this.and(n)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof Ha))throw new TypeError('"geometry" must be of type Point. Received type '+typeof e.geometry);if(void 0!==e.maxDistance&&!qa(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof e.maxDistance);if(void 0!==e.minDistance&&!qa(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof e.minDistance);var n=new t(cc.GEO_NEAR,[e],this.fieldName);return this.and(n)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof ec||e.geometry instanceof Ja))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof e.geometry);var n=new t(cc.GEO_WITHIN,[e],this.fieldName);return this.and(n)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof Ha||e.geometry instanceof Ka||e.geometry instanceof Ja||e.geometry instanceof za||e.geometry instanceof Xa||e.geometry instanceof ec))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof e.geometry);var n=new t(cc.GEO_INTERSECTS,[e],this.fieldName);return this.and(n)},t}(sc);function lc(e){return e&&e instanceof fc&&e._internalType===wa}function hc(e){return lc(e)}var pc={};for(var dc in cc)pc[dc]="$"+dc;for(var dc in rc)pc[dc]="$"+dc;for(var dc in ka)pc[dc]="$"+dc;function yc(e){return pc[e]||"$"+e}pc[cc.NEQ]="$ne",pc[ka.REMOVE]="$unset",pc[ka.SHIFT]="$pop",pc[ka.UNSHIFT]="$push";var gc=function(){return gc=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},gc.apply(this,arguments)},vc=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},mc=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(vc(arguments[t]));return e};function _c(e){return bc(e,[e])}function bc(e,t){if(!$a(e)){if(Fa(e))return{$date:+e};if(Ba(e))return{$regex:e.source,$options:e.flags};if(Wa(e))return e.map((function(e){if(t.indexOf(e)>-1)throw new Error("Cannot convert circular structure to JSON");return bc(e,mc(t,[e]))}));if(Ma(e)){var n=gc({},e);for(var r in n){if(t.indexOf(n[r])>-1)throw new Error("Cannot convert circular structure to JSON");n[r]=bc(n[r],mc(t,[n[r]]))}return n}return e}switch(e._internalType){case Sa:return e.toJSON();case Ra:case Pa:return e.parse();default:return e.toJSON?e.toJSON():e}}var wc=function(){return wc=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},wc.apply(this,arguments)},Ec=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},Sc=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ec(arguments[t]));return e};function Ic(e,t,n,r){var o=wc({},e);for(var i in e)if(!/^\$/.test(i)){var s=e[i];if(s&&Ma(s)&&!t(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Ic(s,t,Sc(n,[i]),Sc(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 Oc(e){return Ic(e,Nc,[],[e])}function Ac(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Wa(e[r])?e[r].push(t[r]):Ma(e[r])?Ma(t[r])?Object.assign(e[r],t[r]):(console.warn("unmergable condition, query is object but condition is "+Ua(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+Ua(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]}function Nc(e){return $a(e)||Fa(e)||Ba(e)}function Tc(e){return _c(e)}var Rc=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.prototype.encodeUpdate=function(e){return ic(e)?this.encodeUpdateCommand(e):"object"===Ua(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===_a)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case ka.PUSH:case ka.PULL:case ka.PULL_ALL:case ka.POP:case ka.SHIFT:case ka.UNSHIFT:case ka.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,n,r,o,i=yc(e.operator);return e.operator===ka.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=yc(e.operator);switch(e.operator){case ka.PUSH:var h=void 0;return h=Wa(e.operands)?{$each:e.operands.map(Tc)}:e.operands,(t={})[l]=((n={})[e.fieldName]=h,n),t;case ka.UNSHIFT:h={$each:e.operands.map(Tc),$position:0};return(r={})[l]=((o={})[e.fieldName]=h,o),r;case ka.POP:return(i={})[l]=((s={})[e.fieldName]=1,s),i;case ka.SHIFT:return(a={})[l]=((c={})[e.fieldName]=-1,c),a;default:return(u={})[l]=((f={})[e.fieldName]=Tc(e.operands),f),u}},e.prototype.encodeUpdateObject=function(e){var t=Oc(e);for(var n in t)if(!/^\$/.test(n)){var r=t[n];if(ic(r)){t[n]=r._setFieldName(n),Ac(t,this.encodeUpdateCommand(t[n]),n)}else{t[n]=r=Tc(r);var o=new oc(ka.SET,[r],n);Ac(t,this.encodeUpdateCommand(o),n)}}return t},e}(),Pc={};function xc(e){if(!Ef.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return Pc[t]||(Pc[t]=new Ef.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new Ef.reqClass(e.config)}}})),Pc[t]}var Lc=function(){return Lc=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},Lc.apply(this,arguments)},kc=function(){function e(e,t,n,r){var o=this;void 0===r&&(r={}),this.watch=function(e){return xc(o._db).watch(Lc(Lc({},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 Ef.reqClass(this._db.config),this.projection=r}return e.prototype.create=function(e,t){t=t||nc();var n={collectionName:this._coll,data:_c(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||nc(),!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 oc?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:Qs.DOC,data:_c(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||nc(),!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:Rc.encode(e),query:n,queryType:Qs.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||nc();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:Qs.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||nc();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:Qs.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=Da.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}(),Cc=function(){function e(){}return e.encode=function(e){return(new Dc).encodeQuery(e)},e}(),Dc=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var n;return Nc(e)?ac(e)?this.encodeLogicCommand(e):lc(e)?this.encodeQueryCommand(e):((n={})[t]=this.encodeQueryObject(e),n):Ma(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 rc.NOR:case rc.AND:case rc.OR:var u=yc(e.operator),f=e.operands.map((function(t){return c.encodeQuery(t,e.fieldName)}));return(t={})[u]=f,t;case rc.NOT:u=yc(e.operator);var l=e.operands[0];if(Ba(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=yc(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 hc(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,n,r,o,i,s,a,c,u;if(e.fieldName===_a)throw new Error("Cannot encode a comparison command with unset field name");var f=yc(e.operator);switch(e.operator){case cc.EQ:case cc.NEQ:case cc.LT:case cc.LTE:case cc.GT:case cc.GTE:case cc.ELEM_MATCH:case cc.EXISTS:case cc.SIZE:case cc.MOD:return(t={})[e.fieldName]=((n={})[f]=Tc(e.operands[0]),n),t;case cc.IN:case cc.NIN:case cc.ALL:return(r={})[e.fieldName]=((o={})[f]=Tc(e.operands),o),r;case cc.GEO_NEAR:var l=e.operands[0];return(i={})[e.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case cc.GEO_WITHIN:l=e.operands[0];return(s={})[e.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case cc.GEO_INTERSECTS:l=e.operands[0];return(a={})[e.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(c={})[e.fieldName]=((u={})[f]=Tc(e.operands[0]),u),c}},e.prototype.encodeQueryObject=function(e){var t=Oc(e);for(var n in t){var r=t[n];if(ac(r)){t[n]=r._setFieldName(n);var o=this.encodeLogicCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else if(hc(r)){t[n]=r._setFieldName(n);o=this.encodeComparisonCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else Nc(r)&&(t[n]=Tc(r))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Wa(e[r])?e[r]=e[r].concat(t[r]):Ma(e[r])?Ma(t[r])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is "+Ua(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+Ua(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]},e}(),jc=function(){return jc=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},jc.apply(this,arguments)},Uc=function(){function e(e,t,n,r,o){var i=this;this.watch=function(e){return xc(i._db).watch(jc(jc({},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 Ef.reqClass(this._db.config)}return e.prototype.get=function(e){e=e||nc();var t=[];this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)}));var n={collectionName:this._coll,queryType:Qs.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:Da.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||nc();var t={collectionName:this._coll,queryType:Qs.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(Ys.QueryParamTypeError);var n=Object.keys(t),r=n.some((function(e){return void 0!==t[e]}));if(n.length&&!r)throw Error(Ys.QueryParamValueError);return new e(this._db,this._coll,Cc.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,n){ja.isFieldPath(t),ja.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){ja.isInteger("limit",t);var n=jc({},this._queryOptions);return n.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.skip=function(t){ja.isInteger("offset",t);var n=jc({},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||nc(),!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:Qs.WHERE,multi:!0,merge:!0,upsert:!1,data:Rc.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=jc({},this._queryOptions);return r.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.remove=function(e){e=e||nc(),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:Cc.encode(this._fieldFilters),queryType:Qs.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}(),Mc=function(e,t){return Mc=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])},Mc(e,t)};function qc(e,t){function n(){this.constructor=e}Mc(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Wc=function(e){function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return qc(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),t}(Error),Fc=function(e){function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return qc(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),t}(TypeError);function Bc(e){return e&&e.Math==Math&&e}function $c(){return Bc("object"==typeof globalThis&&globalThis)||Bc("object"==typeof window&&window)||Bc("object"==typeof self&&self)||Bc("object"==typeof global&&global)||Function("return this")()}var Hc=function(t){var n,r="object"==typeof(n=$c()).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},Gc=function(){var e=void 0;try{e=require("crypto").randomBytes}catch(e){}return e||Hc}();function Kc(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)}function Vc(e){return"object"==typeof e&&null!==e}function Jc(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 Yc(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 Fc("Must use either Buffer or TypedArray")}var zc=/^(?:[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,Zc=function(e){return"string"==typeof e&&zc.test(e)},Xc=function(t){if(!Zc(t))throw new Fc('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")},Qc=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")},eu=Math.pow(2,53),tu=-Math.pow(2,53),nu=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 Fc("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=Yc(n),this.position=this.buffer.byteLength)}return t.prototype.put=function(n){if("string"==typeof n&&1!==n.length)throw new Fc("only accepts single character String");if("number"!=typeof n&&1!==n.length)throw new Fc("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 Fc("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(Yc(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 ru(this.buffer.slice(0,this.position));throw new Wc('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=Xc(n.$uuid)),!o)throw new Fc("Unexpected Binary Extended JSON format ".concat(JSON.stringify(n)));return 4===i?new ru(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(nu.prototype,"_bsontype",{value:"Binary"});var ru=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=Yc(r);else{if("string"!=typeof r)throw new Fc("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=Xc(r)}return(s=t.call(this,o,4)||this).__id=i,s}return qc(n,t),Object.defineProperty(n.prototype,"id",{get:function(){return this.buffer},set:function(e){this.buffer=e,n.cacheHexString&&(this.__id=Qc(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=Qc(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 nu(this.id,nu.SUBTYPE_UUID)},n.generate=function(){var t=Gc(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?Zc(e):!!Kc(e)&&(16===e.length&&(64==(240&e[6])&&128==(128&e[8])))))},n.createFromHexString=function(e){return new n(Xc(e))},n.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},n.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},n}(nu),ou=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(ou.prototype,"_bsontype",{value:"Code"});var iu=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(iu.prototype,"_bsontype",{value:"DBRef"});var su=void 0;try{su=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(Js){}var au=4294967296,cu=0x10000000000000000,uu=cu/2,fu={},lu={},hu=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=lu[t])?o:(r=e.fromBits(t,(0|t)<0?-1:0,!0),i&&(lu[t]=r),r):(i=-128<=(t|=0)&&t<128)&&(o=fu[t])?o:(r=e.fromBits(t,t<0?-1:0,!1),i&&(fu[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>=cu)return e.MAX_UNSIGNED_VALUE}else{if(t<=-uu)return e.MIN_VALUE;if(t+1>=uu)return e.MAX_VALUE}return t<0?e.fromNumber(-t,n).neg():e.fromBits(t%au|0,t/au|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 Vc(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(su){if(!this.unsigned&&-2147483648===this.high&&-1===t.low&&-1===t.high)return this;var n=(this.unsigned?su.div_u:su.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(n,su.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)),su){var n=(this.unsigned?su.rem_u:su.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(n,su.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)),su){var n=su.mul(this.low,this.high,t.low,t.high);return e.fromBits(n,su.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)*au+(this.low>>>0):this.high*au+(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(hu.prototype,"__isLong__",{value:!0}),Object.defineProperty(hu.prototype,"_bsontype",{value:"Long"});var pu=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,du=/^(\+|-)?(Infinity|inf)$/i,yu=/^(\+|-)?NaN$/i,gu=6111,vu=-6176,mu=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),_u=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),bu=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),wu=/^([-+])?(\d+)?$/;function Eu(e){return!isNaN(parseInt(e,10))}function Su(e){var t=hu.fromNumber(1e9),n=hu.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 hu(e.parts[r],0)),e.parts[r]=n.div(t).low,n=n.modulo(t);return{quotient:e,rem:n}}function Iu(e,t){throw new Fc('"'.concat(e,'" is not a valid Decimal128 string - ').concat(t))}var Ou=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!Kc(e))throw new Fc("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new Fc("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 hu(0,0),b=new hu(0,0),w=0;if(n.length>=7e3)throw new Fc(n+" not a valid Decimal128 string");var E=n.match(pu),S=n.match(du),I=n.match(yu);if(!E&&!S&&!I||0===n.length)throw new Fc(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&&Iu(n,"missing exponent power"),A&&void 0===O&&Iu(n,"missing exponent base"),void 0===A&&(N||T)&&Iu(n,"missing e before exponent")}if("+"!==n[w]&&"-"!==n[w]||(o="-"===n[w++]),!Eu(n[w])&&"."!==n[w]){if("i"===n[w]||"I"===n[w])return new t(e.from(o?_u:bu));if("N"===n[w])return new t(e.from(mu))}for(;Eu(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&&Iu(n,"contains multiple periods"),i=!0,w+=1);if(i&&!c)throw new Fc(n+" not a valid Decimal128 string");if("e"===n[w]||"E"===n[w]){var R=n.substr(++w).match(wu);if(!R||!R[2])return new t(e.from(mu));v=parseInt(R[0],10),w+=R[0].length}if(n[w])return new t(e.from(mu));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=vu:v-=f;v>gu;){if((g+=1)-y>34){if(h.join("").match(/^0+$/)){v=gu;break}Iu(n,"overflow")}v-=1}for(;v<vu||p<u;){if(0===g&&a<p){v=vu,a=0;break}if(p<u?u-=1:g-=1,v<gu)v+=1;else{if(h.join("").match(/^0+$/)){v=gu;break}Iu(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 k=g;k>=0;k--)if(++h[k]>9&&(h[k]=0,0===k)){if(!(v<gu))return new t(e.from(o?_u:bu));v+=1,h[k]=1}}if(_=hu.fromNumber(0),b=hu.fromNumber(0),0===a)_=hu.fromNumber(0),b=hu.fromNumber(0);else if(g-y<17){k=y;for(b=hu.fromNumber(h[k++]),_=new hu(0,0);k<=g;k++)b=(b=b.multiply(hu.fromNumber(10))).add(hu.fromNumber(h[k]))}else{k=y;for(_=hu.fromNumber(h[k++]);k<=g-17;k++)_=(_=_.multiply(hu.fromNumber(10))).add(hu.fromNumber(h[k]));for(b=hu.fromNumber(h[k++]);k<=g;k++)b=(b=b.multiply(hu.fromNumber(10))).add(hu.fromNumber(h[k]))}var C,D,j,U,M=function(e,t){if(!e&&!t)return{high:hu.fromNumber(0),low:hu.fromNumber(0)};var n=e.shiftRightUnsigned(32),r=new hu(e.getLowBits(),0),o=t.shiftRightUnsigned(32),i=new hu(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 hu(a.getLowBits(),0).add(c).add(u.shiftRightUnsigned(32)),{high:s=s.add(a.shiftRightUnsigned(32)),low:u=a.shiftLeft(32).add(new hu(u.getLowBits(),0))}}(_,hu.fromString("100000000000000000"));M.low=M.low.add(b),C=M.low,D=b,j=C.high>>>0,U=D.high>>>0,(j<U||j===U&&C.low>>>0<D.low>>>0)&&(M.high=M.high.add(hu.fromNumber(1))),r=v+6176;var q={low:hu.fromNumber(0),high:hu.fromNumber(0)};M.high.shiftRightUnsigned(49).and(hu.fromNumber(1)).equals(hu.fromNumber(1))?(q.high=q.high.or(hu.fromNumber(3).shiftLeft(61)),q.high=q.high.or(hu.fromNumber(r).and(hu.fromNumber(16383).shiftLeft(47))),q.high=q.high.or(M.high.and(hu.fromNumber(0x7fffffffffff)))):(q.high=q.high.or(hu.fromNumber(16383&r).shiftLeft(49)),q.high=q.high.or(M.high.and(hu.fromNumber(562949953421311)))),q.low=M.low,o&&(q.high=q.high.or(hu.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 hu(h,p),high:new hu(d,y)}.high.lessThan(hu.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,_=Su(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(Ou.prototype,"_bsontype",{value:"Decimal128"});var Au=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(Au.prototype,"_bsontype",{value:"Double"});var Nu=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(Nu.prototype,"_bsontype",{value:"Int32"});var Tu=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(Tu.prototype,"_bsontype",{value:"MaxKey"});var Ru=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(Ru.prototype,"_bsontype",{value:"MinKey"});var Pu=new RegExp("^[0-9a-fA-F]{24}$"),xu=null,Lu=Symbol("id"),ku=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 Fc("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[Lu]=t.generate("number"==typeof r?r:void 0);else if(ArrayBuffer.isView(r)&&12===r.byteLength)this[Lu]=r instanceof e?r:Yc(r);else{if("string"!=typeof r)throw new Fc("Argument passed in does not match the accepted types");if(12===r.length){var o=e.from(r);if(12!==o.byteLength)throw new Fc("Argument passed in must be a string of 12 bytes");this[Lu]=o}else{if(24!==r.length||!Pu.test(r))throw new Fc("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[Lu]=e.from(r,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[Lu]},set:function(e){this[Lu]=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===xu&&(xu=Gc(5)),o[4]=xu[0],o[5]=xu[1],o[6]=xu[2],o[7]=xu[3],o[8]=xu[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[Lu][11]===n[Lu][11]&&this[Lu].equals(n[Lu]);if("string"==typeof n&&t.isValid(n)&&12===n.length&&Kc(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 Fc("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(ku.prototype,"generate",{value:Jc((function(e){return ku.generate(e)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(ku.prototype,"getInc",{value:Jc((function(){return ku.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(ku.prototype,"get_inc",{value:Jc((function(){return ku.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(ku,"get_inc",{value:Jc((function(){return ku.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(ku.prototype,"_bsontype",{value:"ObjectID"});var Cu=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 Wc("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new Wc("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 Wc("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 Fc("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(t)))},e}();Object.defineProperty(Cu.prototype,"_bsontype",{value:"BSONRegExp"});var Du=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(Du.prototype,"_bsontype",{value:"Symbol"});var ju=function(e){function t(n,r){var o=this;return o instanceof t?(o=hu.isLong(n)?e.call(this,n.low,n.high,!0)||this:Vc(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 qc(t,e),t.prototype.toJSON=function(){return{$timestamp:this.toString()}},t.fromInt=function(e){return new t(hu.fromInt(e,!0))},t.fromNumber=function(e){return new t(hu.fromNumber(e,!0))},t.fromBits=function(e,n){return new t(e,n)},t.fromString=function(e,n){return new t(hu.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=hu.MAX_UNSIGNED_VALUE,t}(hu);var Uu=2147483647,Mu=-2147483648,qu=0x8000000000000000,Wu=-0x8000000000000000,Fu={$oid:ku,$binary:nu,$uuid:nu,$symbol:Du,$numberInt:Nu,$numberDecimal:Ou,$numberDouble:Au,$numberLong:hu,$minKey:Ru,$maxKey:Tu,$regex:Cu,$regularExpression:Cu,$timestamp:ju};function Bu(e,t){if(void 0===t&&(t={}),"number"==typeof e){if(t.relaxed||t.legacy)return e;if(Math.floor(e)===e){if(e>=Mu&&e<=Uu)return new Nu(e);if(e>=Wu&&e<=qu)return hu.fromNumber(e)}return new Au(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=Fu[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)):hu.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=Bu(e.$scope)),ou.fromExtendedJSON(e)}if(function(e){return Vc(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 iu)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 iu.fromExtendedJSON(c)}return e}function $u(e){var t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function Hu(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 Fc("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 Hu(e,t)}finally{t.seenObjects.pop()}}))}(e,t);if(void 0===e)return null;if(e instanceof Date||Vc(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:$u(e)}:t.relaxed&&l?{$date:$u(e)}:{$date:{$numberLong:e.getTime().toString()}}}var h;if(!("number"!=typeof e||t.relaxed&&isFinite(e))){if(Math.floor(e)===e){var p=e>=Wu&&e<=qu;if(e>=Mu&&e<=Uu)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 Cu(e.source,d).toExtendedJSON(t)}return null!=e&&"object"==typeof e?function(e,t){if(null==e||"object"!=typeof e)throw new Wc("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=Hu(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 Vc(e)&&Reflect.has(e,"_bsontype")&&"string"==typeof e._bsontype}(e)){var s=e;if("function"!=typeof s.toExtendedJSON){var a=Ku[e._bsontype];if(!a)throw new Fc("Unrecognized or invalid _bsontype: "+e._bsontype);s=a(s)}return"Code"===n&&s.scope?s=new ou(s.code,Hu(s.scope,t)):"DBRef"===n&&s.oid&&(s=new iu(Hu(s.collection,t),Hu(s.oid,t),Hu(s.db,t),Hu(s.fields,t))),s.toExtendedJSON(t)}throw new Wc("_bsontype must be a string, but was: "+typeof n)}(e,t):e}var Gu,Ku={Binary:function(e){return new nu(e.value(),e.sub_type)},Code:function(e){return new ou(e.code,e.scope)},DBRef:function(e){return new iu(e.collection||e.namespace,e.oid,e.db,e.fields)},Decimal128:function(e){return new Ou(e.bytes)},Double:function(e){return new Au(e.value)},Int32:function(e){return new Nu(e.value)},Long:function(e){return hu.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 Tu},MinKey:function(){return new Ru},ObjectID:function(e){return new ku(e)},ObjectId:function(e){return new ku(e)},BSONRegExp:function(e){return new Cu(e.pattern,e.options)},Symbol:function(e){return new Du(e.value)},Timestamp:function(e){return ju.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 Wc("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(e)));return Bu(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=Hu(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)}}(Gu||(Gu={}));var Vu=$c();Vu.Map?Vu.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})}(),hu.fromNumber(eu),hu.fromNumber(tu);var Ju=new Uint8Array(8);new DataView(Ju.buffer,Ju.byteOffset,Ju.byteLength);e.alloc(17825792);var Yu=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())}))},zu=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])}}},Zu=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=new Ef.reqClass(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return Yu(this,void 0,void 0,(function(){var e;return zu(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(Gu.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",Cc.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}(),Xu=Zu,Qu=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)}}(),ef=function(e){function t(t,n){return e.call(this,t,n)||this}return Qu(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 kc(this._db,this._coll,e)},t.prototype.add=function(e,t){return new kc(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new Xu(this._db,this._coll)},t}(Uc),tf={eq:function(e){return new fc(cc.EQ,[e])},neq:function(e){return new fc(cc.NEQ,[e])},lt:function(e){return new fc(cc.LT,[e])},lte:function(e){return new fc(cc.LTE,[e])},gt:function(e){return new fc(cc.GT,[e])},gte:function(e){return new fc(cc.GTE,[e])},in:function(e){return new fc(cc.IN,e)},nin:function(e){return new fc(cc.NIN,e)},all:function(e){return new fc(cc.ALL,e)},elemMatch:function(e){return new fc(cc.ELEM_MATCH,[e])},exists:function(e){return new fc(cc.EXISTS,[e])},size:function(e){return new fc(cc.SIZE,[e])},mod:function(e){return new fc(cc.MOD,[e])},geoNear:function(e){return new fc(cc.GEO_NEAR,[e])},geoWithin:function(e){return new fc(cc.GEO_WITHIN,[e])},geoIntersects:function(e){return new fc(cc.GEO_INTERSECTS,[e])},and:function(){var e=Wa(arguments[0])?arguments[0]:Array.from(arguments);return new sc(rc.AND,e)},nor:function(){var e=Wa(arguments[0])?arguments[0]:Array.from(arguments);return new sc(rc.NOR,e)},or:function(){var e=Wa(arguments[0])?arguments[0]:Array.from(arguments);return new sc(rc.OR,e)},not:function(){var e=Wa(arguments[0])?arguments[0]:Array.from(arguments);return new sc(rc.NOT,e)},set:function(e){return new oc(ka.SET,[e])},remove:function(){return new oc(ka.REMOVE,[])},inc:function(e){return new oc(ka.INC,[e])},mul:function(e){return new oc(ka.MUL,[e])},push:function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(Ma(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=Wa(t[0])?t[0]:Array.from(t);return new oc(ka.PUSH,e)},pull:function(e){return new oc(ka.PULL,e)},pullAll:function(e){return new oc(ka.PULL_ALL,e)},pop:function(){return new oc(ka.POP,[])},shift:function(){return new oc(ka.SHIFT,[])},unshift:function(){var e=Wa(arguments[0])?arguments[0]:Array.from(arguments);return new oc(ka.UNSHIFT,e)},addToSet:function(e){return new oc(ka.ADD_TO_SET,e)},rename:function(e){return new oc(ka.RENAME,[e])},bit:function(e){return new oc(ka.BIT,[e])},max:function(e){return new oc(ka.MAX,[e])},min:function(e){return new oc(ka.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===Ua(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new Xu},abs:function(e){return new nf("abs",e)},add:function(e){return new nf("add",e)},ceil:function(e){return new nf("ceil",e)},divide:function(e){return new nf("divide",e)},exp:function(e){return new nf("exp",e)},floor:function(e){return new nf("floor",e)},ln:function(e){return new nf("ln",e)},log:function(e){return new nf("log",e)},log10:function(e){return new nf("log10",e)},mod:function(e){return new nf("mod",e)},multiply:function(e){return new nf("multiply",e)},pow:function(e){return new nf("pow",e)},sqrt:function(e){return new nf("sqrt",e)},subtract:function(e){return new nf("subtract",e)},trunc:function(e){return new nf("trunc",e)},arrayElemAt:function(e){return new nf("arrayElemAt",e)},arrayToObject:function(e){return new nf("arrayToObject",e)},concatArrays:function(e){return new nf("concatArrays",e)},filter:function(e){return new nf("filter",e)},in:function(e){return new nf("in",e)},indexOfArray:function(e){return new nf("indexOfArray",e)},isArray:function(e){return new nf("isArray",e)},map:function(e){return new nf("map",e)},range:function(e){return new nf("range",e)},reduce:function(e){return new nf("reduce",e)},reverseArray:function(e){return new nf("reverseArray",e)},size:function(e){return new nf("size",e)},slice:function(e){return new nf("slice",e)},zip:function(e){return new nf("zip",e)},and:function(e){return new nf("and",e)},not:function(e){return new nf("not",e)},or:function(e){return new nf("or",e)},cmp:function(e){return new nf("cmp",e)},eq:function(e){return new nf("eq",e)},gt:function(e){return new nf("gt",e)},gte:function(e){return new nf("gte",e)},lt:function(e){return new nf("lt",e)},lte:function(e){return new nf("lte",e)},neq:function(e){return new nf("ne",e)},cond:function(e){return new nf("cond",e)},ifNull:function(e){return new nf("ifNull",e)},switch:function(e){return new nf("switch",e)},dateFromParts:function(e){return new nf("dateFromParts",e)},dateFromString:function(e){return new nf("dateFromString",e)},dayOfMonth:function(e){return new nf("dayOfMonth",e)},dayOfWeek:function(e){return new nf("dayOfWeek",e)},dayOfYear:function(e){return new nf("dayOfYear",e)},isoDayOfWeek:function(e){return new nf("isoDayOfWeek",e)},isoWeek:function(e){return new nf("isoWeek",e)},isoWeekYear:function(e){return new nf("isoWeekYear",e)},millisecond:function(e){return new nf("millisecond",e)},minute:function(e){return new nf("minute",e)},month:function(e){return new nf("month",e)},second:function(e){return new nf("second",e)},hour:function(e){return new nf("hour",e)},week:function(e){return new nf("week",e)},year:function(e){return new nf("year",e)},literal:function(e){return new nf("literal",e)},mergeObjects:function(e){return new nf("mergeObjects",e)},objectToArray:function(e){return new nf("objectToArray",e)},allElementsTrue:function(e){return new nf("allElementsTrue",e)},anyElementTrue:function(e){return new nf("anyElementTrue",e)},setDifference:function(e){return new nf("setDifference",e)},setEquals:function(e){return new nf("setEquals",e)},setIntersection:function(e){return new nf("setIntersection",e)},setIsSubset:function(e){return new nf("setIsSubset",e)},setUnion:function(e){return new nf("setUnion",e)},concat:function(e){return new nf("concat",e)},dateToString:function(e){return new nf("dateToString",e)},indexOfBytes:function(e){return new nf("indexOfBytes",e)},indexOfCP:function(e){return new nf("indexOfCP",e)},split:function(e){return new nf("split",e)},strLenBytes:function(e){return new nf("strLenBytes",e)},strLenCP:function(e){return new nf("strLenCP",e)},strcasecmp:function(e){return new nf("strcasecmp",e)},substr:function(e){return new nf("substr",e)},substrBytes:function(e){return new nf("substrBytes",e)},substrCP:function(e){return new nf("substrCP",e)},toLower:function(e){return new nf("toLower",e)},toUpper:function(e){return new nf("toUpper",e)},meta:function(e){return new nf("meta",e)},addToSet:function(e){return new nf("addToSet",e)},avg:function(e){return new nf("avg",e)},first:function(e){return new nf("first",e)},last:function(e){return new nf("last",e)},max:function(e){return new nf("max",e)},min:function(e){return new nf("min",e)},push:function(e){return new nf("push",e)},stdDevPop:function(e){return new nf("stdDevPop",e)},stdDevSamp:function(e){return new nf("stdDevSamp",e)},sum:function(e){return new nf("sum",e)},let:function(e){return new nf("let",e)}},project:{slice:function(e){return new rf("slice",e)},elemMatch:function(e){return new rf("elemMatch",e)}}},nf=function(e,t){this["$"+e]=t},rf=function(e,t){this["$"+e]=t},of=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 Pa},enumerable:!0,configurable:!0}),e}();function sf(e){return new of(e)}var af={code:"INSERT_DOC_FAIL",message:"insert document failed"},cf={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},uf=function(){return uf=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},uf.apply(this,arguments)},ff=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())}))},lf=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])}}},hf="database.updateDocInTransaction",pf=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 ff(this,void 0,void 0,(function(){var t,n,r,o;return lf(this,(function(i){switch(i.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:Gu.stringify(_c(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=Gu.parse(n.inserted),1==(o=Gu.parse(n.ok))&&1==r)return[2,uf(uf({},n),{ok:o,inserted:r})];throw new Error(af.message)}}))}))},e.prototype.get=function(){return ff(this,void 0,void 0,(function(){var e,t;return lf(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?Da.formatField(Gu.parse(t.data)):Gu.parse(t.data),requestId:t.requestId}]}}))}))},e.prototype.set=function(e){return ff(this,void 0,void 0,(function(){var t,n;return lf(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Gu.stringify(_c(e),{relaxed:!1}),upsert:!0},[4,this._request.send(hf,t)];case 1:if((n=r.sent()).code)throw n;return[2,uf(uf({},n),{updated:Gu.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},e.prototype.update=function(e){return ff(this,void 0,void 0,(function(){var t,n;return lf(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Gu.stringify(Rc.encode(e),{relaxed:!1})},[4,this._request.send(hf,t)];case 1:if((n=r.sent()).code)throw n;return[2,uf(uf({},n),{updated:Gu.parse(n.updated)})]}}))}))},e.prototype.delete=function(){return ff(this,void 0,void 0,(function(){var e,t;return lf(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,uf(uf({},t),{deleted:Gu.parse(t.deleted)})]}}))}))},e}(),df=function(e,t){this._coll=t,this._transaction=e},yf=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)}}(),gf=function(e){function t(t,n){return e.call(this,t,n)||this}return yf(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 pf(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new pf(this._transaction,this._coll,t).create(e)},t}(df),vf=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())}))},mf=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])}}},_f=function(){function e(e){this._db=e,this._request=new Ef.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return vf(this,void 0,void 0,(function(){var e;return mf(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 gf(this,e)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return vf(this,void 0,void 0,(function(){var e,t;return mf(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 vf(this,void 0,void 0,(function(){var t,n;return mf(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 bf(){return vf(this,void 0,void 0,(function(){var e;return mf(this,(function(t){switch(t.label){case 0:return[4,(e=new _f(this)).init()];case 1:return t.sent(),[2,e]}}))}))}function wf(e,t){return void 0===t&&(t=3),vf(this,void 0,void 0,(function(){var n,r,o,i,s=this;return mf(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new _f(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 vf(s,void 0,void 0,(function(){return mf(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===cf.code?[4,wf.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 Ef=function(){function e(e){this.config=e,this.Geo=tc,this.serverDate=La,this.command=tf,this.RegExp=sf,this.startTransaction=bf,this.runTransaction=wf,this.logicCommand=sc,this.updateCommand=oc,this.queryCommand=fc}return e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new ef(this,e)},e.prototype.createCollection=function(t){var n={collectionName:t};return new e.reqClass(this.config).send("database.addCollection",n)},e}(),Sf=function(){return Sf=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},Sf.apply(this,arguments)};var If={name:"database",entity:{database:function(e){var t=this.platform,n=t.adapter,r=t.runtime;return Ef.reqClass=this.request.constructor,Ef.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},Ef.runtime=r,this.wsClientClass&&(Ef.wsClass=n.wsClass,Ef.wsClientClass=this.wsClientClass),Ef.ws||(Ef.ws=null),new Ef(Sf(Sf({},this.config),e))}}};try{cloudbase.registerComponent(If)}catch(e){}var Of,Af="1.7.2";zt.registerVersion(Af);try{!function(e){try{e.registerComponent(Wr)}catch(e){console.warn(e)}}(zt),function(e){try{e.registerComponent(Qr)}catch(e){console.warn(e)}}(zt),function(e){try{e.registerComponent(go)}catch(e){console.warn(e)}}(zt),function(e){try{e.registerComponent(If)}catch(e){console.warn(e)}}(zt),function(e){try{e.registerComponent(Ms),e.registerHook(Us)}catch(e){console.warn(e)}}(zt),function(e){try{e.registerComponent(Zs)}catch(e){console.warn(e)}}(zt)}catch(e){}try{window.cloudbase=zt}catch(e){}!function(e){e.development="dev-1gpp53ju3ceb46c7",e.testing="dev-1gpp53ju3ceb46c7",e.production="release-7gvojkxi667a3f26"}(Of||(Of={}));var Nf={ENV:Of[process.env.NODE_ENV],REGION:"ap-shanghai"},Tf={region:Nf.REGION,env:Nf.ENV},Rf=zt.init(Tf);function Pf(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,Rf.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)}))]}}))}))}var xf=t.create();function Lf(e){return function(e){!e.method&&e.data&&(e.method="post"),e.method||e.data||(e.method="get")}(e),function(e){e.requestInterceptors&&"function"==typeof e.requestInterceptors&&xf.interceptors.request.use(e.requestInterceptors),e.responseInterceptors&&"function"==typeof e.responseInterceptors&&xf.interceptors.response.use(e.responseInterceptors)}(e),new Promise((function(t,n){xf.request({method:e.method,url:e.url,headers:(null==e?void 0:e.headers)||{},data:null==e?void 0:e.data,params:null==e?void 0:e.params,timeout:(null==e?void 0:e.timeout)||8e3}).then((function(e){if(200===e.status){var r=e.data;t(r)}else{r=e.data;n(r)}})).catch((function(t){var r=(null==t?void 0:t.response)||{};(null==e?void 0:e.catchCallback)&&"function"==typeof(null==e?void 0:e.catchCallback)&&(null==e||e.catchCallback(t));var o=null==r?void 0:r.data;n(o)}))}))}var kf=function(){function e(){this.token=null,this.loginPath="",this.instance=t.create(),this.setupInterceptors()}return e.prototype.setupTokenListener=function(e){var t=this;window.addEventListener("storage",(function(n){if("string"==typeof e&&n.key===e&&n.newValue&&t.setToken(n.newValue),"function"==typeof e){var r=e();t.setToken(r)}}));var n="string"==typeof e?window.localStorage.getItem(e):"function"==typeof e?e():null;n&&this.setToken(n)},e.prototype.setupAuthorizationCallback=function(e){this.instance.interceptors.response.use((function(e){return e}),(function(t){return t.response&&401===t.response.status&&("string"==typeof e?location.replace(e):"function"==typeof e&&e()),Promise.reject(t)}))},e.prototype.encryptToken=function(e){if(e){var t=e+"|+|"+(new Date).getTime();return r.AES.encrypt(t,"214c!dsf1").toString()}},e.prototype.setToken=function(e){this.token=e},e.prototype.setupInterceptors=function(){var e=this;this.instance.interceptors.request.use((function(t){return e.token&&(t.headers["x-belink-authorization"]=e.encryptToken(e.token)),t}))},e.prototype.setRequestMethod=function(e){e&&!(null==e?void 0:e.method)&&(e.method=(null==e?void 0:e.data)?"post":"get")},e.prototype.setInterceptors=function(e){"function"==typeof e.requestInterceptors&&this.instance.interceptors.request.use(e.requestInterceptors),"function"==typeof e.responseInterceptors&&this.instance.interceptors.response.use(e.responseInterceptors)},e.prototype.request=function(e){return o(this,void 0,void 0,(function(){var t=this;return i(this,(function(r){return this.setRequestMethod(e),this.setInterceptors(e),[2,new Promise((function(r,o){t.instance.request({method:e.method,url:e.url,headers:e.headers,data:e.data,params:e.params,timeout:e.timeout||8e3}).then((function(e){200===e.status?r(e.data):o(e.data)})).catch((function(t){var r;null==t||t.response,e.catchCallback&&t instanceof n&&e.catchCallback(t),o((null===(r=t.response)||void 0===r?void 0:r.data)||t)}))}))]}))}))},e}(),Cf=new kf;export{Cf as beLinkRequest,Pf as callFunction,Lf as request};
|