@cloudbase/js-sdk 2.5.21-beta.0 → 2.5.23-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase",[],e):"object"==typeof exports?exports.cloudbase=e():t.cloudbase=e()}("undefined"!=typeof window?window:this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=18)}([function(t,e,n){"use strict";n.d(e,"c",(function(){return u})),n.d(e,"a",(function(){return r})),n.d(e,"b",(function(){return b})),n.d(e,"d",(function(){return o})),n.d(e,"f",(function(){return f})),n.d(e,"e",(function(){return i}));var r={};n.r(r),n.d(r,"RUNTIME",(function(){return a})),n.d(r,"useAdapters",(function(){return v})),n.d(r,"useDefaultAdapter",(function(){return m}));var o={};n.r(o),n.d(o,"CloudbaseEvent",(function(){return E})),n.d(o,"IErrorEvent",(function(){return I})),n.d(o,"CloudbaseEventEmitter",(function(){return S})),n.d(o,"addEventListener",(function(){return A})),n.d(o,"activateEvent",(function(){return T})),n.d(o,"removeEventListener",(function(){return N}));var i={};n.r(i),n.d(i,"catchErrorsDecorator",(function(){return U}));var s,a,u=n(2),c=n(5),f=n(1),l=n(8),h=(s=function(t,e){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),p=function(){return(p=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},d=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},y=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},g=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return h(e,t),e.prototype.get=function(t){return this.request(p(p({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(p(p({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(p(p({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,o=t.method,i=t.headers,s=void 0===i?{}:i,a={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===a?(Object.keys(e).forEach((function(t){u.append(t,e[t])})),u.append("key",r),u.append("file",n),this.request(p(p({},t),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request(p(p({},t),{method:"put",headers:s,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return d(this,void 0,void 0,(function(){var e,n,r,o;return y(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(p(p({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,u=t.headers,c=void 0===u?{}:u,h=t.data,p=t.responseType,d=t.withCredentials,y=t.body,g=t.onUploadProgress,v=Object(f.formatUrl)(Object(l.c)(),a,"get"===r?h:{}),m=new XMLHttpRequest;m.open(r,v),p&&(m.responseType=p),Object.keys(c).forEach((function(t){m.setRequestHeader(t,c[t])})),g&&m.upload.addEventListener("progress",g),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o})),t.header=n,t.statusCode=m.status;try{t.data="blob"===p?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===p?m.response:m.responseText}clearTimeout(i),o(t)}},e&&n.timeout&&(i=setTimeout((function(){console.warn(n.timeoutMsg),m.abort()}),n.timeout)),s=Object(f.isFormData)(h)?h:"application/x-www-form-urlencoded"===c["content-type"]?Object(f.toQueryString)(h):y||(h?JSON.stringify(h):void 0),d&&(m.withCredentials=!0),m.send(s)}))},e}(c.a);function v(t){for(var e=0,n=Object(f.isArray)(t)?t:[t];e<n.length;e++){var r=n[e],o=r.isMatch,i=r.genAdapter,s=r.runtime;if(o())return{adapter:i(),runtime:s}}}function m(){return{adapter:{root:window,reqClass:g,wsClass:WebSocket,localStorage:localStorage},runtime:a.WEB}}!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a||(a={}));var b=n(10),w=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),_=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};var E=function(t,e){this.data=e||null,this.name=t},I=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return w(e,t),e}(E),S=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(Object(f.isInstanceOf)(t,I))return console.error(t.error),this;var n=Object(f.isString)(t)?new E(t,e||{}):t,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,i=this.listeners[r]?_(this.listeners[r]):[];o<i.length;o++){i[o].call(this,n)}}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}(),O=new S;function A(t,e){O.on(t,e)}function T(t,e){void 0===e&&(e={}),O.fire(t,e)}function N(t,e){O.off(t,e)}var R=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},x=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},C=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(C=-1!==navigator.userAgent.indexOf("Firefox"));var L=C?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,P=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function U(t){var e=t.mode,n=void 0===e?"async":e,r=t.customInfo,o=void 0===r?{}:r,i=t.title,s=t.messages,a=void 0===s?[]:s;return function(t,e,r){if(u.IS_DEBUG_MODE){var s=o.className||t.constructor.name,c=o.methodName||e,l=r.value,h=function(t){var e="",n=t.stack.split("\n"),r=n.findIndex((function(t){return L.test(t)}));if(-1!==r){var o=P.exec(n[r+1]||"");e=o?o[0]:""}return e}(new Error);r.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=D({err:new Error,className:s,methodName:c,sourceLink:h});try{return l.apply(this,t)}catch(t){var r=t,o=t.message,u=t.error,p=t.error_description,d={title:i||s+"."+c+" failed",content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var y=JSON.parse(o);d.subtitle=o,y.code&&(n?(n.code=y.code,n.msg=y.msg):(t.code=y.code,t.message=y.msg),r=n||t,d.content=a.map((function(t){return{type:"info",body:t}})))}throw u&&p&&(d.subtitle=p,n?(n.code=u,n.msg=p):(t.code=u,t.message=p),r=n||t,d.content=a.map((function(t){return{type:"info",body:t}}))),Object(f.printGroupLog)(d),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return R(this,void 0,void 0,(function(){var e,n,r,o,u,p,d,y;return x(this,(function(g){switch(g.label){case 0:e=D({err:new Error,className:s,methodName:c,sourceLink:h}),g.label=1;case 1:return g.trys.push([1,3,,4]),[4,l.apply(this,t)];case 2:return[2,g.sent()];case 3:throw n=g.sent(),r=n,o=n.message,u=n.error,p=n.error_description,d={title:i||s+"."+c+" failed",content:[{type:"error",body:n}]},o&&/^\{.*\}$/.test(o)&&(y=JSON.parse(o),d.subtitle=y,y.code&&(e?(e.code=y.code,e.message=y.msg):(n.code=y.code,n.message=y.msg),r=e||n,d.content=a.map((function(t){return{type:"info",body:t}})))),u&&p&&(d.subtitle=p,e?(e.code=u,e.msg=p):(n.code=u,n.message=p),r=e||n,d.content=a.map((function(t){return{type:"info",body:t}}))),Object(f.printGroupLog)(d),r;case 4:return[2]}}))}))}}}}function D(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),a=C?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]\\s*\\(.*\\)$"),u=C?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]"),c=s.findIndex((function(t){return a.test(t)}));if(-1!==c){var f=s.filter((function(t,e){return e>c}));f.unshift(s[c].replace(u,n+"."+r).replace(P,o)),(i=new Error).stack=(C?"@debugger":"Error")+"\n"+f.join("\n")}return i}function j(t){this.message=t}j.prototype=new Error,j.prototype.name="InvalidCharacterError";"undefined"!=typeof window&&window.atob&&window.atob.bind(window);function k(t){this.message=t}k.prototype=new Error,k.prototype.name="InvalidTokenError"},function(t,e,n){"use strict";n.r(e),n.d(e,"isArray",(function(){return f})),n.d(e,"isString",(function(){return l})),n.d(e,"isUndefined",(function(){return h})),n.d(e,"isPalinObject",(function(){return p})),n.d(e,"isNull",(function(){return d})),n.d(e,"isInstanceOf",(function(){return y})),n.d(e,"isFormData",(function(){return g})),n.d(e,"genSeqId",(function(){return v})),n.d(e,"formatUrl",(function(){return m})),n.d(e,"createSign",(function(){return w})),n.d(e,"toQueryString",(function(){return _})),n.d(e,"getQuery",(function(){return E})),n.d(e,"getHash",(function(){return I})),n.d(e,"removeParam",(function(){return S})),n.d(e,"createPromiseCallback",(function(){return O})),n.d(e,"execCallback",(function(){return A})),n.d(e,"printWarn",(function(){return T})),n.d(e,"printError",(function(){return N})),n.d(e,"printInfo",(function(){return R})),n.d(e,"throwError",(function(){return x})),n.d(e,"printGroupLog",(function(){return C})),n.d(e,"sleep",(function(){return L})),n.d(e,"transformPhone",(function(){return P}));var r=n(13),o=n.n(r),i=n(14),s=n.n(i),a=n(9),u=n.n(a),c=n(2);function f(t){return"[object Array]"===Object.prototype.toString.call(t)}function l(t){return"string"==typeof t}function h(t){return void 0===t}function p(t){return"[object Object]"===Object.prototype.toString.call(t)}function d(t){return"[object Null]"===Object.prototype.toString.call(t)}function y(t,e){return t instanceof e}function g(t){return"[object FormData]"===Object.prototype.toString.call(t)}function v(){return Math.random().toString(16).slice(2)}function m(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";return Object.keys(n).forEach((function(t){""===o?!r&&(e+="?"):o+="&",o+=t+"="+encodeURIComponent(n[t])})),/^http(s)?:\/\//.test(e+=o)?e:""+t+e}function b(t){var e=s.a.stringify(t);return e=(e=(e=e.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function w(t,e){var n=b(u.a.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+b(u.a.parse(JSON.stringify(t)));return n+"."+b(o()(n,e))}function _(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(n){e.push(n+"="+encodeURIComponent(t[n]))})),e.join("&")}function E(t,e){if("undefined"==typeof window)return!1;var n=e||window.location.search,r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""}var I=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]"+t+"=([^&#]*)"));return e?e[1]:""};function S(t,e){var n=e.split("?")[0],r=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===t&&r.splice(i,1);n=n+"?"+r.join("&")}return n}function O(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t}function A(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n}function T(t,e){console.warn("["+Object(c.getSdkName)()+"]["+t+"]:"+e)}function N(t,e){console.error({code:t,msg:"["+Object(c.getSdkName)()+"]["+t+"]:"+e})}function R(t,e){console.log("["+Object(c.getSdkName)()+"]["+t+"]:"+e)}function x(t,e){throw new Error(JSON.stringify({code:t,msg:"["+Object(c.getSdkName)()+"]["+t+"]:"+e}))}function C(t){var e=t.title,n=t.subtitle,r=void 0===n?"":n,o=t.content,i=void 0===o?[]:o,s=t.printTrace,a=void 0!==s&&s,u=t.collapsed;void 0!==u&&u?console.groupCollapsed(e,r):console.group(e,r);for(var c=0,f=i;c<f.length;c++){var l=f[c],h=l.type,p=l.body;switch(h){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}a&&console.trace("stack trace:"),console.groupEnd()}var L=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))};function P(t){return"+86"+t}},function(t,e,n){"use strict";n.r(e),n.d(e,"setSdkName",(function(){return r.f})),n.d(e,"getSdkName",(function(){return r.d})),n.d(e,"setProtocol",(function(){return r.e})),n.d(e,"getProtocol",(function(){return r.c})),n.d(e,"IS_DEBUG_MODE",(function(){return r.b})),n.d(e,"COMMUNITY_SITE_URL",(function(){return r.a})),n.d(e,"ERRORS",(function(){return o})),n.d(e,"OATUH_LOGINTYPE",(function(){return i}));var r=n(8),o={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"},i="constants"},function(t,e,n){"use strict";(function(t){n.d(e,"i",(function(){return u})),n.d(e,"e",(function(){return c})),n.d(e,"h",(function(){return f})),n.d(e,"d",(function(){return l})),n.d(e,"a",(function(){return p})),n.d(e,"f",(function(){return g})),n.d(e,"g",(function(){return v})),n.d(e,"c",(function(){return m})),n.d(e,"b",(function(){return b}));var r=n(0),o=r.c.setSdkName,i=r.c.setProtocol,s="",a="@cloudbase/js-sdk";function u(t){s=t}function c(){return s}function f(t){a=t,o(t)}function l(){return a}var h,p="2020-01-10",d="https:",y="//tcb-api.tencentcloudapi.com/web";function g(t,e){y=t,e&&(d=e,i(e))}function v(t,e,n){g(e?"//"+t+"."+e+".tcb-api.tencentcloudapi.com/web":"//"+t+".ap-shanghai.tcb-api.tencentcloudapi.com/web",n)}function m(){return{BASE_URL:y,PROTOCOL:d}}function b(){var t=m();return(""+t.PROTOCOL+t.BASE_URL).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]}!function(t){t.NULL="NULL",t.ANONYMOUS="ANONYMOUS",t.WECHAT="WECHAT",t.WECHAT_PUBLIC="WECHAT-PUBLIC",t.WECHAT_OPEN="WECHAT-OPEN",t.CUSTOM="CUSTOM",t.EMAIL="EMAIL",t.USERNAME="USERNAME",t.PHONE="PHONE"}(h||(h={}))}).call(this,n(11))},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return _t}));for(var r=function(t){var e=h(t),n=e[0],r=e[1];return 3*(n+r)/4-r},o=function(t){var e,n,r=h(t),o=r[0],i=r[1],s=new u(function(t,e,n){return 3*(e+n)/4-n}(0,o,i)),c=0,f=i>0?o-4:o;for(n=0;n<f;n+=4)e=a[t.charCodeAt(n)]<<18|a[t.charCodeAt(n+1)]<<12|a[t.charCodeAt(n+2)]<<6|a[t.charCodeAt(n+3)],s[c++]=e>>16&255,s[c++]=e>>8&255,s[c++]=255&e;2===i&&(e=a[t.charCodeAt(n)]<<2|a[t.charCodeAt(n+1)]>>4,s[c++]=255&e);1===i&&(e=a[t.charCodeAt(n)]<<10|a[t.charCodeAt(n+1)]<<4|a[t.charCodeAt(n+2)]>>2,s[c++]=e>>8&255,s[c++]=255&e);return s},i=function(t){for(var e,n=t.length,r=n%3,o=[],i=0,a=n-r;i<a;i+=16383)o.push(p(t,i,i+16383>a?a:i+16383));1===r?(e=t[n-1],o.push(s[e>>2]+s[e<<4&63]+"==")):2===r&&(e=(t[n-2]<<8)+t[n-1],o.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return o.join("")},s=[],a=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,l=c.length;f<l;++f)s[f]=c[f],a[c.charCodeAt(f)]=f;function h(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function p(t,e,n){for(var r,o,i=[],a=e;a<n;a+=3)r=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),i.push(s[(o=r)>>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63;var d={byteLength:r,toByteArray:o,fromByteArray:i},y=function(t,e,n,r,o){var i,s,a=8*o-r-1,u=(1<<a)-1,c=u>>1,f=-7,l=n?o-1:0,h=n?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+t[e+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=r;f>0;s=256*s+t[e+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),i-=c}return(p?-1:1)*s*Math.pow(2,i-r)},g=function(t,e,n,r,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,d=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(e*u-1)*Math.pow(2,o),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[n+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;t[n+p]=255&s,p+=d,s/=256,c-=8);t[n+p-d]|=128*y},v=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){var n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=o,e.SlowBuffer=function(t){+t!=t&&(t=0);return o.alloc(+t)},e.INSPECT_MAX_BYTES=50;function r(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,o.prototype),e}function o(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return i(t,e,n)}function i(t,e,n){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var n=0|l(t,e),i=r(n),s=i.write(t,e);s!==n&&(i=i.slice(0,s));return i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(B(t,Uint8Array)){var e=new Uint8Array(t);return c(e.buffer,e.byteOffset,e.byteLength)}return u(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t));if(B(t,ArrayBuffer)||t&&B(t.buffer,ArrayBuffer))return c(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(B(t,SharedArrayBuffer)||t&&B(t.buffer,SharedArrayBuffer)))return c(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return o.from(i,e,n);var s=function(t){if(o.isBuffer(t)){var e=0|f(t.length),n=r(e);return 0===n.length||t.copy(n,0,0,e),n}if(void 0!==t.length)return"number"!=typeof t.length||q(t.length)?r(0):u(t);if("Buffer"===t.type&&Array.isArray(t.data))return u(t.data)}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return o.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t))}function s(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return s(t),r(t<0?0:0|f(t))}function u(t){for(var e=t.length<0?0:0|f(t.length),n=r(e),o=0;o<e;o+=1)n[o]=255&t[o];return n}function c(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,o.prototype),r}function f(t){if(t>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function l(t,e){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||B(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+babelHelpers.typeof(t));var n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return k(t).length;default:if(i)return r?-1:j(t).length;e=(""+e).toLowerCase(),i=!0}}function h(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return N(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return A(this,e,n);case"latin1":case"binary":return T(this,e,n);case"base64":return S(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function p(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function v(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),q(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=o.from(e,r)),o.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,o){var i,s=1,a=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var f=-1;for(i=n;i<a;i++)if(c(t,i)===c(e,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===u)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(n+u>a&&(n=a-u),i=n;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(c(t,i+h)!==c(e,h)){l=!1;break}if(l)return i}return-1}function b(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=e.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(e.substr(2*s,2),16);if(q(a))return s;t[n+s]=a}return s}function w(t,e,n,r){return M(j(e,t.length-n),t,n,r)}function _(t,e,n,r){return M(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function E(t,e,n,r){return M(k(e),t,n,r)}function I(t,e,n,r){return M(function(t,e){for(var n,r,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function S(t,e,n){return 0===e&&n===t.length?d.fromByteArray(t):d.fromByteArray(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o<n;){var i,s,a,u,c=t[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),o+=l}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=4096));return n}(r)}e.kMaxLength=2147483647,o.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),o.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(t,e,n){return i(t,e,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(t,e,n){return function(t,e,n){return s(t),t<=0?r(t):void 0!==e?"string"==typeof n?r(t).fill(e,n):r(t).fill(e):r(t)}(t,e,n)},o.allocUnsafe=function(t){return a(t)},o.allocUnsafeSlow=function(t){return a(t)},o.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==o.prototype},o.compare=function(t,e){if(B(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),B(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,r=e.length,i=0,s=Math.min(n,r);i<s;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=o.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var s=t[n];if(B(s,Uint8Array))i+s.length>r.length?o.from(s).copy(r,i):Uint8Array.prototype.set.call(r,s,i);else{if(!o.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i)}i+=s.length}return r},o.byteLength=l,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)p(this,e,e+1);return this},o.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)p(this,e,e+3),p(this,e+1,e+2);return this},o.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)p(this,e,e+7),p(this,e+1,e+6),p(this,e+2,e+5),p(this,e+3,e+4);return this},o.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?O(this,0,t):h.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===o.compare(this,t)},o.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(t,e,n,r,i){if(B(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+babelHelpers.typeof(t));if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0),u=Math.min(s,a),c=this.slice(r,i),f=t.slice(e,n),l=0;l<u;++l)if(c[l]!==f[l]){s=c[l],a=f[l];break}return s<a?-1:a<s?1:0},o.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},o.prototype.indexOf=function(t,e,n){return v(this,t,e,n,!0)},o.prototype.lastIndexOf=function(t,e,n){return v(this,t,e,n,!1)},o.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return _(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function A(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function T(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function N(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=e;i<n;++i)o+=F[t[i]];return o}function R(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length-1;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function x(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,n,r,i,s){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function L(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function P(t,e,n,r,o){return e=+e,n>>>=0,o||L(t,0,n,4),g(t,e,n,r,23,4),n+4}function U(t,e,n,r,o){return e=+e,n>>>=0,o||L(t,0,n,8),g(t,e,n,r,52,8),n+8}o.prototype.slice=function(t,e){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r=this.subarray(t,e);return Object.setPrototypeOf(r,o.prototype),r},o.prototype.readUintLE=o.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||x(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||x(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||x(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*e)),r},o.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||x(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},o.prototype.readInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){t>>>=0,e||x(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(t,e){t>>>=0,e||x(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,e){return t>>>=0,e||x(t,4,this.length),y(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t>>>=0,e||x(t,4,this.length),y(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t>>>=0,e||x(t,8,this.length),y(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t>>>=0,e||x(t,8,this.length),y(this,t,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e>>>=0,n>>>=0,r)||C(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e>>>=0,n>>>=0,r)||C(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,1,255,0),this[e]=255&t,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);C(this,t,e,n,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<n&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+n},o.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);C(this,t,e,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+n},o.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeFloatLE=function(t,e,n){return P(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){return P(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){return U(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){return U(this,t,e,!1,n)},o.prototype.copy=function(t,e,n,r){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),i},o.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){var i=t.charCodeAt(0);("utf8"===r&&i<128||"latin1"===r)&&(t=i)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var s;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=e;s<n;++s)this[s]=t;else{var a=o.isBuffer(t)?t:o.from(t,r),u=a.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-e;++s)this[s+e]=a[s%u]}return this};var D=/[^+/0-9A-Za-z-_]/g;function j(t,e){var n;e=e||1/0;for(var r=t.length,o=null,i=[],s=0;s<r;++s){if((n=t.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function k(t){return d.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(D,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function M(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function B(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function q(t){return t!=t}var F=function(){for(var t=new Array(256),e=0;e<16;++e)for(var n=16*e,r=0;r<16;++r)t[n+r]="0123456789abcdef"[e]+"0123456789abcdef"[r];return t}()})),m=v.Buffer;
2
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */v.SlowBuffer,v.INSPECT_MAX_BYTES,v.kMaxLength;
3
- /*! *****************************************************************************
4
- Copyright (c) Microsoft Corporation.
5
-
6
- Permission to use, copy, modify, and/or distribute this software for any
7
- purpose with or without fee is hereby granted.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- PERFORMANCE OF THIS SOFTWARE.
16
- ***************************************************************************** */
17
- var b=function(t,e){return(b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function w(t,e){function n(){this.constructor=t}b(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var _=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return w(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),e}(Error),E=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return w(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),e}(TypeError);function I(t){return t&&t.Math==Math&&t}function S(){return I("object"==typeof globalThis&&globalThis)||I("object"==typeof window&&window)||I("object"==typeof self&&self)||I("object"==typeof t&&t)||Function("return this")()}var O=function(t){var e,n="object"==typeof(e=S()).navigator&&"ReactNative"===e.navigator.product?"BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.":"BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.";console.warn(n);for(var r=m.alloc(t),o=0;o<t;++o)r[o]=Math.floor(256*Math.random());return r},A=function(){if("undefined"!=typeof window){var e=window.crypto||window.msCrypto;if(e&&e.getRandomValues)return function(t){return e.getRandomValues(m.alloc(t))}}return void 0!==t&&t.crypto&&t.crypto.getRandomValues?function(e){return t.crypto.getRandomValues(m.alloc(e))}:O}();function T(t){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(t))}function N(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function R(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function x(t){return C(t)&&"[object Date]"===Object.prototype.toString.call(t)}function C(t){return"object"==typeof t&&null!==t}function L(t,e){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return n||(console.warn(e),n=!0),t.apply(this,r)}}function P(t){if(ArrayBuffer.isView(t))return m.from(t.buffer,t.byteOffset,t.byteLength);if(T(t))return m.from(t);throw new E("Must use either Buffer or TypedArray")}var U=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i,D=function(t){return"string"==typeof t&&U.test(t)},j=function(t){if(!D(t))throw new E('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var e=t.replace(/-/g,"");return m.from(e,"hex")},k=function(t,e){return void 0===e&&(e=!0),e?t.toString("hex",0,4)+"-"+t.toString("hex",4,6)+"-"+t.toString("hex",6,8)+"-"+t.toString("hex",8,10)+"-"+t.toString("hex",10,16):t.toString("hex")},M=(Math.pow(2,63),Math.pow(2,63),Math.pow(2,53)),B=-Math.pow(2,53),q=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(!(null==e||"string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Array.isArray(e)))throw new E("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=n?n:t.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=m.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=m.from(e,"binary"):Array.isArray(e)?this.buffer=m.from(e):this.buffer=P(e),this.position=this.buffer.byteLength)}return t.prototype.put=function(e){if("string"==typeof e&&1!==e.length)throw new E("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new E("only accepts single character Uint8Array or Array");var n;if((n="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0])<0||n>255)throw new E("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=n;else{var r=m.alloc(t.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=n}},t.prototype.write=function(t,e){if(e="number"==typeof e?e:this.position,this.buffer.length<e+t.length){var n=m.alloc(this.buffer.length+t.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n}ArrayBuffer.isView(t)?(this.buffer.set(P(t),e),this.position=e+t.byteLength>this.position?e+t.length:this.position):"string"==typeof t&&(this.buffer.write(t,e,t.length,"binary"),this.position=e+t.length>this.position?e+t.length:this.position)},t.prototype.read=function(t,e){return e=e&&e>0?e:this.position,this.buffer.slice(t,t+e)},t.prototype.value=function(t){return(t=!!t)&&this.buffer.length===this.position?this.buffer:t?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)},t.prototype.length=function(){return this.position},t.prototype.toJSON=function(){return this.buffer.toString("base64")},t.prototype.toString=function(t){return this.buffer.toString(t)},t.prototype.toExtendedJSON=function(t){t=t||{};var e=this.buffer.toString("base64"),n=Number(this.sub_type).toString(16);return t.legacy?{$binary:e,$type:1===n.length?"0"+n:n}:{$binary:{base64:e,subType:1===n.length?"0"+n:n}}},t.prototype.toUUID=function(){if(this.sub_type===t.SUBTYPE_UUID)return new F(this.buffer.slice(0,this.position));throw new _('Binary sub_type "'.concat(this.sub_type,'" is not supported for converting to UUID. Only "').concat(t.SUBTYPE_UUID,'" is currently supported.'))},t.fromExtendedJSON=function(e,n){var r,o;if(n=n||{},"$binary"in e?n.legacy&&"string"==typeof e.$binary&&"$type"in e?(o=e.$type?parseInt(e.$type,16):0,r=m.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=m.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,r=j(e.$uuid)),!r)throw new E("Unexpected Binary Extended JSON format ".concat(JSON.stringify(e)));return 4===o?new F(r):new t(r,o)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.value(!0);return'new Binary(Buffer.from("'.concat(t.toString("hex"),'", "hex"), ').concat(this.sub_type,")")},t.BSON_BINARY_SUBTYPE_DEFAULT=0,t.BUFFER_SIZE=256,t.SUBTYPE_DEFAULT=0,t.SUBTYPE_FUNCTION=1,t.SUBTYPE_BYTE_ARRAY=2,t.SUBTYPE_UUID_OLD=3,t.SUBTYPE_UUID=4,t.SUBTYPE_MD5=5,t.SUBTYPE_ENCRYPTED=6,t.SUBTYPE_COLUMN=7,t.SUBTYPE_USER_DEFINED=128,t}();Object.defineProperty(q.prototype,"_bsontype",{value:"Binary"});var F=function(t){function e(n){var r,o,i=this;if(null==n)r=e.generate();else if(n instanceof e)r=m.from(n.buffer),o=n.__id;else if(ArrayBuffer.isView(n)&&16===n.byteLength)r=P(n);else{if("string"!=typeof n)throw new E("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");r=j(n)}return(i=t.call(this,r,4)||this).__id=o,i}return w(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.buffer},set:function(t){this.buffer=t,e.cacheHexString&&(this.__id=k(t))},enumerable:!1,configurable:!0}),e.prototype.toHexString=function(t){if(void 0===t&&(t=!0),e.cacheHexString&&this.__id)return this.__id;var n=k(this.id,t);return e.cacheHexString&&(this.__id=n),n},e.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},e.prototype.toJSON=function(){return this.toHexString()},e.prototype.equals=function(t){if(!t)return!1;if(t instanceof e)return t.id.equals(this.id);try{return new e(t).id.equals(this.id)}catch(t){return!1}},e.prototype.toBinary=function(){return new q(this.id,q.SUBTYPE_UUID)},e.generate=function(){var t=A(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,m.from(t)},e.isValid=function(t){return!!t&&(t instanceof e||("string"==typeof t?D(t):!!N(t)&&(16===t.length&&(64==(240&t[6])&&128==(128&t[8])))))},e.createFromHexString=function(t){return new e(j(t))},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},e}(q),W=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);this.code=e,this.scope=n}return t.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},t.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},t.fromExtendedJSON=function(e){return new t(e.$code,e.$scope)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toJSON();return'new Code("'.concat(String(t.code),'"').concat(t.scope?", ".concat(JSON.stringify(t.scope)):"",")")},t}();function $(t){return C(t)&&null!=t.$id&&"string"==typeof t.$ref&&(null==t.$db||"string"==typeof t.$db)}Object.defineProperty(W.prototype,"_bsontype",{value:"Code"});var V=function(){function t(e,n,r,o){if(!(this instanceof t))return new t(e,n,r,o);var i=e.split(".");2===i.length&&(r=i.shift(),e=i.shift()),this.collection=e,this.oid=n,this.db=r,this.fields=o||{}}return Object.defineProperty(t.prototype,"namespace",{get:function(){return this.collection},set:function(t){this.collection=t},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){var t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(t.$db=this.db),t},t.prototype.toExtendedJSON=function(t){t=t||{};var e={$ref:this.collection,$id:this.oid};return t.legacy?e:(this.db&&(e.$db=this.db),e=Object.assign(e,this.fields))},t.fromExtendedJSON=function(e){var n=Object.assign({},e);return delete n.$ref,delete n.$id,delete n.$db,new t(e.$ref,e.$id,e.$db,n)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return'new DBRef("'.concat(this.namespace,'", new ObjectId("').concat(String(t),'")').concat(this.db?', "'.concat(this.db,'"'):"",")")},t}();Object.defineProperty(V.prototype,"_bsontype",{value:"DBRef"});var H=void 0;try{H=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(t){}var G={},J={},K=function(){function t(e,n,r){if(void 0===e&&(e=0),!(this instanceof t))return new t(e,n,r);"bigint"==typeof e?Object.assign(this,t.fromBigInt(e,!!n)):"string"==typeof e?Object.assign(this,t.fromString(e,!!n)):(this.low=0|e,this.high=0|n,this.unsigned=!!r),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return t.fromBits=function(e,n,r){return new t(e,n,r)},t.fromInt=function(e,n){var r,o,i;return n?(i=0<=(e>>>=0)&&e<256)&&(o=J[e])?o:(r=t.fromBits(e,(0|e)<0?-1:0,!0),i&&(J[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(o=G[e])?o:(r=t.fromBits(e,e<0?-1:0,!1),i&&(G[e]=r),r)},t.fromNumber=function(e,n){if(isNaN(e))return n?t.UZERO:t.ZERO;if(n){if(e<0)return t.UZERO;if(e>=0x10000000000000000)return t.MAX_UNSIGNED_VALUE}else{if(e<=-0x8000000000000000)return t.MIN_VALUE;if(e+1>=0x8000000000000000)return t.MAX_VALUE}return e<0?t.fromNumber(-e,n).neg():t.fromBits(e%4294967296|0,e/4294967296|0,n)},t.fromBigInt=function(e,n){return t.fromString(e.toString(),n)},t.fromString=function(e,n,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t.ZERO;if("number"==typeof n?(r=n,n=!1):n=!!n,(r=r||10)<2||36<r)throw RangeError("radix");var o;if((o=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===o)return t.fromString(e.substring(1),n,r).neg();for(var i=t.fromNumber(Math.pow(r,8)),s=t.ZERO,a=0;a<e.length;a+=8){var u=Math.min(8,e.length-a),c=parseInt(e.substring(a,a+u),r);if(u<8){var f=t.fromNumber(Math.pow(r,u));s=s.mul(f).add(t.fromNumber(c))}else s=(s=s.mul(i)).add(t.fromNumber(c))}return s.unsigned=n,s},t.fromBytes=function(e,n,r){return r?t.fromBytesLE(e,n):t.fromBytesBE(e,n)},t.fromBytesLE=function(e,n){return new t(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)},t.fromBytesBE=function(e,n){return new t(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)},t.isLong=function(t){return C(t)&&!0===t.__isLong__},t.fromValue=function(e,n){return"number"==typeof e?t.fromNumber(e,n):"string"==typeof e?t.fromString(e,n):t.fromBits(e.low,e.high,"boolean"==typeof n?n:e.unsigned)},t.prototype.add=function(e){t.isLong(e)||(e=t.fromValue(e));var n=this.high>>>16,r=65535&this.high,o=this.low>>>16,i=65535&this.low,s=e.high>>>16,a=65535&e.high,u=e.low>>>16,c=0,f=0,l=0,h=0;return l+=(h+=i+(65535&e.low))>>>16,h&=65535,f+=(l+=o+u)>>>16,l&=65535,c+=(f+=r+a)>>>16,f&=65535,c+=n+s,c&=65535,t.fromBits(l<<16|h,c<<16|f,this.unsigned)},t.prototype.and=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low&e.low,this.high&e.high,this.unsigned)},t.prototype.compare=function(e){if(t.isLong(e)||(e=t.fromValue(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},t.prototype.comp=function(t){return this.compare(t)},t.prototype.divide=function(e){if(t.isLong(e)||(e=t.fromValue(e)),e.isZero())throw Error("division by zero");if(H){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;var n=(this.unsigned?H.div_u:H.div_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,H.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?t.UZERO:t.ZERO;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return t.UZERO;if(e.gt(this.shru(1)))return t.UONE;i=t.UZERO}else{if(this.eq(t.MIN_VALUE))return e.eq(t.ONE)||e.eq(t.NEG_ONE)?t.MIN_VALUE:e.eq(t.MIN_VALUE)?t.ONE:(r=this.shr(1).div(e).shl(1)).eq(t.ZERO)?e.isNegative()?t.ONE:t.NEG_ONE:(o=this.sub(e.mul(r)),i=r.add(o.div(e)));if(e.eq(t.MIN_VALUE))return this.unsigned?t.UZERO:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=t.ZERO}for(o=this;o.gte(e);){r=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),a=s<=48?1:Math.pow(2,s-48),u=t.fromNumber(r),c=u.mul(e);c.isNegative()||c.gt(o);)r-=a,c=(u=t.fromNumber(r,this.unsigned)).mul(e);u.isZero()&&(u=t.ONE),i=i.add(u),o=o.sub(c)}return i},t.prototype.div=function(t){return this.divide(t)},t.prototype.equals=function(e){return t.isLong(e)||(e=t.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},t.prototype.eq=function(t){return this.equals(t)},t.prototype.getHighBits=function(){return this.high},t.prototype.getHighBitsUnsigned=function(){return this.high>>>0},t.prototype.getLowBits=function(){return this.low},t.prototype.getLowBitsUnsigned=function(){return this.low>>>0},t.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(t.MIN_VALUE)?64:this.neg().getNumBitsAbs();var e,n=0!==this.high?this.high:this.low;for(e=31;e>0&&0==(n&1<<e);e--);return 0!==this.high?e+33:e+1},t.prototype.greaterThan=function(t){return this.comp(t)>0},t.prototype.gt=function(t){return this.greaterThan(t)},t.prototype.greaterThanOrEqual=function(t){return this.comp(t)>=0},t.prototype.gte=function(t){return this.greaterThanOrEqual(t)},t.prototype.ge=function(t){return this.greaterThanOrEqual(t)},t.prototype.isEven=function(){return 0==(1&this.low)},t.prototype.isNegative=function(){return!this.unsigned&&this.high<0},t.prototype.isOdd=function(){return 1==(1&this.low)},t.prototype.isPositive=function(){return this.unsigned||this.high>=0},t.prototype.isZero=function(){return 0===this.high&&0===this.low},t.prototype.lessThan=function(t){return this.comp(t)<0},t.prototype.lt=function(t){return this.lessThan(t)},t.prototype.lessThanOrEqual=function(t){return this.comp(t)<=0},t.prototype.lte=function(t){return this.lessThanOrEqual(t)},t.prototype.modulo=function(e){if(t.isLong(e)||(e=t.fromValue(e)),H){var n=(this.unsigned?H.rem_u:H.rem_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,H.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},t.prototype.mod=function(t){return this.modulo(t)},t.prototype.rem=function(t){return this.modulo(t)},t.prototype.multiply=function(e){if(this.isZero())return t.ZERO;if(t.isLong(e)||(e=t.fromValue(e)),H){var n=H.mul(this.low,this.high,e.low,e.high);return t.fromBits(n,H.get_high(),this.unsigned)}if(e.isZero())return t.ZERO;if(this.eq(t.MIN_VALUE))return e.isOdd()?t.MIN_VALUE:t.ZERO;if(e.eq(t.MIN_VALUE))return this.isOdd()?t.MIN_VALUE:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(t.TWO_PWR_24)&&e.lt(t.TWO_PWR_24))return t.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,o=65535&this.high,i=this.low>>>16,s=65535&this.low,a=e.high>>>16,u=65535&e.high,c=e.low>>>16,f=65535&e.low,l=0,h=0,p=0,d=0;return p+=(d+=s*f)>>>16,d&=65535,h+=(p+=i*f)>>>16,p&=65535,h+=(p+=s*c)>>>16,p&=65535,l+=(h+=o*f)>>>16,h&=65535,l+=(h+=i*c)>>>16,h&=65535,l+=(h+=s*u)>>>16,h&=65535,l+=r*f+o*c+i*u+s*a,l&=65535,t.fromBits(p<<16|d,l<<16|h,this.unsigned)},t.prototype.mul=function(t){return this.multiply(t)},t.prototype.negate=function(){return!this.unsigned&&this.eq(t.MIN_VALUE)?t.MIN_VALUE:this.not().add(t.ONE)},t.prototype.neg=function(){return this.negate()},t.prototype.not=function(){return t.fromBits(~this.low,~this.high,this.unsigned)},t.prototype.notEquals=function(t){return!this.equals(t)},t.prototype.neq=function(t){return this.notEquals(t)},t.prototype.ne=function(t){return this.notEquals(t)},t.prototype.or=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low|e.low,this.high|e.high,this.unsigned)},t.prototype.shiftLeft=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):t.fromBits(0,this.low<<e-32,this.unsigned)},t.prototype.shl=function(t){return this.shiftLeft(t)},t.prototype.shiftRight=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):t.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},t.prototype.shr=function(t){return this.shiftRight(t)},t.prototype.shiftRightUnsigned=function(e){if(t.isLong(e)&&(e=e.toInt()),0===(e&=63))return this;var n=this.high;if(e<32){var r=this.low;return t.fromBits(r>>>e|n<<32-e,n>>>e,this.unsigned)}return 32===e?t.fromBits(n,0,this.unsigned):t.fromBits(n>>>e-32,0,this.unsigned)},t.prototype.shr_u=function(t){return this.shiftRightUnsigned(t)},t.prototype.shru=function(t){return this.shiftRightUnsigned(t)},t.prototype.subtract=function(e){return t.isLong(e)||(e=t.fromValue(e)),this.add(e.neg())},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},t.prototype.toNumber=function(){return this.unsigned?4294967296*(this.high>>>0)+(this.low>>>0):4294967296*this.high+(this.low>>>0)},t.prototype.toBigInt=function(){return BigInt(this.toString())},t.prototype.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},t.prototype.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},t.prototype.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},t.prototype.toSigned=function(){return this.unsigned?t.fromBits(this.low,this.high,!1):this},t.prototype.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(t.MIN_VALUE)){var n=t.fromNumber(e),r=this.div(n),o=r.mul(n).sub(this);return r.toString(e)+o.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=t.fromNumber(Math.pow(e,6),this.unsigned),s=this,a="";;){var u=s.div(i),c=(s.sub(u.mul(i)).toInt()>>>0).toString(e);if((s=u).isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}},t.prototype.toUnsigned=function(){return this.unsigned?this:t.fromBits(this.low,this.high,!0)},t.prototype.xor=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low^e.low,this.high^e.high,this.unsigned)},t.prototype.eqz=function(){return this.isZero()},t.prototype.le=function(t){return this.lessThanOrEqual(t)},t.prototype.toExtendedJSON=function(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}},t.fromExtendedJSON=function(e,n){var r=t.fromString(e.$numberLong);return n&&n.relaxed?r.toNumber():r},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Long("'.concat(this.toString(),'"').concat(this.unsigned?", true":"",")")},t.TWO_PWR_24=t.fromInt(1<<24),t.MAX_UNSIGNED_VALUE=t.fromBits(-1,-1,!0),t.ZERO=t.fromInt(0),t.UZERO=t.fromInt(0,!0),t.ONE=t.fromInt(1),t.UONE=t.fromInt(1,!0),t.NEG_ONE=t.fromInt(-1),t.MAX_VALUE=t.fromBits(-1,2147483647,!1),t.MIN_VALUE=t.fromBits(0,-2147483648,!1),t}();Object.defineProperty(K.prototype,"__isLong__",{value:!0}),Object.defineProperty(K.prototype,"_bsontype",{value:"Long"});var Y=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,z=/^(\+|-)?(Infinity|inf)$/i,Q=/^(\+|-)?NaN$/i,Z=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),X=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),tt=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),et=/^([-+])?(\d+)?$/;function nt(t){return!isNaN(parseInt(t,10))}function rt(t){var e=K.fromNumber(1e9),n=K.fromNumber(0);if(!(t.parts[0]||t.parts[1]||t.parts[2]||t.parts[3]))return{quotient:t,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new K(t.parts[r],0)),t.parts[r]=n.div(e).low,n=n.modulo(e);return{quotient:t,rem:n}}function ot(t,e){throw new E('"'.concat(t,'" is not a valid Decimal128 string - ').concat(e))}var it=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!N(e))throw new E("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new E("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(e){var n,r=!1,o=!1,i=!1,s=0,a=0,u=0,c=0,f=0,l=[0],h=0,p=0,d=0,y=0,g=0,v=0,b=new K(0,0),w=new K(0,0),_=0;if(e.length>=7e3)throw new E(e+" not a valid Decimal128 string");var I=e.match(Y),S=e.match(z),O=e.match(Q);if(!I&&!S&&!O||0===e.length)throw new E(e+" not a valid Decimal128 string");if(I){var A=I[2],T=I[4],N=I[5],R=I[6];T&&void 0===R&&ot(e,"missing exponent power"),T&&void 0===A&&ot(e,"missing exponent base"),void 0===T&&(N||R)&&ot(e,"missing e before exponent")}if("+"!==e[_]&&"-"!==e[_]||(r="-"===e[_++]),!nt(e[_])&&"."!==e[_]){if("i"===e[_]||"I"===e[_])return new t(m.from(r?X:tt));if("N"===e[_])return new t(m.from(Z))}for(;nt(e[_])||"."===e[_];)"."!==e[_]?(h<34&&("0"!==e[_]||i)&&(i||(f=a),i=!0,l[p++]=parseInt(e[_],10),h+=1),i&&(u+=1),o&&(c+=1),a+=1,_+=1):(o&&ot(e,"contains multiple periods"),o=!0,_+=1);if(o&&!a)throw new E(e+" not a valid Decimal128 string");if("e"===e[_]||"E"===e[_]){var x=e.substr(++_).match(et);if(!x||!x[2])return new t(m.from(Z));g=parseInt(x[0],10),_+=x[0].length}if(e[_])return new t(m.from(Z));if(d=0,h){if(y=h-1,1!==(s=u))for(;0===l[f+s-1];)s-=1}else d=0,y=0,l[0]=0,u=1,h=1,s=0;for(g<=c&&c-g>16384?g=-6176:g-=c;g>6111;){if((y+=1)-d>34){if(l.join("").match(/^0+$/)){g=6111;break}ot(e,"overflow")}g-=1}for(;g<-6176||h<u;){if(0===y&&s<h){g=-6176,s=0;break}if(h<u?u-=1:y-=1,g<6111)g+=1;else{if(l.join("").match(/^0+$/)){g=6111;break}ot(e,"overflow")}}if(y-d+1<s){var C=a;o&&(f+=1,C+=1),r&&(f+=1,C+=1);var L=parseInt(e[f+y+1],10),P=0;if(L>=5&&(P=1,5===L))for(P=l[y]%2==1?1:0,v=f+y+2;v<C;v++)if(parseInt(e[v],10)){P=1;break}if(P)for(var U=y;U>=0;U--)if(++l[U]>9&&(l[U]=0,0===U)){if(!(g<6111))return new t(m.from(r?X:tt));g+=1,l[U]=1}}if(b=K.fromNumber(0),w=K.fromNumber(0),0===s)b=K.fromNumber(0),w=K.fromNumber(0);else if(y-d<17){U=d;for(w=K.fromNumber(l[U++]),b=new K(0,0);U<=y;U++)w=(w=w.multiply(K.fromNumber(10))).add(K.fromNumber(l[U]))}else{U=d;for(b=K.fromNumber(l[U++]);U<=y-17;U++)b=(b=b.multiply(K.fromNumber(10))).add(K.fromNumber(l[U]));for(w=K.fromNumber(l[U++]);U<=y;U++)w=(w=w.multiply(K.fromNumber(10))).add(K.fromNumber(l[U]))}var D,j,k,M,B=function(t,e){if(!t&&!e)return{high:K.fromNumber(0),low:K.fromNumber(0)};var n=t.shiftRightUnsigned(32),r=new K(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new K(e.getLowBits(),0),s=n.multiply(o),a=n.multiply(i),u=r.multiply(o),c=r.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new K(a.getLowBits(),0).add(u).add(c.shiftRightUnsigned(32)),{high:s=s.add(a.shiftRightUnsigned(32)),low:c=a.shiftLeft(32).add(new K(c.getLowBits(),0))}}(b,K.fromString("100000000000000000"));B.low=B.low.add(w),D=B.low,j=w,k=D.high>>>0,M=j.high>>>0,(k<M||k===M&&D.low>>>0<j.low>>>0)&&(B.high=B.high.add(K.fromNumber(1))),n=g+6176;var q={low:K.fromNumber(0),high:K.fromNumber(0)};B.high.shiftRightUnsigned(49).and(K.fromNumber(1)).equals(K.fromNumber(1))?(q.high=q.high.or(K.fromNumber(3).shiftLeft(61)),q.high=q.high.or(K.fromNumber(n).and(K.fromNumber(16383).shiftLeft(47))),q.high=q.high.or(B.high.and(K.fromNumber(0x7fffffffffff)))):(q.high=q.high.or(K.fromNumber(16383&n).shiftLeft(49)),q.high=q.high.or(B.high.and(K.fromNumber(562949953421311)))),q.low=B.low,r&&(q.high=q.high.or(K.fromString("9223372036854775808")));var F=m.alloc(16);return _=0,F[_++]=255&q.low.low,F[_++]=q.low.low>>8&255,F[_++]=q.low.low>>16&255,F[_++]=q.low.low>>24&255,F[_++]=255&q.low.high,F[_++]=q.low.high>>8&255,F[_++]=q.low.high>>16&255,F[_++]=q.low.high>>24&255,F[_++]=255&q.high.low,F[_++]=q.high.low>>8&255,F[_++]=q.high.low>>16&255,F[_++]=q.high.low>>24&255,F[_++]=255&q.high.high,F[_++]=q.high.high>>8&255,F[_++]=q.high.high>>16&255,F[_++]=q.high.high>>24&255,new t(F)},t.prototype.toString=function(){for(var t,e=0,n=new Array(36),r=0;r<n.length;r++)n[r]=0;var o,i,s,a=0,u=!1,c={parts:[0,0,0,0]},f=[];a=0;var l=this.bytes,h=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,p=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,d=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,y=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24;a=0,{low:new K(h,p),high:new K(d,y)}.high.lessThan(K.ZERO)&&f.push("-");var g=y>>26&31;if(g>>3==3){if(30===g)return f.join("")+"Infinity";if(31===g)return"NaN";t=y>>15&16383,o=8+(y>>14&1)}else o=y>>14&7,t=y>>17&16383;var v=t-6176;if(c.parts[0]=(16383&y)+((15&o)<<14),c.parts[1]=d,c.parts[2]=p,c.parts[3]=h,0===c.parts[0]&&0===c.parts[1]&&0===c.parts[2]&&0===c.parts[3])u=!0;else for(s=3;s>=0;s--){var m=0,b=rt(c);if(c=b.quotient,m=b.rem.low)for(i=8;i>=0;i--)n[9*s+i]=m%10,m=Math.floor(m/10)}if(u)e=1,n[a]=0;else for(e=36;!n[a];)e-=1,a+=1;var w=e-1+v;if(w>=34||w<=-7||v>0){if(e>34)return f.push("".concat(0)),v>0?f.push("E+".concat(v)):v<0&&f.push("E".concat(v)),f.join("");f.push("".concat(n[a++])),(e-=1)&&f.push(".");for(r=0;r<e;r++)f.push("".concat(n[a++]));f.push("E"),w>0?f.push("+".concat(w)):f.push("".concat(w))}else if(v>=0)for(r=0;r<e;r++)f.push("".concat(n[a++]));else{var _=e+v;if(_>0)for(r=0;r<_;r++)f.push("".concat(n[a++]));else f.push("0");for(f.push(".");_++<0;)f.push("0");for(r=0;r<e-Math.max(_-1,0);r++)f.push("".concat(n[a++]))}return f.join("")},t.prototype.toJSON=function(){return{$numberDecimal:this.toString()}},t.prototype.toExtendedJSON=function(){return{$numberDecimal:this.toString()}},t.fromExtendedJSON=function(e){return t.fromString(e.$numberDecimal)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Decimal128("'.concat(this.toString(),'")')},t}();Object.defineProperty(it.prototype,"_bsontype",{value:"Decimal128"});var st=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toJSON=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toExtendedJSON=function(t){return t&&(t.legacy||t.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-".concat(this.value.toFixed(1))}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}},t.fromExtendedJSON=function(e,n){var r=parseFloat(e.$numberDouble);return n&&n.relaxed?r:new t(r)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toExtendedJSON();return"new Double(".concat(t.$numberDouble,")")},t}();Object.defineProperty(st.prototype,"_bsontype",{value:"Double"});var at=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=0|+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(t){return t&&(t.relaxed||t.legacy)?this.value:{$numberInt:this.value.toString()}},t.fromExtendedJSON=function(e,n){return n&&n.relaxed?parseInt(e.$numberInt,10):new t(e.$numberInt)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new Int32(".concat(this.valueOf(),")")},t}();Object.defineProperty(at.prototype,"_bsontype",{value:"Int32"});var ut=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$maxKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MaxKey()"},t}();Object.defineProperty(ut.prototype,"_bsontype",{value:"MaxKey"});var ct=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$minKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MinKey()"},t}();Object.defineProperty(ct.prototype,"_bsontype",{value:"MinKey"});var ft=new RegExp("^[0-9a-fA-F]{24}$"),lt=null,ht=Symbol("id"),pt=function(){function t(e){if(!(this instanceof t))return new t(e);var n;if("object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new E("Argument passed in must have an id that is of type string or Buffer");n="toHexString"in e&&"function"==typeof e.toHexString?m.from(e.toHexString(),"hex"):e.id}else n=e;if(null==n||"number"==typeof n)this[ht]=t.generate("number"==typeof n?n:void 0);else if(ArrayBuffer.isView(n)&&12===n.byteLength)this[ht]=n instanceof m?n:P(n);else{if("string"!=typeof n)throw new E("Argument passed in does not match the accepted types");if(12===n.length){var r=m.from(n);if(12!==r.byteLength)throw new E("Argument passed in must be a string of 12 bytes");this[ht]=r}else{if(24!==n.length||!ft.test(n))throw new E("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[ht]=m.from(n,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[ht]},set:function(e){this[ht]=e,t.cacheHexString&&(this.__id=e.toString("hex"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"generationTime",{get:function(){return this.id.readInt32BE(0)},set:function(t){this.id.writeUInt32BE(t,0)},enumerable:!1,configurable:!0}),t.prototype.toHexString=function(){if(t.cacheHexString&&this.__id)return this.__id;var e=this.id.toString("hex");return t.cacheHexString&&!this.__id&&(this.__id=e),e},t.getInc=function(){return t.index=(t.index+1)%16777215},t.generate=function(e){"number"!=typeof e&&(e=Math.floor(Date.now()/1e3));var n=t.getInc(),r=m.alloc(12);return r.writeUInt32BE(e,0),null===lt&&(lt=A(5)),r[4]=lt[0],r[5]=lt[1],r[6]=lt[2],r[7]=lt[3],r[8]=lt[4],r[11]=255&n,r[10]=n>>8&255,r[9]=n>>16&255,r},t.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},t.prototype.toJSON=function(){return this.toHexString()},t.prototype.equals=function(e){if(null==e)return!1;if(e instanceof t)return this[ht][11]===e[ht][11]&&this[ht].equals(e[ht]);if("string"==typeof e&&t.isValid(e)&&12===e.length&&N(this.id))return e===m.prototype.toString.call(this.id,"latin1");if("string"==typeof e&&t.isValid(e)&&24===e.length)return e.toLowerCase()===this.toHexString();if("string"==typeof e&&t.isValid(e)&&12===e.length)return m.from(e).equals(this.id);if("object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString){var n=e.toHexString(),r=this.toHexString().toLowerCase();return"string"==typeof n&&n.toLowerCase()===r}return!1},t.prototype.getTimestamp=function(){var t=new Date,e=this.id.readUInt32BE(0);return t.setTime(1e3*Math.floor(e)),t},t.createPk=function(){return new t},t.createFromTime=function(e){var n=m.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n.writeUInt32BE(e,0),new t(n)},t.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new E("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(m.from(e,"hex"))},t.isValid=function(e){if(null==e)return!1;try{return new t(e),!0}catch(t){return!1}},t.prototype.toExtendedJSON=function(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}},t.fromExtendedJSON=function(e){return new t(e.$oid)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new ObjectId("'.concat(this.toHexString(),'")')},t.index=Math.floor(16777215*Math.random()),t}();Object.defineProperty(pt.prototype,"generate",{value:L((function(t){return pt.generate(t)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(pt.prototype,"getInc",{value:L((function(){return pt.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(pt.prototype,"get_inc",{value:L((function(){return pt.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(pt,"get_inc",{value:L((function(){return pt.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(pt.prototype,"_bsontype",{value:"ObjectID"});var dt=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(this.pattern=e,this.options=(null!=n?n:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new _("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new _("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.options)));for(var r=0;r<this.options.length;r++)if("i"!==this.options[r]&&"m"!==this.options[r]&&"x"!==this.options[r]&&"l"!==this.options[r]&&"s"!==this.options[r]&&"u"!==this.options[r])throw new _("The regular expression option [".concat(this.options[r],"] is not supported"))}return t.parseOptions=function(t){return t?t.split("").sort().join(""):""},t.prototype.toExtendedJSON=function(t){return(t=t||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}},t.fromExtendedJSON=function(e){if("$regex"in e){if("string"==typeof e.$regex)return new t(e.$regex,t.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new t(e.$regularExpression.pattern,t.parseOptions(e.$regularExpression.options));throw new E("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(e)))},t}();Object.defineProperty(dt.prototype,"_bsontype",{value:"BSONRegExp"});var yt=function(){function t(e){if(!(this instanceof t))return new t(e);this.value=e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(){return this.value},t.prototype.inspect=function(){return'new BSONSymbol("'.concat(this.value,'")')},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(){return{$symbol:this.value}},t.fromExtendedJSON=function(e){return new t(e.$symbol)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t}();Object.defineProperty(yt.prototype,"_bsontype",{value:"Symbol"});var gt=function(t){function e(n,r){var o=this;return o instanceof e?(o=K.isLong(n)?t.call(this,n.low,n.high,!0)||this:C(n)&&void 0!==n.t&&void 0!==n.i?t.call(this,n.i,n.t,!0)||this:t.call(this,n,r,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new e(n,r)}return w(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(K.fromInt(t,!0))},e.fromNumber=function(t){return new e(K.fromNumber(t,!0))},e.fromBits=function(t,n){return new e(t,n)},e.fromString=function(t,n){return new e(K.fromString(t,!0,n))},e.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},e.fromExtendedJSON=function(t){return new e(t.$timestamp)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Timestamp({ t: ".concat(this.getHighBits(),", i: ").concat(this.getLowBits()," })")},e.MAX_VALUE=K.MAX_UNSIGNED_VALUE,e}(K);function vt(t){return C(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}var mt={$oid:pt,$binary:q,$uuid:q,$symbol:yt,$numberInt:at,$numberDecimal:it,$numberDouble:st,$numberLong:K,$minKey:ct,$maxKey:ut,$regex:dt,$regularExpression:dt,$timestamp:gt};function bt(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function wt(t,e){if(("object"==typeof t||"function"==typeof t)&&null!==t){var n=e.seenObjects.findIndex((function(e){return e.obj===t}));if(-1!==n){var r=e.seenObjects.map((function(t){return t.propertyName})),o=r.slice(0,n).map((function(t){return"".concat(t," -> ")})).join(""),i=r[n],s=" -> "+r.slice(n+1,r.length-1).map((function(t){return"".concat(t," -> ")})).join(""),a=r[r.length-1],u=" ".repeat(o.length+i.length/2),c="-".repeat(s.length+(i.length+a.length)/2-1);throw new E("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(s).concat(a,"\n")+" ".concat(u,"\\").concat(c,"/"))}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((function(t,n){e.seenObjects.push({propertyName:"index ".concat(n),obj:null});try{return wt(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||x(t)){var f=t.getTime(),l=f>-1&&f<2534023188e5;return e.legacy?e.relaxed&&l?{$date:t.getTime()}:{$date:bt(t)}:e.relaxed&&l?{$date:bt(t)}:{$date:{$numberLong:t.getTime().toString()}}}if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Math.floor(t)===t){var h=t>=-0x8000000000000000&&t<=0x8000000000000000;if(t>=-2147483648&&t<=2147483647)return{$numberInt:t.toString()};if(h)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||R(t)){var p=t.flags;if(void 0===p){var d=t.toString().match(/[gimuy]*$/);d&&(p=d[0])}return new dt(t.source,p).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new _("not an object instance");var n=t._bsontype;if(void 0===n){var r={};for(var o in t){e.seenObjects.push({propertyName:o,obj:null});try{var i=wt(t[o],e);"__proto__"===o?Object.defineProperty(r,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):r[o]=i}finally{e.seenObjects.pop()}}return r}if(vt(t)){var s=t;if("function"!=typeof s.toExtendedJSON){var a=Et[t._bsontype];if(!a)throw new E("Unrecognized or invalid _bsontype: "+t._bsontype);s=a(s)}return"Code"===n&&s.scope?s=new W(s.code,wt(s.scope,e)):"DBRef"===n&&s.oid&&(s=new V(wt(s.collection,e),wt(s.oid,e),wt(s.db,e),wt(s.fields,e))),s.toExtendedJSON(e)}throw new _("_bsontype must be a string, but was: "+typeof n)}(t,e):t}var _t,Et={Binary:function(t){return new q(t.value(),t.sub_type)},Code:function(t){return new W(t.code,t.scope)},DBRef:function(t){return new V(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new it(t.bytes)},Double:function(t){return new st(t.value)},Int32:function(t){return new at(t.value)},Long:function(t){return K.fromBits(null!=t.low?t.low:t.low_,null!=t.low?t.high:t.high_,null!=t.low?t.unsigned:t.unsigned_)},MaxKey:function(){return new ut},MinKey:function(){return new ct},ObjectID:function(t){return new pt(t)},ObjectId:function(t){return new pt(t)},BSONRegExp:function(t){return new dt(t.pattern,t.options)},Symbol:function(t){return new yt(t.value)},Timestamp:function(t){return gt.fromBits(t.low,t.high)}};!function(t){function e(t,e){var n=Object.assign({},{relaxed:!0,legacy:!1},e);return"boolean"==typeof n.relaxed&&(n.strict=!n.relaxed),"boolean"==typeof n.strict&&(n.relaxed=!n.strict),JSON.parse(t,(function(t,e){if(-1!==t.indexOf("\0"))throw new _("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(t)));return function t(e,n){if(void 0===n&&(n={}),"number"==typeof e){if(n.relaxed||n.legacy)return e;if(Math.floor(e)===e){if(e>=-2147483648&&e<=2147483647)return new at(e);if(e>=-0x8000000000000000&&e<=0x8000000000000000)return K.fromNumber(e)}return new st(e)}if(null==e||"object"!=typeof e)return e;if(e.$undefined)return null;for(var r=Object.keys(e).filter((function(t){return t.startsWith("$")&&null!=e[t]})),o=0;o<r.length;o++){var i=mt[r[o]];if(i)return i.fromExtendedJSON(e,n)}if(null!=e.$date){var s=e.$date,a=new Date;return n.legacy?"number"==typeof s?a.setTime(s):"string"==typeof s&&a.setTime(Date.parse(s)):"string"==typeof s?a.setTime(Date.parse(s)):K.isLong(s)?a.setTime(s.toNumber()):"number"==typeof s&&n.relaxed&&a.setTime(s),a}if(null!=e.$code){var u=Object.assign({},e);return e.$scope&&(u.$scope=t(e.$scope)),W.fromExtendedJSON(e)}if($(e)||e.$dbPointer){var c=e.$ref?e:e.$dbPointer;if(c instanceof V)return c;var f=Object.keys(c).filter((function(t){return t.startsWith("$")})),l=!0;if(f.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(l=!1)})),l)return V.fromExtendedJSON(c)}return e}(e,n)}))}function n(t,e,n,r){null!=n&&"object"==typeof n&&(r=n,n=0),null==e||"object"!=typeof e||Array.isArray(e)||(r=e,e=void 0,n=0);var o=wt(t,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,n)}t.parse=e,t.stringify=n,t.serialize=function(t,e){return e=e||{},JSON.parse(n(t,e))},t.deserialize=function(t,n){return n=n||{},e(JSON.stringify(t),n)}}(_t||(_t={}));var It=S();It.Map?It.Map:function(){function t(t){void 0===t&&(t=[]),this._keys=[],this._values={};for(var e=0;e<t.length;e++)if(null!=t[e]){var n=t[e],r=n[0],o=n[1];this._keys.push(r),this._values[r]={v:o,i:this._keys.length-1}}}t.prototype.clear=function(){this._keys=[],this._values={}},t.prototype.delete=function(t){var e=this._values[t];return null!=e&&(delete this._values[t],this._keys.splice(e.i,1),!0)},t.prototype.entries=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?[n,t._values[n].v]:void 0,done:void 0===n}}}},t.prototype.forEach=function(t,e){e=e||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];t.call(e,this._values[r].v,r,e)}},t.prototype.get=function(t){return this._values[t]?this._values[t].v:void 0},t.prototype.has=function(t){return null!=this._values[t]},t.prototype.keys=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},t.prototype.set=function(t,e){return this._values[t]?(this._values[t].v=e,this):(this._keys.push(t),this._values[t]={v:e,i:this._keys.length-1},this)},t.prototype.values=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?t._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0})}();K.fromNumber(M),K.fromNumber(B);new Set(["$db","$ref","$id","$clusterTime"]);var St=new Uint8Array(8);new DataView(St.buffer,St.byteOffset,St.byteLength);m.alloc(17825792)}).call(this,n(7))},function(t,e,n){"use strict";var r;n.d(e,"c",(function(){return r})),n.d(e,"a",(function(){return o})),n.d(e,"b",(function(){return i})),n.d(e,"d",(function(){return s})),function(t){t.local="local",t.none="none",t.session="session"}(r||(r={}));var o=function(){},i=function(){};function s(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";for(var i in n)""===o?!r&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},function(t,e,n){var r;t.exports=(r=r||function(t,e){var n=Object.create||function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}}(),r={},o=r.lib={},i=o.Base={extend:function(t){var e=n(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=o.WordArray=i.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;e[r+i>>>2]|=s<<24-(r+i)%4*8}else for(i=0;i<o;i+=4)e[r+i>>>2]=n[i>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=i.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n,r=[],o=function(e){e=e;var n=987654321,r=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&r)<<16)+(e=18e3*(65535&e)+(e>>16)&r)&r;return o/=4294967296,(o+=.5)*(t.random()>.5?1:-1)}},i=0;i<e;i+=4){var a=o(4294967296*(n||t.random()));n=987654071*a(),r.push(4294967296*a()|0)}return new s.init(r,e)}}),a=r.enc={},u=a.Hex={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new s.init(n,e/2)}},c=a.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r++)n[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new s.init(n,e)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},l=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,a=o/(4*i),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*i,c=t.min(4*u,o);if(u){for(var f=0;f<u;f+=i)this._doProcessBlock(r,f);var l=r.splice(0,u);n.sigBytes-=c}return new s.init(l,c)},clone:function(){var t=i.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),h=(o.Hasher=l.extend({cfg:i.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,n){return new t.init(n).finalize(e)}},_createHmacHelper:function(t){return function(e,n){return new h.HMAC.init(t,n).finalize(e)}}}),r.algo={});return r}(Math),r)},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.d(e,"f",(function(){return o})),n.d(e,"d",(function(){return i})),n.d(e,"e",(function(){return a})),n.d(e,"c",(function(){return u})),n.d(e,"b",(function(){return c})),n.d(e,"a",(function(){return f}));var r="@cloudbase/js-sdk";function o(t){r=t}function i(){return r}var s="https:";function a(t){s=t}function u(){return s}var c=!1,f="https://support.qq.com/products/148793"},function(t,e,n){var r;t.exports=(r=n(6),r.enc.Utf8)},function(t,e,n){"use strict";n.r(e),function(t){n.d(e,"CloudbaseCache",(function(){return l}));var r,o=n(5),i=n(1),s=n(2),a=(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),u=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},c=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},f=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return a(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(o.b);var l=function(){function e(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,o=t.keys,a=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:(Object(i.printWarn)(s.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(e.root));case"none":return new f(e.root);default:return e.localStorage?e.localStorage:(Object(i.printWarn)(s.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(e.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=a)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:s.ERRORS.OPERATION_FAIL,msg:"["+Object(s.getSdkName)()+"]["+s.ERRORS.OPERATION_FAIL+"]setStore failed",info:t}))}}else Object(i.printWarn)(s.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(t,e,n){return u(this,void 0,void 0,(function(){var r;return c(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,n){var r;if("async"!==this.mode){try{if(void 0!==t&&(null===(r=t.env)||void 0===r?void 0:r.tcb_token))return t.env.tcb_token;if(!this.storage)return""}catch(t){return""}n=n||"localCachev1";var o=this.storage.getItem(e);return o&&o.indexOf(n)>=0?JSON.parse(o).content:""}Object(i.printWarn)(s.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,n){var r;return u(this,void 0,void 0,(function(){var o;return c(this,(function(i){switch(i.label){case 0:try{if(void 0!==t&&(null===(r=t.env)||void 0===r?void 0:r.tcb_token))return[2,t.env.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return n=n||"localCachev1",[4,this.storage.getItem(e)];case 1:return(o=i.sent())&&o.indexOf(n)>=0?[2,JSON.parse(o).content]:[2,""]}}))}))},e.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):Object(i.printWarn)(s.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},e}()}.call(this,n(11))},function(t,e){var n,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(t){r=s}}();var u,c=[],f=!1,l=-1;function h(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&p())}function p(){if(!f){var t=a(h);f=!0;for(var e=c.length;e;){for(u=c,c=[];++l<e;)u&&u[l].run();l=-1,e=c.length}u=null,f=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function y(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new d(t,e)),1!==c.length||f||a(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e){},function(t,e,n){var r;t.exports=(r=n(6),n(21),n(22),r.HmacSHA256)},function(t,e,n){var r,o,i;t.exports=(i=n(6),o=(r=i).lib.WordArray,r.enc.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp();for(var o=[],i=0;i<n;i+=3)for(var s=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a<n;a++)o.push(r.charAt(s>>>6*(3-a)&63));var u=r.charAt(64);if(u)for(;o.length%4;)o.push(u);return o.join("")},parse:function(t){var e=t.length,n=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var i=0;i<n.length;i++)r[n.charCodeAt(i)]=i}var s=n.charAt(64);if(s){var a=t.indexOf(s);-1!==a&&(e=a)}return function(t,e,n){for(var r=[],i=0,s=0;s<e;s++)if(s%4){var a=n[t.charCodeAt(s-1)]<<s%4*2,u=n[t.charCodeAt(s)]>>>6-s%4*2;r[i>>>2]|=(a|u)<<24-i%4*8,i++}return o.create(r,i)}(t,e,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)},function(t,e,n){(function(e){var n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/,o=/^\./,i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g,a=/^\[object .+?Constructor\]$/,u=/^(?:0|[1-9]\d*)$/,c="object"==typeof e&&e&&e.Object===Object&&e,f="object"==typeof self&&self&&self.Object===Object&&self,l=c||f||Function("return this")();var h,p=Array.prototype,d=Function.prototype,y=Object.prototype,g=l["__core-js_shared__"],v=(h=/[^.]+$/.exec(g&&g.keys&&g.keys.IE_PROTO||""))?"Symbol(src)_1."+h:"",m=d.toString,b=y.hasOwnProperty,w=y.toString,_=RegExp("^"+m.call(b).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),E=l.Symbol,I=p.splice,S=j(l,"Map"),O=j(Object,"create"),A=E?E.prototype:void 0,T=A?A.toString:void 0;function N(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function R(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function x(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function C(t,e,n){var r=t[e];b.call(t,e)&&F(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function L(t,e){for(var n=t.length;n--;)if(F(t[n][0],e))return n;return-1}function P(t){return!(!$(t)||(e=t,v&&v in e))&&(function(t){var e=$(t)?w.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?_:a).test(function(t){if(null!=t){try{return m.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function U(t,e,o,i){if(!$(t))return t;for(var s=-1,a=(e=function(t,e){if(W(t))return!1;var o=typeof t;if("number"==o||"symbol"==o||"boolean"==o||null==t||V(t))return!0;return r.test(t)||!n.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:function(t){return W(t)?t:M(t)}(e)).length,u=a-1,c=t;null!=c&&++s<a;){var f=B(e[s]),l=o;if(s!=u){var h=c[f];void 0===(l=i?i(h,f,c):void 0)&&(l=$(h)?h:k(e[s+1])?[]:{})}C(c,f,l),c=c[f]}return t}function D(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function j(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return P(n)?n:void 0}function k(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||u.test(t))&&t>-1&&t%1==0&&t<e}N.prototype.clear=function(){this.__data__=O?O(null):{}},N.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},N.prototype.get=function(t){var e=this.__data__;if(O){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return b.call(e,t)?e[t]:void 0},N.prototype.has=function(t){var e=this.__data__;return O?void 0!==e[t]:b.call(e,t)},N.prototype.set=function(t,e){return this.__data__[t]=O&&void 0===e?"__lodash_hash_undefined__":e,this},R.prototype.clear=function(){this.__data__=[]},R.prototype.delete=function(t){var e=this.__data__,n=L(e,t);return!(n<0)&&(n==e.length-1?e.pop():I.call(e,n,1),!0)},R.prototype.get=function(t){var e=this.__data__,n=L(e,t);return n<0?void 0:e[n][1]},R.prototype.has=function(t){return L(this.__data__,t)>-1},R.prototype.set=function(t,e){var n=this.__data__,r=L(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},x.prototype.clear=function(){this.__data__={hash:new N,map:new(S||R),string:new N}},x.prototype.delete=function(t){return D(this,t).delete(t)},x.prototype.get=function(t){return D(this,t).get(t)},x.prototype.has=function(t){return D(this,t).has(t)},x.prototype.set=function(t,e){return D(this,t).set(t,e),this};var M=q((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(V(t))return T?T.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return o.test(t)&&n.push(""),t.replace(i,(function(t,e,r,o){n.push(r?o.replace(s,"$1"):e||t)})),n}));function B(t){if("string"==typeof t||V(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function q(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(q.Cache||x),n}function F(t,e){return t===e||t!=t&&e!=e}q.Cache=x;var W=Array.isArray;function $(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function V(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==w.call(t)}t.exports=function(t,e,n){return null==t?t:U(t,e,n)}}).call(this,n(7))},function(t,e,n){(function(e){var n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/,o=/^\./,i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g,a=/^\[object .+?Constructor\]$/,u="object"==typeof e&&e&&e.Object===Object&&e,c="object"==typeof self&&self&&self.Object===Object&&self,f=u||c||Function("return this")();var l,h=Array.prototype,p=Function.prototype,d=Object.prototype,y=f["__core-js_shared__"],g=(l=/[^.]+$/.exec(y&&y.keys&&y.keys.IE_PROTO||""))?"Symbol(src)_1."+l:"",v=p.toString,m=d.hasOwnProperty,b=d.toString,w=RegExp("^"+v.call(m).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_=f.Symbol,E=h.splice,I=D(f,"Map"),S=D(Object,"create"),O=_?_.prototype:void 0,A=O?O.toString:void 0;function T(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function N(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function R(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function x(t,e){for(var n,r,o=t.length;o--;)if((n=t[o][0])===(r=e)||n!=n&&r!=r)return o;return-1}function C(t){return!(!F(t)||(e=t,g&&g in e))&&(function(t){var e=F(t)?b.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?w:a).test(function(t){if(null!=t){try{return v.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function L(t,e){t=function(t,e){return 1==e.length?t:function(t,e){for(var n=0,r=(e=j(e,t)?[e]:P(e)).length;null!=t&&n<r;)t=t[M(e[n++])];return n&&n==r?t:void 0}(t,function(t,e,n){var r=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var i=Array(o);++r<o;)i[r]=t[r+e];return i}(e,0,-1))}(t,e=j(e,t)?[e]:P(e));var n,r,o=M((r=(n=e)?n.length:0)?n[r-1]:void 0);return!(null!=t&&m.call(t,o))||delete t[o]}function P(t){return q(t)?t:k(t)}function U(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function D(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return C(n)?n:void 0}function j(t,e){if(q(t))return!1;var o=typeof t;return!("number"!=o&&"symbol"!=o&&"boolean"!=o&&null!=t&&!W(t))||(r.test(t)||!n.test(t)||null!=e&&t in Object(e))}T.prototype.clear=function(){this.__data__=S?S(null):{}},T.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},T.prototype.get=function(t){var e=this.__data__;if(S){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return m.call(e,t)?e[t]:void 0},T.prototype.has=function(t){var e=this.__data__;return S?void 0!==e[t]:m.call(e,t)},T.prototype.set=function(t,e){return this.__data__[t]=S&&void 0===e?"__lodash_hash_undefined__":e,this},N.prototype.clear=function(){this.__data__=[]},N.prototype.delete=function(t){var e=this.__data__,n=x(e,t);return!(n<0)&&(n==e.length-1?e.pop():E.call(e,n,1),!0)},N.prototype.get=function(t){var e=this.__data__,n=x(e,t);return n<0?void 0:e[n][1]},N.prototype.has=function(t){return x(this.__data__,t)>-1},N.prototype.set=function(t,e){var n=this.__data__,r=x(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},R.prototype.clear=function(){this.__data__={hash:new T,map:new(I||N),string:new T}},R.prototype.delete=function(t){return U(this,t).delete(t)},R.prototype.get=function(t){return U(this,t).get(t)},R.prototype.has=function(t){return U(this,t).has(t)},R.prototype.set=function(t,e){return U(this,t).set(t,e),this};var k=B((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(W(t))return A?A.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return o.test(t)&&n.push(""),t.replace(i,(function(t,e,r,o){n.push(r?o.replace(s,"$1"):e||t)})),n}));function M(t){if("string"==typeof t||W(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function B(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(B.Cache||R),n}B.Cache=R;var q=Array.isArray;function F(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function W(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==b.call(t)}t.exports=function(t,e){return null==t||L(t,e)}}).call(this,n(7))},function(t,e,n){(function(t,n){var r="[object Arguments]",o="[object Function]",i="[object GeneratorFunction]",s="[object Map]",a="[object Set]",u=/\w*$/,c=/^\[object .+?Constructor\]$/,f=/^(?:0|[1-9]\d*)$/,l={};l[r]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object DataView]"]=l["[object Boolean]"]=l["[object Date]"]=l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l[s]=l["[object Number]"]=l["[object Object]"]=l["[object RegExp]"]=l[a]=l["[object String]"]=l["[object Symbol]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l["[object Error]"]=l[o]=l["[object WeakMap]"]=!1;var h="object"==typeof t&&t&&t.Object===Object&&t,p="object"==typeof self&&self&&self.Object===Object&&self,d=h||p||Function("return this")(),y=e&&!e.nodeType&&e,g=y&&"object"==typeof n&&n&&!n.nodeType&&n,v=g&&g.exports===y;function m(t,e){return t.set(e[0],e[1]),t}function b(t,e){return t.add(e),t}function w(t,e,n,r){var o=-1,i=t?t.length:0;for(r&&i&&(n=t[++o]);++o<i;)n=e(n,t[o],o,t);return n}function _(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function E(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function I(t,e){return function(n){return t(e(n))}}function S(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}var O,A=Array.prototype,T=Function.prototype,N=Object.prototype,R=d["__core-js_shared__"],x=(O=/[^.]+$/.exec(R&&R.keys&&R.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"",C=T.toString,L=N.hasOwnProperty,P=N.toString,U=RegExp("^"+C.call(L).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),D=v?d.Buffer:void 0,j=d.Symbol,k=d.Uint8Array,M=I(Object.getPrototypeOf,Object),B=Object.create,q=N.propertyIsEnumerable,F=A.splice,W=Object.getOwnPropertySymbols,$=D?D.isBuffer:void 0,V=I(Object.keys,Object),H=gt(d,"DataView"),G=gt(d,"Map"),J=gt(d,"Promise"),K=gt(d,"Set"),Y=gt(d,"WeakMap"),z=gt(Object,"create"),Q=_t(H),Z=_t(G),X=_t(J),tt=_t(K),et=_t(Y),nt=j?j.prototype:void 0,rt=nt?nt.valueOf:void 0;function ot(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function it(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function st(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function at(t){this.__data__=new it(t)}function ut(t,e){var n=It(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&St(t)}(t)&&L.call(t,"callee")&&(!q.call(t,"callee")||P.call(t)==r)}(t)?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],o=n.length,i=!!o;for(var s in t)!e&&!L.call(t,s)||i&&("length"==s||bt(s,o))||n.push(s);return n}function ct(t,e,n){var r=t[e];L.call(t,e)&&Et(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function ft(t,e){for(var n=t.length;n--;)if(Et(t[n][0],e))return n;return-1}function lt(t,e,n,c,f,h,p){var d;if(c&&(d=h?c(t,f,h,p):c(t)),void 0!==d)return d;if(!Tt(t))return t;var y=It(t);if(y){if(d=function(t){var e=t.length,n=t.constructor(e);e&&"string"==typeof t[0]&&L.call(t,"index")&&(n.index=t.index,n.input=t.input);return n}(t),!e)return function(t,e){var n=-1,r=t.length;e||(e=Array(r));for(;++n<r;)e[n]=t[n];return e}(t,d)}else{var g=mt(t),v=g==o||g==i;if(Ot(t))return function(t,e){if(e)return t.slice();var n=new t.constructor(t.length);return t.copy(n),n}(t,e);if("[object Object]"==g||g==r||v&&!h){if(_(t))return h?t:{};if(d=function(t){return"function"!=typeof t.constructor||wt(t)?{}:(e=M(t),Tt(e)?B(e):{});var e}(v?{}:t),!e)return function(t,e){return dt(t,vt(t),e)}(t,function(t,e){return t&&dt(e,Nt(e),t)}(d,t))}else{if(!l[g])return h?t:{};d=function(t,e,n,r){var o=t.constructor;switch(e){case"[object ArrayBuffer]":return pt(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var n=e?pt(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t,e){var n=e?pt(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}(t,r);case s:return function(t,e,n){return w(e?n(E(t),!0):E(t),m,new t.constructor)}(t,r,n);case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,u.exec(t));return e.lastIndex=t.lastIndex,e}(t);case a:return function(t,e,n){return w(e?n(S(t),!0):S(t),b,new t.constructor)}(t,r,n);case"[object Symbol]":return i=t,rt?Object(rt.call(i)):{}}var i}(t,g,lt,e)}}p||(p=new at);var I=p.get(t);if(I)return I;if(p.set(t,d),!y)var O=n?function(t){return function(t,e,n){var r=e(t);return It(t)?r:function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}(r,n(t))}(t,Nt,vt)}(t):Nt(t);return function(t,e){for(var n=-1,r=t?t.length:0;++n<r&&!1!==e(t[n],n,t););}(O||t,(function(r,o){O&&(r=t[o=r]),ct(d,o,lt(r,e,n,c,o,t,p))})),d}function ht(t){return!(!Tt(t)||(e=t,x&&x in e))&&(At(t)||_(t)?U:c).test(_t(t));var e}function pt(t){var e=new t.constructor(t.byteLength);return new k(e).set(new k(t)),e}function dt(t,e,n,r){n||(n={});for(var o=-1,i=e.length;++o<i;){var s=e[o],a=r?r(n[s],t[s],s,n,t):void 0;ct(n,s,void 0===a?t[s]:a)}return n}function yt(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function gt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return ht(n)?n:void 0}ot.prototype.clear=function(){this.__data__=z?z(null):{}},ot.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},ot.prototype.get=function(t){var e=this.__data__;if(z){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return L.call(e,t)?e[t]:void 0},ot.prototype.has=function(t){var e=this.__data__;return z?void 0!==e[t]:L.call(e,t)},ot.prototype.set=function(t,e){return this.__data__[t]=z&&void 0===e?"__lodash_hash_undefined__":e,this},it.prototype.clear=function(){this.__data__=[]},it.prototype.delete=function(t){var e=this.__data__,n=ft(e,t);return!(n<0)&&(n==e.length-1?e.pop():F.call(e,n,1),!0)},it.prototype.get=function(t){var e=this.__data__,n=ft(e,t);return n<0?void 0:e[n][1]},it.prototype.has=function(t){return ft(this.__data__,t)>-1},it.prototype.set=function(t,e){var n=this.__data__,r=ft(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},st.prototype.clear=function(){this.__data__={hash:new ot,map:new(G||it),string:new ot}},st.prototype.delete=function(t){return yt(this,t).delete(t)},st.prototype.get=function(t){return yt(this,t).get(t)},st.prototype.has=function(t){return yt(this,t).has(t)},st.prototype.set=function(t,e){return yt(this,t).set(t,e),this},at.prototype.clear=function(){this.__data__=new it},at.prototype.delete=function(t){return this.__data__.delete(t)},at.prototype.get=function(t){return this.__data__.get(t)},at.prototype.has=function(t){return this.__data__.has(t)},at.prototype.set=function(t,e){var n=this.__data__;if(n instanceof it){var r=n.__data__;if(!G||r.length<199)return r.push([t,e]),this;n=this.__data__=new st(r)}return n.set(t,e),this};var vt=W?I(W,Object):function(){return[]},mt=function(t){return P.call(t)};function bt(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||f.test(t))&&t>-1&&t%1==0&&t<e}function wt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||N)}function _t(t){if(null!=t){try{return C.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Et(t,e){return t===e||t!=t&&e!=e}(H&&"[object DataView]"!=mt(new H(new ArrayBuffer(1)))||G&&mt(new G)!=s||J&&"[object Promise]"!=mt(J.resolve())||K&&mt(new K)!=a||Y&&"[object WeakMap]"!=mt(new Y))&&(mt=function(t){var e=P.call(t),n="[object Object]"==e?t.constructor:void 0,r=n?_t(n):void 0;if(r)switch(r){case Q:return"[object DataView]";case Z:return s;case X:return"[object Promise]";case tt:return a;case et:return"[object WeakMap]"}return e});var It=Array.isArray;function St(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}(t.length)&&!At(t)}var Ot=$||function(){return!1};function At(t){var e=Tt(t)?P.call(t):"";return e==o||e==i}function Tt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Nt(t){return St(t)?ut(t):function(t){if(!wt(t))return V(t);var e=[];for(var n in Object(t))L.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}n.exports=function(t){return lt(t,!0,!0)}}).call(this,n(7),n(25)(t))},function(t,e,n){n(19),t.exports=n(20)},function(t,e,n){var r=function(t){"use strict";var e=Object.prototype,n=e.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",a=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function c(t,e,n,o){var i=e&&e.prototype instanceof h?e:h,s=Object.create(i.prototype),a=new O(o||[]);return r(s,"_invoke",{value:_(t,n,a)}),s}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function h(){}function p(){}function d(){}var y={};u(y,i,(function(){return this}));var g=Object.getPrototypeOf,v=g&&g(g(A([])));v&&v!==e&&n.call(v,i)&&(y=v);var m=d.prototype=h.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var o;r(this,"_invoke",{value:function(r,i){function s(){return new e((function(o,s){!function r(o,i,s,a){var u=f(t[o],t,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,s,a)}),(function(t){r("throw",t,s,a)})):e.resolve(l).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,a)}))}a(u.arg)}(r,i,o,s)}))}return o=o?o.then(s,s):s()}})}function _(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return T()}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var a=E(s,n);if(a){if(a===l)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=f(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function E(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;var o=f(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,l;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function A(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return p.prototype=d,r(m,"constructor",{value:d,configurable:!0}),r(d,"constructor",{value:p,configurable:!0}),p.displayName=u(d,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,u(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),u(w.prototype,s,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new w(c(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},b(m),u(m,a,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=A,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return s.type="throw",s.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var a=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(a&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;S(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:A(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=r(n(31)),i=n(29),s=n(23),a=n(24),u=n(30),c=n(26),f=n(28),l=r(n(27)).default.version;o.default.registerVersion(l);try{i.registerAuth(o.default),s.registerFunctions(o.default),a.registerStorage(o.default),f.registerDatabase(o.default),u.registerRealtime(o.default),c.registerAnalytics(o.default)}catch(t){}try{window.cloudbase=o.default}catch(t){}e.default=o.default,t.exports=o.default},function(t,e,n){var r;t.exports=(r=n(6),function(t){var e=r,n=e.lib,o=n.WordArray,i=n.Hasher,s=e.algo,a=[],u=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)e(r)&&(o<8&&(a[o]=n(t.pow(r,.5))),u[o]=n(t.pow(r,1/3)),o++),r++}();var c=[],f=s.SHA256=i.extend({_doReset:function(){this._hash=new o.init(a.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],a=n[4],f=n[5],l=n[6],h=n[7],p=0;p<64;p++){if(p<16)c[p]=0|t[e+p];else{var d=c[p-15],y=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=c[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;c[p]=y+c[p-7]+v+c[p-16]}var m=r&o^r&i^o&i,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),w=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&l)+u[p]+c[p];h=l,l=f,f=a,a=s+w|0,s=i,i=o,o=r,r=w+(b+m)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+f|0,n[6]=n[6]+l|0,n[7]=n[7]+h|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,o=8*e.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=t.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=i._createHelper(f),e.HmacSHA256=i._createHmacHelper(f)}(Math),r.SHA256)},function(t,e,n){var r,o,i,s;t.exports=(r=n(6),i=(o=r).lib.Base,s=o.enc.Utf8,void(o.algo.HMAC=i.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=s.parse(e));var n=t.blockSize,r=4*n;e.sigBytes>r&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),i=this._iKey=e.clone(),a=o.words,u=i.words,c=0;c<n;c++)a[c]^=1549556828,u[c]^=909522486;o.sigBytes=i.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,n=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(n))}})))},function(t,e,n){"use strict";n.r(e),n.d(e,"registerFunctions",(function(){return d}));var r=n(0),o=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},i=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},u=r.c.getSdkName,c=r.c.ERRORS,f=r.c.COMMUNITY_SITE_URL,l=r.f.execCallback,h=r.e.catchErrorsDecorator,p={name:"functions",entity:{callFunction:(new(function(){function t(){}return t.prototype.callFunction=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s,f,h,p,d,y,g,v;return a(this,(function(a){switch(a.label){case 0:if(n=t.name,r=t.data,o=t.query,i=t.parse,s=t.search,!n)throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[functions.callFunction] invalid function name"}));try{f=r?JSON.stringify(r):""}catch(t){throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[functions.callFunction] invalid data"}))}h="functions.invokeFunction",p={inQuery:o,parse:i,search:s,function_name:n,request_data:f},d=this.request,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,d.send(h,p)];case 2:if((y=a.sent()).code)return[2,l(e,null,y)];if(g=y.data.response_data,i)return[2,l(e,null,{result:g,requestId:y.requestId})];try{return g=JSON.parse(y.data.response_data),[2,l(e,null,{result:g,requestId:y.requestId})]}catch(t){l(e,new Error("["+u()+"]["+c.INVALID_PARAMS+"][functions.callFunction] response data must be json"))}return[3,4];case 3:return v=a.sent(),l(e,v),[3,4];case 4:return[2]}}))}))},o([h({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"callFunction",null),t}())).callFunction}};try{cloudbase.registerComponent(p)}catch(t){}function d(t){try{t.registerComponent(p)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"registerStorage",(function(){return w}));var r,o=n(0),i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},s=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},a=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},u=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},c=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};!function(t){t.put="put",t.post="post"}(r||(r={}));var f=o.c.getSdkName,l=o.c.ERRORS,h=o.c.COMMUNITY_SITE_URL,p=o.f.isArray,d=o.f.isString,y=o.f.isPalinObject,g=o.f.execCallback,v=o.e.catchErrorsDecorator,m=new(function(){function t(){}return t.prototype.uploadFile=function(t,e){return u(this,void 0,void 0,(function(){var n,o,s,a,u,h,p,y,v,m,b,w,_,E,I,S,O,A,T,N,R,x,C,L,P;return c(this,(function(c){switch(c.label){case 0:if(n=t.cloudPath,o=t.filePath,s=t.onUploadProgress,a=t.method,u=void 0===a?"put":a,h=t.headers,p=void 0===h?{}:h,!d(n)||!o)throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.uploadFile] invalid params"}));return y={put:r.put,post:r.post}[u.toLocaleLowerCase()]||r.put,"storage.getUploadMetadata",v=this.request,m={path:n,method:y},y===r.put&&(m.headers=p),[4,v.send("storage.getUploadMetadata",m)];case 1:return b=c.sent(),w=b.data,_=w.url,E=w.authorization,I=w.token,S=w.fileId,O=w.cosFileId,A=w.download_url,T=b.requestId,R=i(i({},N={url:_,file:o,name:n,onUploadProgress:s}),{method:r.put,headers:i(i({},p),{authorization:E,"x-cos-meta-fileid":O,"x-cos-security-token":I})}),x=i(i({},N),{method:r.post,data:{key:n,signature:E,"x-cos-meta-fileid":O,success_action_status:"201","x-cos-security-token":I}}),(P={})[r.put]={params:R,isSuccess:function(t){return t>=200&&t<300}},P[r.post]={params:x,isSuccess:function(t){return 201===t}},C=P,[4,v.upload(C[y].params)];case 2:return L=c.sent(),C[y].isSuccess(L.statusCode)?[2,g(e,null,{fileID:S,download_url:A,requestId:T})]:[2,g(e,new Error("["+f()+"]["+l.OPERATION_FAIL+"][storage]:"+L.data))]}}))}))},t.prototype.getUploadMetadata=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s;return c(this,(function(a){switch(a.label){case 0:if(n=t.cloudPath,!d(n))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getUploadMetadata] invalid cloudPath"}));r=this.request,o="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.send(o,{path:n})];case 2:return i=a.sent(),[2,g(e,null,i)];case 3:return s=a.sent(),[2,g(e,s)];case 4:return[2]}}))}))},t.prototype.deleteFile=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(!(n=t.fileList)||!p(n)||0===n.length)throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.deleteFile] fileList must not be empty"}));for(r=0,o=n;r<o.length;r++)if(!(i=o[r])||!d(i))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.deleteFile] fileID must be string"}));return"storage.batchDeleteFile",[4,this.request.send("storage.batchDeleteFile",{fileid_list:n})];case 1:return(s=u.sent()).code?[2,g(e,null,s)]:(a={fileList:s.data.delete_list,requestId:s.requestId},[2,g(e,null,a)])}}))}))},t.prototype.getTempFileURL=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(!(n=t.fileList)||!p(n)||0===n.length)throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getTempFileURL] fileList must not be empty"}));for(r=[],o=0,i=n;o<i.length;o++)if(s=i[o],y(s)){if(!Object.prototype.hasOwnProperty.call(s,"fileID")||!Object.prototype.hasOwnProperty.call(s,"maxAge"))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getTempFileURL] file info must include fileID and maxAge"}));r.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!d(s))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getTempFileURL] invalid fileList"}));r.push({fileid:s})}return"storage.batchGetDownloadUrl",[4,this.request.send("storage.batchGetDownloadUrl",{file_list:r})];case 1:return(a=u.sent()).code?[2,g(e,null,a)]:[2,g(e,null,{fileList:a.data.download_list,requestId:a.requestId})]}}))}))},t.prototype.downloadFile=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(n=t.fileID,!d(n))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[storage.getTempFileURL] fileID must be string"}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}]})];case 1:return r=u.sent(),"SUCCESS"!==(o=r.fileList[0]).code?[2,g(e,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return a=u.sent(),[2,g(e,null,a)]}}))}))},s([v({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"uploadFile",null),s([v({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"getUploadMetadata",null),s([v({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"deleteFile",null),s([v({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"getTempFileURL",null),s([v({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+h]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"downloadFile",null),t}()),b={name:"storage",entity:{uploadFile:m.uploadFile,deleteFile:m.deleteFile,getTempFileURL:m.getTempFileURL,downloadFile:m.downloadFile,getUploadMetadata:m.getUploadMetadata}};try{cloudbase.registerComponent(b)}catch(t){}function w(t){try{t.registerComponent(b)}catch(t){console.warn(t)}}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){"use strict";n.r(e),n.d(e,"registerAnalytics",(function(){return p}));var r=n(0),o=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},i=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},u=r.c.ERRORS,c=r.c.COMMUNITY_SITE_URL,f=r.e.catchErrorsDecorator,l=["mall"];var h={name:"analytics",entity:{analytics:(new(function(){function t(){}return t.prototype.analytics=function(t){return s(this,void 0,void 0,(function(){var e,n,r;return a(this,(function(o){if(!function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))return!1;var e=t.report_data,n=t.report_type;return!1!==l.includes(n)&&("Object"===Object.prototype.toString.call(e).slice(8,-1)&&(!(void 0!==e.action_time&&!Number.isInteger(e.action_time))&&"string"==typeof e.action_type))}(t))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[analytics.analytics] invalid report data"}));return"analytics.report",e=void 0===t.report_data.action_time?Math.floor(Date.now()/1e3):t.report_data.action_time,n={analytics_scene:t.report_type,analytics_data:Object.assign({},t.report_data,{action_time:e})},r={requestData:n},this.request.send("analytics.report",r),[2]}))}))},o([f({customInfo:{className:"Cloudbase",methodName:"analytics"},title:"上报调用失败",messages:["请确认以下各项:"," 1 - 调用 analytics() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+c]}),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],t.prototype,"analytics",null),t}())).analytics}};try{cloudbase.registerComponent(h)}catch(t){}function p(t){try{t.registerComponent(h)}catch(t){console.warn(t)}}},function(t){t.exports=JSON.parse('{"version":"2.5.21-beta.0"}')},function(t,e,n){"use strict";n.r(e),n.d(e,"registerDatabase",(function(){return we}));var r,o,i={};n.r(i),n.d(i,"Point",(function(){return ct})),n.d(i,"LineString",(function(){return K})),n.d(i,"Polygon",(function(){return z})),n.d(i,"MultiPoint",(function(){return Z})),n.d(i,"MultiLineString",(function(){return tt})),n.d(i,"MultiPolygon",(function(){return nt})),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a="Number",u="Object",c="Array",f="GeoPoint",l="GeoLineString",h="GeoPolygon",p="GeoMultiPoint",d="GeoMultiLineString",y="GeoMultiPolygon",g="Date",v="ServerDate",m="BsonDate",b=["desc","asc"],w=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(s||(s={}));var _;(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte";!function(t){t.WHERE="WHERE",t.DOC="DOC"}(_||(_={}));var E,I=(E=function(t,e){return(E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}E(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),S=[],O={},A=function(t){function e(e,n){if(n!==O)throw new TypeError("InternalSymbol cannot be constructed with new operator");return t.call(this,e)||this}return I(e,t),e.for=function(t){for(var n=0,r=S.length;n<r;n++)if(S[n].target===t)return S[n].instance;var o=new e(t,O);return S.push({target:t,instance:o}),o},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})})),T=A,N=T.for("UNSET_FIELD_NAME"),R=T.for("UPDATE_COMMAND"),x=T.for("QUERY_COMMAND"),C=T.for("LOGIC_COMMAND"),L=T.for("GEO_POINT"),P=T.for("SYMBOL_GEO_LINE_STRING"),U=T.for("SYMBOL_GEO_POLYGON"),D=T.for("SYMBOL_GEO_MULTI_POINT"),j=T.for("SYMBOL_GEO_MULTI_LINE_STRING"),k=T.for("SYMBOL_GEO_MULTI_POLYGON"),M=T.for("SERVER_DATE"),B=T.for("REGEXP"),q=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},F=function(t){return"object"===q(t)},W=function(t){return"number"===q(t)},$=function(t){return Array.isArray(t)},V=function(t){return"date"===q(t)},H=function(t){return"regexp"===q(t)},G=function(t){return t&&t._internalType instanceof A},J=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},K=function(){function t(t){if(!$(t))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t);if(t.length<2)throw new Error('"points" must contain 2 points at least');t.forEach((function(t){if(!(t instanceof ct))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t+"[]")})),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"LineString",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))},e},t.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))}},t.validate=function(t){var e,n;if("LineString"!==t.type||!$(t.coordinates))return!1;try{for(var r=J(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!W(i[0])||!W(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},t.isClosed=function(t){var e=t.points[0],n=t.points[t.points.length-1];if(e.latitude===n.latitude&&e.longitude===n.longitude)return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return P},enumerable:!0,configurable:!0}),t}(),Y=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},z=function(){function t(t){if(!$(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof K))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]");if(!K.isClosed(t))throw new Error("LineString "+t.points.map((function(t){return t.toReadableString()}))+" is not a closed cycle")})),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Polygon",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))},e},t.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}},t.validate=function(t){var e,n,r,o;if("Polygon"!==t.type||!$(t.coordinates))return!1;try{for(var i=Y(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var u=(r=void 0,Y(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!W(f[0])||!W(f[1]))return!1}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},t.isCloseLineString=function(t){var e=t[0],n=t[t.length-1];return e[0]===n[0]&&e[1]===n[1]},Object.defineProperty(t.prototype,"_internalType",{get:function(){return k},enumerable:!0,configurable:!0}),t}(),Q=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Z=function(){function t(t){if(!$(t))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t);if(0===t.length)throw new Error('"points" must contain 1 point at least');t.forEach((function(t){if(!(t instanceof ct))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t+"[]")})),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPoint",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))},e},t.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))}},t.validate=function(t){var e,n;if("MultiPoint"!==t.type||!$(t.coordinates))return!1;try{for(var r=Q(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!W(i[0])||!W(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return D},enumerable:!0,configurable:!0}),t}(),X=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},tt=function(){function t(t){if(!$(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof K))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]")})),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiLineString",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))},e},t.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}},t.validate=function(t){var e,n,r,o;if("MultiLineString"!==t.type||!$(t.coordinates))return!1;try{for(var i=X(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var u=(r=void 0,X(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!W(f[0])||!W(f[1]))return!1}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),t}(),et=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},nt=function(){function t(t){var e,n;if(!$(t))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof t);if(0===t.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=et(t),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof z))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof i+"[]")}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.polygons=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPolygon",coordinates:this.polygons.map((function(t){return t.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}))},e},t.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(t){return t.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}))}},t.validate=function(t){var e,n,r,o,i,s;if("MultiPolygon"!==t.type||!$(t.coordinates))return!1;try{for(var a=et(t.coordinates),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var f=(r=void 0,et(c)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,et(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!W(y[0])||!W(y[1]))return!1}}catch(t){i={error:t}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return U},enumerable:!0,configurable:!0}),t}(),rt=function(){function t(t){var e=(void 0===t?{}:t).offset,n=void 0===e?0:e;this.offset=n}return Object.defineProperty(t.prototype,"_internalType",{get:function(){return M},enumerable:!0,configurable:!0}),t.prototype.parse=function(){return{$date:{offset:this.offset}}},t}();function ot(t){return new rt(t)}var it,st=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},at=function(){function t(){}return t.formatResDocumentData=function(e){return e.map((function(e){return t.formatField(e)}))},t.formatField=function(e){var n=Object.keys(e),r={};return Array.isArray(e)&&(r=[]),n.forEach((function(n){var o,i=e[n];switch(t.whichType(i)){case f:o=new ct(i.coordinates[0],i.coordinates[1]);break;case l:o=new K(i.coordinates.map((function(t){return new ct(t[0],t[1])})));break;case h:o=new z(i.coordinates.map((function(t){return new K(t.map((function(t){var e=st(t,2),n=e[0],r=e[1];return new ct(n,r)})))})));break;case p:o=new Z(i.coordinates.map((function(t){return new ct(t[0],t[1])})));break;case d:o=new tt(i.coordinates.map((function(t){return new K(t.map((function(t){var e=st(t,2),n=e[0],r=e[1];return new ct(n,r)})))})));break;case y:o=new nt(i.coordinates.map((function(t){return new z(t.map((function(t){return new K(t.map((function(t){var e=st(t,2),n=e[0],r=e[1];return new ct(n,r)})))})))})));break;case g:o=new Date(1e3*i.$timestamp);break;case u:case c:o=t.formatField(i);break;case v:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o})),r},t.whichType=function(t){var e=Object.prototype.toString.call(t).slice(8,-1);if(e===g)return m;if(e===u){if(t instanceof ct)return f;if(t instanceof Date)return g;if(t instanceof rt)return v;t.$timestamp?e=g:t.$date?e=v:ct.validate(t)?e=f:K.validate(t)?e=l:z.validate(t)?e=h:Z.validate(t)?e=p:tt.validate(t)?e=d:nt.validate(t)&&(e=y)}return e},t.generateDocId=function(){for(var t="ABCDEFabcdef0123456789",e="",n=0;n<24;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},t}(),ut=function(){function t(){}return t.isGeopoint=function(t,e){if(at.whichType(e)!==a)throw new Error("Geo Point must be number type");var n=Math.abs(e);if("latitude"===t&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===t&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},t.isInteger=function(t,e){if(!Number.isInteger(e))throw new Error(t+o.IntergerError);return!0},t.isFieldOrder=function(t){if(-1===b.indexOf(t))throw new Error(o.DirectionError);return!0},t.isFieldPath=function(t){if(!/^[a-zA-Z0-9-_\.]/.test(t))throw new Error;return!0},t.isOperator=function(t){if(-1===w.indexOf(t))throw new Error(o.OpStrError);return!0},t.isCollName=function(t){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(t))throw new Error(o.CollNameError);return!0},t.isDocID=function(t){if(!/^([a-fA-F0-9]){24}$/.test(t))throw new Error(o.DocIDError);return!0},t}(),ct=function(){function t(t,e){ut.isGeopoint("longitude",t),ut.isGeopoint("latitude",e),this.longitude=t,this.latitude=e}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Point",coordinates:[this.longitude,this.latitude]},e},t.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},t.prototype.toReadableString=function(){return"["+this.longitude+","+this.latitude+"]"},t.validate=function(t){return"Point"===t.type&&$(t.coordinates)&&ut.isGeopoint("longitude",t.coordinates[0])&&ut.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return L},enumerable:!0,configurable:!0}),t}(),ft=function(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t};!function(t){t.SET="set",t.REMOVE="remove",t.INC="inc",t.MUL="mul",t.PUSH="push",t.PULL="pull",t.PULL_ALL="pullAll",t.POP="pop",t.SHIFT="shift",t.UNSHIFT="unshift",t.ADD_TO_SET="addToSet",t.BIT="bit",t.RENAME="rename",t.MAX="max",t.MIN="min"}(it||(it={}));var lt=function(){function t(t,e,n){this._internalType=R,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||N}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function ht(t){return t&&t instanceof lt&&t._internalType===R}var pt;!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(pt||(pt={}));var dt=function(){function t(t,e,n){if(this._internalType=C,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||N,this.fieldName!==N)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++){(yt(i=e[r])||bt(i))&&(e[r]=i._setFieldName(this.fieldName))}}else{var i;(yt(i=e)||bt(i))&&(e=i._setFieldName(this.fieldName))}}return t.prototype._setFieldName=function(e){var n=this.operands.map((function(n){return n instanceof t?n._setFieldName(e):n}));return new t(this.operator,n,e)},t.prototype.and=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(pt.AND,r,this.fieldName)},t.prototype.or=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(pt.OR,r,this.fieldName)},t}();function yt(t){return t&&t instanceof dt&&t._internalType===C}var gt,vt=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t.EQ="eq",t.NEQ="neq",t.GT="gt",t.GTE="gte",t.LT="lt",t.LTE="lte",t.IN="in",t.NIN="nin",t.ALL="all",t.ELEM_MATCH="elemMatch",t.EXISTS="exists",t.SIZE="size",t.MOD="mod",t.GEO_NEAR="geoNear",t.GEO_WITHIN="geoWithin",t.GEO_INTERSECTS="geoIntersects"}(gt||(gt={}));var mt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.operator=e,o._internalType=x,o}return vt(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case gt.IN:case gt.NIN:return(t={})["$"+this.operator]=this.operands,t;default:return(e={})["$"+this.operator]=this.operands[0],e}},e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e.prototype.eq=function(t){var n=new e(gt.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(gt.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(gt.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(gt.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(gt.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(gt.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(gt.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(gt.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof ct))throw new TypeError('"geometry" must be of type Point. Received type '+typeof t.geometry);if(void 0!==t.maxDistance&&!W(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof t.maxDistance);if(void 0!==t.minDistance&&!W(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof t.minDistance);var n=new e(gt.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof nt||t.geometry instanceof z))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof t.geometry);var n=new e(gt.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof ct||t.geometry instanceof K||t.geometry instanceof z||t.geometry instanceof Z||t.geometry instanceof tt||t.geometry instanceof nt))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof t.geometry);var n=new e(gt.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(dt);function bt(t){return t&&t instanceof mt&&t._internalType===x}function wt(t){return bt(t)}var _t={};for(var Et in gt)_t[Et]="$"+Et;for(var Et in pt)_t[Et]="$"+Et;for(var Et in it)_t[Et]="$"+Et;function It(t){return _t[t]||"$"+t}_t[gt.NEQ]="$ne",_t[it.REMOVE]="$unset",_t[it.SHIFT]="$pop",_t[it.UNSHIFT]="$push";var St=function(){return(St=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Ot=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},At=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ot(arguments[e]));return t};function Tt(t){return function t(e,n){if(!G(e)){if(V(e))return{$date:+e};if(H(e))return{$regex:e.source,$options:e.flags};if($(e))return e.map((function(e){if(n.indexOf(e)>-1)throw new Error("Cannot convert circular structure to JSON");return t(e,At(n,[e]))}));if(F(e)){var r=St({},e);for(var o in r){if(n.indexOf(r[o])>-1)throw new Error("Cannot convert circular structure to JSON");r[o]=t(r[o],At(n,[r[o]]))}return r}return e}switch(e._internalType){case L:return e.toJSON();case M:case B:return e.parse();default:return e.toJSON?e.toJSON():e}}(t,[t])}var Nt=function(){return(Nt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Rt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},xt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Rt(arguments[e]));return t};function Ct(t,e,n,r){var o=Nt({},t);for(var i in t)if(!/^\$/.test(i)){var s=t[i];if(s&&F(s)&&!e(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Ct(s,e,xt(n,[i]),xt(r,[s]));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o[i+"."+c]=a[c],delete o[i][c]);u||delete o[i]}}return o}function Lt(t){return Ct(t,Ut,[],[t])}function Pt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?$(t[r])?t[r].push(e[r]):F(t[r])?F(e[r])?Object.assign(t[r],e[r]):(console.warn("unmergable condition, query is object but condition is "+q(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+q(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]}function Ut(t){return G(t)||V(t)||H(t)}function Dt(t){return Tt(t)}var jt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return ht(t)?this.encodeUpdateCommand(t):"object"===q(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===N)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case it.PUSH:case it.PULL:case it.PULL_ALL:case it.POP:case it.SHIFT:case it.UNSHIFT:case it.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=It(t.operator);switch(t.operator){case it.REMOVE:return(e={})[i]=((n={})[t.fieldName]="",n),e;default:return(r={})[i]=((o={})[t.fieldName]=t.operands[0],o),r}},t.prototype.encodeArrayUpdateCommand=function(t){var e,n,r,o,i,s,a,u,c,f,l=It(t.operator);switch(t.operator){case it.PUSH:var h=void 0;return h=$(t.operands)?{$each:t.operands.map(Dt)}:t.operands,(e={})[l]=((n={})[t.fieldName]=h,n),e;case it.UNSHIFT:h={$each:t.operands.map(Dt),$position:0};return(r={})[l]=((o={})[t.fieldName]=h,o),r;case it.POP:return(i={})[l]=((s={})[t.fieldName]=1,s),i;case it.SHIFT:return(a={})[l]=((u={})[t.fieldName]=-1,u),a;default:return(c={})[l]=((f={})[t.fieldName]=Dt(t.operands),f),c}},t.prototype.encodeUpdateObject=function(t){var e=Lt(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(ht(r)){e[n]=r._setFieldName(n),Pt(e,this.encodeUpdateCommand(e[n]),n)}else{e[n]=r=Dt(r);var o=new lt(it.SET,[r],n);Pt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),kt={};function Mt(t){if(!ve.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return kt[e]||(kt[e]=new ve.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new ve.reqClass(t.config)}}})),kt[e]}var Bt=function(){return(Bt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},qt=function(){function t(t,e,n,r){var o=this;void 0===r&&(r={}),this.watch=function(t){return Mt(o._db).watch(Bt(Bt({},t),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=t,this._coll=e,this.id=n,this.request=new ve.reqClass(this._db.config),this.projection=r}return t.prototype.create=function(t,e){e=e||ft();var n={collectionName:this._coll,data:Tt(t)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(t){t.code?e(0,t):e(0,{id:t.data._id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.set=function(t,e){if(e=e||ft(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(t){if("object"==typeof t)for(var e in t)t[e]instanceof lt?n=!0:"object"==typeof t[e]&&r(t[e])};if(r(t),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:_.DOC,data:Tt(t),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.update=function(t,e){if(e=e||ft(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:jt.encode(t),query:n,queryType:_.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.remove=function(t){t=t||ft();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:_.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(e){e.code?t(0,e):t(0,{deleted:e.data.deleted,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},t.prototype.get=function(t){t=t||ft();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:_.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n=at.formatResDocumentData(e.data.list);t(0,{data:n,requestId:e.requestId,total:e.TotalCount,limit:e.Limit,offset:e.Offset})}})).catch((function(e){t(e)})),t.promise},t.prototype.field=function(e){for(var n in e)e[n]?e[n]=1:e[n]=0;return new t(this._db,this._coll,this.id,e)},t}(),Ft=function(){function t(){}return t.encode=function(t){return(new Wt).encodeQuery(t)},t}(),Wt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return Ut(t)?yt(t)?this.encodeLogicCommand(t):bt(t)?this.encodeQueryCommand(t):((n={})[e]=this.encodeQueryObject(t),n):F(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regex:t.source,$options:t.flags}},t.prototype.encodeLogicCommand=function(t){var e,n,r,o,i,s,a,u=this;switch(t.operator){case pt.NOR:case pt.AND:case pt.OR:var c=It(t.operator),f=t.operands.map((function(e){return u.encodeQuery(e,t.fieldName)}));return(e={})[c]=f,e;case pt.NOT:c=It(t.operator);var l=t.operands[0];if(H(l))return(n={})[t.fieldName]=((r={})[c]=this.encodeRegExp(l),r),n;f=this.encodeQuery(l)[t.fieldName];return(o={})[t.fieldName]=((i={})[c]=f,i),o;default:c=It(t.operator);if(1===t.operands.length){var h=this.encodeQuery(t.operands[0]);return(s={})[c]=h,s}f=t.operands.map(this.encodeQuery.bind(this));return(a={})[c]=f,a}},t.prototype.encodeQueryCommand=function(t){return wt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,s,a,u,c;if(t.fieldName===N)throw new Error("Cannot encode a comparison command with unset field name");var f=It(t.operator);switch(t.operator){case gt.EQ:case gt.NEQ:case gt.LT:case gt.LTE:case gt.GT:case gt.GTE:case gt.ELEM_MATCH:case gt.EXISTS:case gt.SIZE:case gt.MOD:return(e={})[t.fieldName]=((n={})[f]=Dt(t.operands[0]),n),e;case gt.IN:case gt.NIN:case gt.ALL:return(r={})[t.fieldName]=((o={})[f]=Dt(t.operands),o),r;case gt.GEO_NEAR:var l=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case gt.GEO_WITHIN:l=t.operands[0];return(s={})[t.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case gt.GEO_INTERSECTS:l=t.operands[0];return(a={})[t.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(u={})[t.fieldName]=((c={})[f]=Dt(t.operands[0]),c),u}},t.prototype.encodeQueryObject=function(t){var e=Lt(t);for(var n in e){var r=e[n];if(yt(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else if(wt(r)){e[n]=r._setFieldName(n);o=this.encodeComparisonCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else Ut(r)&&(e[n]=Dt(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?$(t[r])?t[r]=t[r].concat(e[r]):F(t[r])?F(e[r])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is "+q(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+q(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),$t=function(){return($t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Vt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return Mt(i._db).watch($t($t({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(t,e){return t[e.field]=e.direction,t}),{}):void 0}))},this._db=t,this._coll=e,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=new ve.reqClass(this._db.config)}return t.prototype.get=function(t){t=t||ft();var e=[];this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)}));var n={collectionName:this._coll,queryType:_.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),e.length>0&&(n.order=e),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n={data:at.formatResDocumentData(e.data.list),requestId:e.requestId};e.TotalCount&&(n.total=e.TotalCount),e.Limit&&(n.limit=e.Limit),e.Offset&&(n.offset=e.Offset),t(0,n)}})).catch((function(e){t(e)})),t.promise},t.prototype.count=function(t){t=t||ft();var e={collectionName:this._coll,queryType:_.WHERE};return this._fieldFilters&&(e.query=this._fieldFilters),this._request.send("database.countDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,total:e.data.total})})).catch((function(e){t(e)})),t.promise},t.prototype.where=function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(e),r=n.some((function(t){return void 0!==e[t]}));if(n.length&&!r)throw Error(o.QueryParamValueError);return new t(this._db,this._coll,Ft.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){ut.isFieldPath(e),ut.isFieldOrder(n);var r={field:e,direction:n},o=this._fieldOrders.concat(r);return new t(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){ut.isInteger("limit",e);var n=$t({},this._queryOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){ut.isInteger("offset",e);var n=$t({},this._queryOptions);return n.offset=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.update=function(t,e){if(e=e||ft(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:_.WHERE,multi:!0,merge:!0,upsert:!1,data:jt.encode(t)};return this._request.send("database.updateDocument",n).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,updated:t.data.updated,upsertId:t.data.upsert_id})})).catch((function(t){e(t)})),e.promise},t.prototype.field=function(e){for(var n in e)e[n]?"object"!=typeof e[n]&&(e[n]=1):e[n]=0;var r=$t({},this._queryOptions);return r.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.remove=function(t){t=t||ft(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var e={collectionName:this._coll,query:Ft.encode(this._fieldFilters),queryType:_.WHERE,multi:!0};return this._request.send("database.deleteDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,deleted:e.data.deleted})})).catch((function(e){t(e)})),t.promise},t}(),Ht=n(4),Gt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},Jt=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Kt=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=new ve.reqClass(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return Gt(this,void 0,void 0,(function(){var t;return Jt(this,(function(e){switch(e.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(t=e.sent())&&t.data&&t.data.list?[2,{requestId:t.requestId,data:JSON.parse(t.data.list).map(Ht.a.parse)}]:[2,t]}}))}))},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map((function(t){var e,n=t.stageKey,r=t.stageValue;return(e={})[n]=JSON.parse(r),e}))},t.prototype._pipe=function(t,e){return this._stages.push({stageKey:"$"+t,stageValue:JSON.stringify(e)}),this},t.prototype.addFields=function(t){return this._pipe("addFields",t)},t.prototype.bucket=function(t){return this._pipe("bucket",t)},t.prototype.bucketAuto=function(t){return this._pipe("bucketAuto",t)},t.prototype.count=function(t){return this._pipe("count",t)},t.prototype.geoNear=function(t){return t.query&&(t.query=Ft.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new ct(t.near.longitude,t.near.latitude).toJSON()),this._pipe("geoNear",t)},t.prototype.group=function(t){return this._pipe("group",t)},t.prototype.limit=function(t){return this._pipe("limit",t)},t.prototype.match=function(t){return this._pipe("match",Ft.encode(t))},t.prototype.project=function(t){return this._pipe("project",t)},t.prototype.lookup=function(t){return this._pipe("lookup",t)},t.prototype.replaceRoot=function(t){return this._pipe("replaceRoot",t)},t.prototype.sample=function(t){return this._pipe("sample",t)},t.prototype.skip=function(t){return this._pipe("skip",t)},t.prototype.sort=function(t){return this._pipe("sort",t)},t.prototype.sortByCount=function(t){return this._pipe("sortByCount",t)},t.prototype.unwind=function(t){return this._pipe("unwind",t)},t}(),Yt=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),zt=function(t){function e(e,n){return t.call(this,e,n)||this}return Yt(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new qt(this._db,this._coll,t)},e.prototype.add=function(t,e){return new qt(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new Kt(this._db,this._coll)},e}(Vt),Qt={eq:function(t){return new mt(gt.EQ,[t])},neq:function(t){return new mt(gt.NEQ,[t])},lt:function(t){return new mt(gt.LT,[t])},lte:function(t){return new mt(gt.LTE,[t])},gt:function(t){return new mt(gt.GT,[t])},gte:function(t){return new mt(gt.GTE,[t])},in:function(t){return new mt(gt.IN,t)},nin:function(t){return new mt(gt.NIN,t)},all:function(t){return new mt(gt.ALL,t)},elemMatch:function(t){return new mt(gt.ELEM_MATCH,[t])},exists:function(t){return new mt(gt.EXISTS,[t])},size:function(t){return new mt(gt.SIZE,[t])},mod:function(t){return new mt(gt.MOD,[t])},geoNear:function(t){return new mt(gt.GEO_NEAR,[t])},geoWithin:function(t){return new mt(gt.GEO_WITHIN,[t])},geoIntersects:function(t){return new mt(gt.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new dt(pt.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new dt(pt.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new dt(pt.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new dt(pt.NOT,n)},set:function(t){return new lt(it.SET,[t])},remove:function(){return new lt(it.REMOVE,[])},inc:function(t){return new lt(it.INC,[t])},mul:function(t){return new lt(it.MUL,[t])},push:function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(F(e[0])&&e[0].hasOwnProperty("each")){var r=e[0];t={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else t=$(e[0])?e[0]:Array.from(e);return new lt(it.PUSH,t)},pull:function(t){return new lt(it.PULL,t)},pullAll:function(t){return new lt(it.PULL_ALL,t)},pop:function(){return new lt(it.POP,[])},shift:function(){return new lt(it.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new lt(it.UNSHIFT,n)},addToSet:function(t){return new lt(it.ADD_TO_SET,t)},rename:function(t){return new lt(it.RENAME,[t])},bit:function(t){return new lt(it.BIT,[t])},max:function(t){return new lt(it.MAX,[t])},min:function(t){return new lt(it.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===q(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new Kt},abs:function(t){return new Zt("abs",t)},add:function(t){return new Zt("add",t)},ceil:function(t){return new Zt("ceil",t)},divide:function(t){return new Zt("divide",t)},exp:function(t){return new Zt("exp",t)},floor:function(t){return new Zt("floor",t)},ln:function(t){return new Zt("ln",t)},log:function(t){return new Zt("log",t)},log10:function(t){return new Zt("log10",t)},mod:function(t){return new Zt("mod",t)},multiply:function(t){return new Zt("multiply",t)},pow:function(t){return new Zt("pow",t)},sqrt:function(t){return new Zt("sqrt",t)},subtract:function(t){return new Zt("subtract",t)},trunc:function(t){return new Zt("trunc",t)},arrayElemAt:function(t){return new Zt("arrayElemAt",t)},arrayToObject:function(t){return new Zt("arrayToObject",t)},concatArrays:function(t){return new Zt("concatArrays",t)},filter:function(t){return new Zt("filter",t)},in:function(t){return new Zt("in",t)},indexOfArray:function(t){return new Zt("indexOfArray",t)},isArray:function(t){return new Zt("isArray",t)},map:function(t){return new Zt("map",t)},range:function(t){return new Zt("range",t)},reduce:function(t){return new Zt("reduce",t)},reverseArray:function(t){return new Zt("reverseArray",t)},size:function(t){return new Zt("size",t)},slice:function(t){return new Zt("slice",t)},zip:function(t){return new Zt("zip",t)},and:function(t){return new Zt("and",t)},not:function(t){return new Zt("not",t)},or:function(t){return new Zt("or",t)},cmp:function(t){return new Zt("cmp",t)},eq:function(t){return new Zt("eq",t)},gt:function(t){return new Zt("gt",t)},gte:function(t){return new Zt("gte",t)},lt:function(t){return new Zt("lt",t)},lte:function(t){return new Zt("lte",t)},neq:function(t){return new Zt("ne",t)},cond:function(t){return new Zt("cond",t)},ifNull:function(t){return new Zt("ifNull",t)},switch:function(t){return new Zt("switch",t)},dateFromParts:function(t){return new Zt("dateFromParts",t)},dateFromString:function(t){return new Zt("dateFromString",t)},dayOfMonth:function(t){return new Zt("dayOfMonth",t)},dayOfWeek:function(t){return new Zt("dayOfWeek",t)},dayOfYear:function(t){return new Zt("dayOfYear",t)},isoDayOfWeek:function(t){return new Zt("isoDayOfWeek",t)},isoWeek:function(t){return new Zt("isoWeek",t)},isoWeekYear:function(t){return new Zt("isoWeekYear",t)},millisecond:function(t){return new Zt("millisecond",t)},minute:function(t){return new Zt("minute",t)},month:function(t){return new Zt("month",t)},second:function(t){return new Zt("second",t)},hour:function(t){return new Zt("hour",t)},week:function(t){return new Zt("week",t)},year:function(t){return new Zt("year",t)},literal:function(t){return new Zt("literal",t)},mergeObjects:function(t){return new Zt("mergeObjects",t)},objectToArray:function(t){return new Zt("objectToArray",t)},allElementsTrue:function(t){return new Zt("allElementsTrue",t)},anyElementTrue:function(t){return new Zt("anyElementTrue",t)},setDifference:function(t){return new Zt("setDifference",t)},setEquals:function(t){return new Zt("setEquals",t)},setIntersection:function(t){return new Zt("setIntersection",t)},setIsSubset:function(t){return new Zt("setIsSubset",t)},setUnion:function(t){return new Zt("setUnion",t)},concat:function(t){return new Zt("concat",t)},dateToString:function(t){return new Zt("dateToString",t)},indexOfBytes:function(t){return new Zt("indexOfBytes",t)},indexOfCP:function(t){return new Zt("indexOfCP",t)},split:function(t){return new Zt("split",t)},strLenBytes:function(t){return new Zt("strLenBytes",t)},strLenCP:function(t){return new Zt("strLenCP",t)},strcasecmp:function(t){return new Zt("strcasecmp",t)},substr:function(t){return new Zt("substr",t)},substrBytes:function(t){return new Zt("substrBytes",t)},substrCP:function(t){return new Zt("substrCP",t)},toLower:function(t){return new Zt("toLower",t)},toUpper:function(t){return new Zt("toUpper",t)},meta:function(t){return new Zt("meta",t)},addToSet:function(t){return new Zt("addToSet",t)},avg:function(t){return new Zt("avg",t)},first:function(t){return new Zt("first",t)},last:function(t){return new Zt("last",t)},max:function(t){return new Zt("max",t)},min:function(t){return new Zt("min",t)},push:function(t){return new Zt("push",t)},stdDevPop:function(t){return new Zt("stdDevPop",t)},stdDevSamp:function(t){return new Zt("stdDevSamp",t)},sum:function(t){return new Zt("sum",t)},let:function(t){return new Zt("let",t)}},project:{slice:function(t){return new Xt("slice",t)},elemMatch:function(t){return new Xt("elemMatch",t)}}},Zt=function(t,e){this["$"+t]=e},Xt=function(t,e){this["$"+t]=e},te=function(){function t(t){var e=t.regexp,n=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regex=e,this.$options=n}return t.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return B},enumerable:!0,configurable:!0}),t}();function ee(t){return new te(t)}var ne={code:"INSERT_DOC_FAIL",message:"insert document failed"},re={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},oe=function(){return(oe=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},ie=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},se=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},ae="database.updateDocInTransaction",ue=function(){function t(t,e,n){this._coll=e,this.id=n,this._transaction=t,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.create=function(t){return ie(this,void 0,void 0,(function(){var e,n,r,o;return se(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:Ht.a.stringify(Tt(t),{relaxed:!1})},this.id&&(e._id=this.id),[4,this._request.send("database.insertDocInTransaction",e)];case 1:if((n=i.sent()).code)throw n;if(r=Ht.a.parse(n.inserted),1==(o=Ht.a.parse(n.ok))&&1==r)return[2,oe(oe({},n),{ok:o,inserted:r})];throw new Error(ne.message)}}))}))},t.prototype.get=function(){return ie(this,void 0,void 0,(function(){var t,e;return se(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,{data:"null"!==e.data?at.formatField(Ht.a.parse(e.data)):Ht.a.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return ie(this,void 0,void 0,(function(){var e,n;return se(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Ht.a.stringify(Tt(t),{relaxed:!1}),upsert:!0},[4,this._request.send(ae,e)];case 1:if((n=r.sent()).code)throw n;return[2,oe(oe({},n),{updated:Ht.a.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},t.prototype.update=function(t){return ie(this,void 0,void 0,(function(){var e,n;return se(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Ht.a.stringify(jt.encode(t),{relaxed:!1})},[4,this._request.send(ae,e)];case 1:if((n=r.sent()).code)throw n;return[2,oe(oe({},n),{updated:Ht.a.parse(n.updated)})]}}))}))},t.prototype.delete=function(){return ie(this,void 0,void 0,(function(){var t,e;return se(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,oe(oe({},e),{deleted:Ht.a.parse(e.deleted)})]}}))}))},t}(),ce=function(t,e){this._coll=e,this._transaction=t},fe=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),le=function(t){function e(e,n){return t.call(this,e,n)||this}return fe(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new ue(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new ue(this._transaction,this._coll,e).create(t)},e}(ce),he=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},pe=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},de=function(){function t(t){this._db=t,this._request=new ve.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return he(this,void 0,void 0,(function(){var t;return pe(this,(function(e){switch(e.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((t=e.sent()).code)throw t;return this.inited=!0,this._id=t.transactionId,[2]}}))}))},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new le(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return he(this,void 0,void 0,(function(){var t,e;return pe(this,(function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.commitTransaction",t)];case 1:if((e=n.sent()).code)throw e;return this.commited=!0,[2,e]}}))}))},t.prototype.rollback=function(t){return he(this,void 0,void 0,(function(){var e,n;return pe(this,(function(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.abortTransaction",e)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=t,[2,n]}}))}))},t}();function ye(){return he(this,void 0,void 0,(function(){var t;return pe(this,(function(e){switch(e.label){case 0:return[4,(t=new de(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function ge(t,e){return void 0===e&&(e=3),he(this,void 0,void 0,(function(){var n,r,o,i,s=this;return pe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new de(this)).init()];case 1:return a.sent(),[4,t(n)];case 2:if(r=a.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return a.sent(),[2,r];case 4:if(o=a.sent(),!1===n.inited)throw o;return i=function(t){return he(s,void 0,void 0,(function(){return pe(this,(function(e){switch(e.label){case 0:if(n.aborted||n.commited)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.rollback()];case 2:return e.sent(),[3,4];case 3:return e.sent(),[3,4];case 4:throw t;case 5:if(!0===n.aborted)throw n.abortReason;throw t}}))}))},e<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===re.code?[4,ge.bind(this)(t,--e)]:[3,8];case 7:return[2,a.sent()];case 8:return[4,i(o)];case 9:return a.sent(),[3,10];case 10:return[2]}}))}))}var ve=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=ot,this.command=Qt,this.RegExp=ee,this.startTransaction=ye,this.runTransaction=ge,this.logicCommand=dt,this.updateCommand=lt,this.queryCommand=mt}return t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new zt(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return new t.reqClass(this.config).send("database.addCollection",n)},t}(),me=function(){return(me=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};var be={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,r=e.runtime;return ve.reqClass=this.request.constructor,ve.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},ve.runtime=r,this.wsClientClass&&(ve.wsClass=n.wsClass,ve.wsClientClass=this.wsClientClass),ve.ws||(ve.ws=null),new ve(me(me(me({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(be)}catch(t){}function we(t){try{t.registerComponent(be)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"LoginState",(function(){return $})),n.d(e,"Auth",(function(){return V})),n.d(e,"registerAuth",(function(){return G}));var r,o,i=n(0);function s(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}!function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(r||(r={})),function(t){t.UNREACHABLE="unreachable",t.LOCAL="local",t.CANCELLED="cancelled",t.UNKNOWN="unknown",t.INVALID_ARGUMENT="invalid_argument",t.DEADLINE_EXCEEDED="deadline_exceeded",t.NOT_FOUND="not_found",t.ALREADY_EXISTS="already_exists",t.PERMISSION_DENIED="permission_denied",t.UNAUTHENTICATED="unauthenticated",t.RESOURCE_EXHAUSTED="resource_exhausted",t.FAILED_PRECONDITION="failed_precondition",t.ABORTED="aborted",t.OUT_OF_RANGE="out_of_range",t.UNIMPLEMENTED="unimplemented",t.INTERNAL="internal",t.UNAVAILABLE="unavailable",t.DATA_LOSS="data_loss",t.CAPTCHA_REQUIRED="captcha_required",t.CAPTCHA_INVALID="captcha_invalid",t.INVALID_PASSWORD="invalid_password",t.INVALID_STATUS="invalid_status",t.USER_PENDING="user_pending",t.USER_BLOCKED="user_blocked",t.INVALID_VERIFICATION_CODE="invalid_verification_code",t.TWO_FACTOR_REQUIRED="two_factor_required",t.INVALID_TWO_FACTOR="invalid_two_factor",t.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",t.UNDER_REVIEW="under_review",t.INVALID_REQUEST="invalid_request",t.UNAUTHORIZED_CLIENT="unauthorized_client",t.ACCESS_DENIED="access_denied",t.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",t.INVALID_SCOPE="invalid_scope",t.INVALID_GRANT="invalid_grant",t.SERVER_ERROR="server_error",t.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",t.INTERACTION_REQUIRED="interaction_required",t.LOGIN_REQUIRED="login_required",t.ACCOUNT_SELECTION_REQUIRED="account_selection_required",t.CONSENT_REQUIRED="consent_required",t.INVALID_REQUEST_URI="invalid_request_uri",t.INVALID_REQUEST_OBJECT="invalid_request_object",t.REQUEST_NOT_SUPPORTED="request_not_supported",t.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",t.REGISTRATION_NOT_SUPPORTED="registration_not_supported"}(o||(o={}));var a=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},u=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},c=function(){function t(){this.fnPromiseMap=new Map}return t.prototype.run=function(t,e){return a(this,void 0,void 0,(function(){var n,r=this;return u(this,(function(o){switch(o.label){case 0:return[4,n=this.fnPromiseMap.get(t)];case 1:return o.sent()||(n=new Promise((function(n,o){a(r,void 0,void 0,(function(){var r,i,s;return u(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return a.sent(),r=e(),i=n,[4,r];case 2:return i.apply(void 0,[a.sent()]),[3,5];case 3:return s=a.sent(),o(s),[3,5];case 4:return this.fnPromiseMap.delete(t),[7];case 5:return[2]}}))}))})),this.fnPromiseMap.set(t,n)),[2,n]}}))}))},t.prototype.runIdlePromise=function(){return Promise.resolve()},t}(),f=function(){return(f=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},l=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},h=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},p=function(t,e){return l(this,void 0,void 0,(function(){var n,r,i,s,a;return h(this,(function(u){switch(u.label){case 0:n=null,r=null,u.label=1;case 1:return u.trys.push([1,4,,5]),(i=Object.assign({},e)).method||(i.method="GET"),i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body)),[4,fetch(t,i)];case 2:return[4,u.sent().json()];case 3:return(null==(s=u.sent())?void 0:s.error)?(r=s).error_uri=new URL(t).pathname:n=s,[3,5];case 4:return a=u.sent(),r={error:o.UNREACHABLE,error_description:a.message,error_uri:new URL(t).pathname},[3,5];case 5:if(r)throw r;return[2,n]}}))}))};var d=new(function(){function t(){}return t.prototype.getItem=function(t){return l(this,void 0,void 0,(function(){return h(this,(function(e){return[2,window.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return l(this,void 0,void 0,(function(){return h(this,(function(e){return window.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return l(this,void 0,void 0,(function(){return h(this,(function(n){return window.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return window.localStorage.getItem(t)},t.prototype.removeItemSync=function(t){window.localStorage.removeItem(t)},t.prototype.setItemSync=function(t,e){window.localStorage.setItem(t,e)},t}());function y(t){var e=!0;return(null==t?void 0:t.expires_at)&&(null==t?void 0:t.access_token)&&(e=t.expires_at<new Date),e}var g,v,m,b=function(){function t(t){this.credentials=null,this.singlePromise=new c,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage}return t.prototype.getStorageCredentialsSync=function(){var t=null,e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t},t.prototype.setCredentials=function(t){return l(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return(null==t?void 0:t.expires_in)?(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30)),this.storage?(e=JSON.stringify(t),[4,this.storage.setItem(this.tokenSectionName,e)]):[3,2]):[3,3];case 1:n.sent(),n.label=2;case 2:return this.credentials=t,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:n.sent(),n.label=5;case 5:this.credentials=null,n.label=6;case 6:return[2]}}))}))},t.prototype.getCredentials=function(){return l(this,void 0,void 0,(function(){var t=this;return h(this,(function(e){return[2,this.singlePromise.run("getCredentials",(function(){return l(t,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return y(this.credentials)?(t=this,[4,this.getStorageCredentials()]):[3,2];case 1:t.credentials=e.sent(),e.label=2;case 2:return[2,this.credentials]}}))}))}))]}))}))},t.prototype.getStorageCredentials=function(){return l(this,void 0,void 0,(function(){var t=this;return h(this,(function(e){return[2,this.singlePromise.run("_getStorageCredentials",(function(){return l(t,void 0,void 0,(function(){var t,e;return h(this,(function(n){switch(n.label){case 0:return t=null,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),t=null,[3,5];case 5:return[2,t]}}))}))}))]}))}))},t}(),w=function(){function t(e){this.singlePromise=new c,this.apiOrigin=e.apiOrigin,this.clientId=e.clientId,this.retry=this.formatRetry(e.retry,t.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=p,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||d,this.localCredentials=new b({tokenSectionName:"credentials_"+e.clientId,storage:this.storage}),this.clientSecret=e.clientSecret,this.refreshTokenFunc=e.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=e.anonymousSignInFunc}return t.prototype.setCredentials=function(t){return this.localCredentials.setCredentials(t)},t.prototype.getAccessToken=function(){return l(this,void 0,void 0,(function(){var t,e;return h(this,(function(n){switch(n.label){case 0:return[4,this.getCredentials()];case 1:return(null==(t=n.sent())?void 0:t.access_token)?[2,Promise.resolve(t.access_token)]:(e={error:o.UNAUTHENTICATED},[2,Promise.reject(e)])}}))}))},t.prototype.request=function(e,n){return l(this,void 0,void 0,(function(){var r,i,a,u,c,l,p;return h(this,(function(h){switch(h.label){case 0:return n||(n={}),r=this.formatRetry(n.retry,this.retry),n.headers=n.headers||{},this.headers&&(n.headers=f(f({},this.headers),n.headers)),n.headers["x-request-id"]||(n.headers["x-request-id"]=s()),n.headers["x-device-id"]?[3,2]:[4,this.getDeviceId()];case 1:i=h.sent(),n.headers["x-device-id"]=i,h.label=2;case 2:return(null==n?void 0:n.withCredentials)?[4,this.getCredentials()]:[3,4];case 3:return(a=h.sent())&&(this.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token="+a.access_token):n.headers.Authorization=a.token_type+" "+a.access_token),[3,5];case 4:this.clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id="+this.clientId),h.label=5;case 5:e.startsWith("/")&&(e=this.apiOrigin+e),u=null,c=r+1,l=0,h.label=6;case 6:if(!(l<c))return[3,15];h.label=7;case 7:return h.trys.push([7,9,,12]),[4,this.baseRequest(e,n)];case 8:return u=h.sent(),[3,15];case 9:return p=h.sent(),n.withCredentials&&p&&p.error===o.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,11];case 10:return h.sent(),[2,Promise.reject(p)];case 11:return l!==r&&p&&"unreachable"===p.error?[3,12]:[2,Promise.reject(p)];case 12:return[4,this.sleep(t.retryInterval)];case 13:h.sent(),h.label=14;case 14:return l++,[3,6];case 15:return[2,u]}}))}))},t.prototype.getCredentials=function(){return l(this,void 0,void 0,(function(){var t,e,n;return h(this,(function(r){switch(r.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return y(t=r.sent())?t&&"anonymous"===t.scope?this.anonymousSignInFunc?[4,this.anonymousSignInFunc(t)]:[3,5]:[3,8]:[3,10];case 2:return e=r.sent(),(n=e)?[3,4]:[4,this.localCredentials.getCredentials()];case 3:n=r.sent(),r.label=4;case 4:return t=n,[3,7];case 5:return[4,this.anonymousSignIn(t)];case 6:t=r.sent(),r.label=7;case 7:return[3,10];case 8:return[4,this.refreshToken(t)];case 9:t=r.sent(),r.label=10;case 10:return[2,t]}}))}))},t.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},t.prototype.getCredentialsAsync=function(){return this.getCredentials()},t.prototype.getScope=function(){return l(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=e.sent())?[2,t.scope]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},t.prototype.getGroups=function(){return l(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=e.sent())?[2,t.groups]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},t.prototype.checkRetry=function(e){var n=null;if(("number"!=typeof e||e<t.minRetry||e>t.maxRetry)&&(n={error:o.UNREACHABLE,error_description:"wrong options param: retry"}),n)throw n;return e},t.prototype.formatRetry=function(t,e){return void 0===t?e:this.checkRetry(t)},t.prototype.sleep=function(t){return l(this,void 0,void 0,(function(){return h(this,(function(e){return[2,new Promise((function(e){setTimeout((function(){e()}),t)}))]}))}))},t.prototype.refreshToken=function(t){return l(this,void 0,void 0,(function(){var e=this;return h(this,(function(n){return[2,this.singlePromise.run("_refreshToken",(function(){return l(e,void 0,void 0,(function(){var e,n;return h(this,(function(r){switch(r.label){case 0:if(!t||!t.refresh_token)return[2,this.unAuthenticatedError("no refresh token found in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.refreshTokenFunc(t.refresh_token)];case 2:return e=r.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return r.sent(),[2,e];case 4:return(n=r.sent()).error!==o.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},t.prototype.anonymousSignIn=function(t){return l(this,void 0,void 0,(function(){var e=this;return h(this,(function(n){return[2,this.singlePromise.run("_anonymous",(function(){return l(e,void 0,void 0,(function(){var e,n;return h(this,(function(r){switch(r.label){case 0:if(!t||"anonymous"!==t.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.request("/auth/v1/signin/anonymously",{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret}})];case 2:return e=r.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return r.sent(),[2,e];case 4:return(n=r.sent()).error!==o.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},t.prototype.defaultRefreshTokenFunc=function(t){return void 0===t||""===t?this.unAuthenticatedError("refresh token not found"):this.request("/auth/v1/token",{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}})},t.prototype.getDeviceId=function(){return l(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem("device_id")];case 1:return"string"==typeof(t=e.sent())&&t.length>=16&&t.length<=48?[3,3]:(t=s(),[4,this.storage.setItem("device_id",t)]);case 2:e.sent(),e.label=3;case 3:return this.deviceID=t,[2,t]}}))}))},t.prototype.unAuthenticatedError=function(t){var e={error:o.UNAUTHENTICATED,error_description:t};return Promise.reject(e)},t.defaultRetry=2,t.minRetry=0,t.maxRetry=5,t.retryInterval=1e3,t}();!function(t){t.AUTH_SIGN_IN_URL="/auth/v1/signin",t.AUTH_SIGN_IN_ANONYMOUSLY_URL="/auth/v1/signin/anonymously",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v1/signin/with/provider",t.AUTH_SIGN_UP_URL="/auth/v1/signup",t.AUTH_TOKEN_URL="/auth/v1/token",t.AUTH_REVOKE_URL="/auth/v1/revoke",t.PROVIDER_BIND_URL="/auth/v1/user/provider/bind",t.PROVIDER_TOKEN_URL="/auth/v1/provider/token",t.PROVIDER_URI_URL="/auth/v1/provider/uri",t.USER_ME_URL="/auth/v1/user/me",t.USER_QUERY_URL="/auth/v1/user/query",t.USER_PRIFILE_URL="/auth/v1/user/profile",t.USER_TRANS_BY_PROVIDER_URL="/auth/v1/user/trans/by/provider",t.VERIFICATION_URL="/auth/v1/verification",t.VERIFY_URL="/auth/v1/verification/verify",t.PROVIDER_LIST="/auth/v1/user/provider",t.PROVIDER_UNBIND_URL="/auth/v1/user/provider",t.CHECK_PWD_URL="/auth/v1/user/sudo",t.SUDO_URL="/auth/v1/user/sudo",t.BIND_CONTACT_URL="/auth/v1/user/contact",t.AUTH_SET_PASSWORD="/auth/v1/user/password",t.AUTH_RESET_PASSWORD="/auth/v1/reset",t.AUTH_GET_DEVICE_CODE="/auth/v1/device/code",t.CHECK_USERNAME="/auth/v1/checkUsername",t.CHECK_IF_USER_EXIST="/auth/v1/checkIfUserExist"}(g||(g={})),function(t){t.REGISTER="REGISTER",t.SIGN_IN="SIGN_IN",t.PASSWORD_RESET="PASSWORD_RESET",t.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",t.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(v||(v={})),function(t){t.INVALID_ARGUMENT="invalid_argument",t.DEADLINE_EXCEEDED="deadline_exceeded",t.NOT_FOUND="not_found",t.ALREADY_EXISTS="already_exists",t.PERMISSION_DENIED="permission_denied",t.ABORTED="aborted",t.OUT_OF_RANGE="out_of_range",t.UNIMPLEMENTED="unimplemented",t.INTERNAL="internal",t.UNAVAILABLE="unavailable",t.DATA_LOSS="data_loss",t.CAPTCHA_REQUIRED="captcha_required",t.CAPTCHA_INVALID="captcha_invalid",t.INVALID_PASSWORD="invalid_password",t.PASSWORD_NOT_SET="password_not_set",t.INVALID_STATUS="invalid_status",t.USER_PENDING="user_pending",t.USER_BLOCKED="user_blocked"}(m||(m={}));var _=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},E=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},I=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=d),this.config=t,this.tokenSectionName="captcha_"+t.clientId}return t.prototype.request=function(t,e){return _(this,void 0,void 0,(function(){var n,r,o,i;return E(this,(function(s){switch(s.label){case 0:return e||(e={}),e.method||(e.method="GET"),n=e.method+":"+t,r=t,e.withCaptcha?[4,this.appendCaptchaTokenToURL(t,n,!1)]:[3,2];case 1:r=s.sent(),s.label=2;case 2:return s.trys.push([2,4,,7]),[4,this.config.request(r,e)];case 3:return o=s.sent(),[3,7];case 4:return"captcha_required"!==(i=s.sent()).error&&"captcha_invalid"!==i.error?[3,6]:[4,this.appendCaptchaTokenToURL(t,n,"captcha_invalid"===i.error)];case 5:return t=s.sent(),[2,this.config.request(t,e)];case 6:return[2,Promise.reject(i)];case 7:return[2,o]}}))}))},t.prototype.getDefaultOpenURIWithCallback=function(){if(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap")){var t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((function(){document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback},t.prototype.defaultOpenURIWithCallback=function(t){return _(this,void 0,void 0,(function(){var e,n;return E(this,(function(r){return e=document.getElementById("captcha_panel_wrap"),n=document.createElement("iframe"),e.innerHTML="",n.setAttribute("src",t),n.setAttribute("id","review-panel-iframe"),n.style.cssText="min-width:355px;display:block;height:355px;margin:0 auto;background-color: rgb(255, 255, 255);border: none;",e.appendChild(n),e.style.display="block",[2,new Promise((function(t,r){n.onload=function(){try{var o=window.location,i=n.contentWindow.location;if(i.host+i.pathname===o.host+o.pathname){e.style.display="none";var s=new URLSearchParams(i.search),a=s.get("captcha_token");return a?t({captcha_token:a,expires_in:Number(s.get("expires_in"))}):r({error:s.get("error"),error_description:s.get("error_description")})}e.style.display="block"}catch(t){e.style.display="block"}}}))]}))}))},t.prototype.getCaptchaToken=function(t,e){return _(this,void 0,void 0,(function(){var n,r,o,i,s;return E(this,(function(a){switch(a.label){case 0:return t?[3,2]:[4,this.findCaptchaToken()];case 1:if(n=a.sent())return[2,n];a.label=2;case 2:return r=window.location.origin+window.location.pathname+"?__captcha=on",[4,this.config.request("/auth/v1/captcha/init",{method:"POST",body:{client_id:this.config.clientId,redirect_uri:r,state:e},withCredentials:!1})];case 3:return(o=a.sent()).captcha_token?(i={captcha_token:o.captcha_token,expires_in:o.expires_in},this.saveCaptchaToken(i),[2,o.captcha_token]):[4,this.config.openURIWithCallback(o.url)];case 4:return s=a.sent(),this.saveCaptchaToken(s),[2,s.captcha_token]}}))}))},t.prototype.appendCaptchaTokenToURL=function(t,e,n){return _(this,void 0,void 0,(function(){var r;return E(this,(function(o){switch(o.label){case 0:return[4,this.getCaptchaToken(n,e)];case 1:return r=o.sent(),t.indexOf("?")>0?t+="&captcha_token="+r:t+="?captcha_token="+r,[2,t]}}))}))},t.prototype.saveCaptchaToken=function(t){return _(this,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:return t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10)),e=JSON.stringify(t),[4,this.config.storage.setItem(this.tokenSectionName,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.findCaptchaToken=function(){return _(this,void 0,void 0,(function(){var t,e;return E(this,(function(n){switch(n.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(t=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?[2,null]:[2,e.captcha_token];case 3:return n.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),[2,null];case 5:return[2,null]}}))}))},t}(),S=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},O=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},A=function(){function t(t){var e=t.request,n=t.credentialsClient;if(!n){var r={apiOrigin:t.apiOrigin,clientId:t.clientId,storage:t.storage};n=new w(r)}if(!e){var o=n.request.bind(n),i=new I({clientId:t.clientId,request:o,storage:t.storage});e=i.request.bind(i)}this.config={apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:n,storage:t.storage||d}}return t.parseParamsToSearch=function(t){return Object.keys(t).forEach((function(e){t[e]||delete t[e]})),new URLSearchParams(t).toString()},t.prototype.signIn=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.request(g.AUTH_SIGN_IN_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.request(g.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signUp=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.request(g.AUTH_SIGN_UP_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signOut=function(){return S(this,void 0,void 0,(function(){var t,e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.credentialsClient.getAccessToken()];case 1:return t=n.sent(),[4,this.config.request(g.AUTH_REVOKE_URL,{method:"POST",body:{token:t}})];case 2:return e=n.sent(),[4,this.config.credentialsClient.setCredentials()];case 3:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.getVerification=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return e=!1,"CUR_USER"!==t.target?[3,1]:(e=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:n.sent()&&(e=!0),n.label=3;case 3:return[2,this.config.request(g.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:!0,withCredentials:e})]}}))}))},t.prototype.verify=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.VERIFY_URL,{method:"POST",body:t})]}))}))},t.prototype.genProviderRedirectUri=function(t){return S(this,void 0,void 0,(function(){var e,n;return O(this,(function(r){return e=g.PROVIDER_URI_URL+"?client_id="+this.config.clientId+"&provider_id="+t.provider_id+"&redirect_uri="+encodeURIComponent(t.provider_redirect_uri)+"&state="+t.state,(n=t.other_params)&&"string"==typeof n.sign_out_uri&&n.sign_out_uri.length>0&&(e+="&other_params[sign_out_uri]="+n.sign_out_uri),[2,this.config.request(e,{method:"GET"})]}))}))},t.prototype.grantProviderToken=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.patchProviderToken=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]}))}))},t.prototype.signInWithProvider=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.config.request(g.AUTH_SIGN_IN_WITH_PROVIDER_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.bindWithProvider=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.getUserProfile=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.getUserInfo()]}))}))},t.prototype.getUserInfo=function(){return S(this,void 0,void 0,(function(){var t;return O(this,(function(e){switch(e.label){case 0:return[4,this.config.request(g.USER_ME_URL,{method:"GET",withCredentials:!0})];case 1:return(t=e.sent()).sub&&(t.uid=t.sub),[2,t]}}))}))},t.prototype.deleteMe=function(e){return S(this,void 0,void 0,(function(){var n;return O(this,(function(r){return n=g.USER_ME_URL+"?"+t.parseParamsToSearch(e),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.hasLoginState=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},t.prototype.getLoginState=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.config.credentialsClient.getCredentialsAsync()]}))}))},t.prototype.transByProvider=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.grantToken=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.AUTH_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.getProviders=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.config.request(g.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},t.prototype.unbindProvider=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_UNBIND_URL+"/"+t.provider_id,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.checkPassword=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.CHECK_PWD_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.bindPhone=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.BIND_CONTACT_URL,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.bindEmail=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.BIND_CONTACT_URL,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.setPassword=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.AUTH_SET_PASSWORD,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.updatePasswordByOld=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.sudo({password:t.old_password})];case 1:return e=n.sent(),[2,this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})]}}))}))},t.prototype.sudo=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(""+g.SUDO_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.getCurUserVerification=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return t.target="CUR_USER",[2,this.config.request(g.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]}))}))},t.prototype.changeBindedProvider=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.PROVIDER_LIST+"/"+t.provider_id+"/trans",{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})]}))}))},t.prototype.setUserProfile=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.queryUserProfile=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){return e=new URLSearchParams(t),[2,this.config.request(g.USER_QUERY_URL+"?"+e.toString(),{method:"GET",withCredentials:!0})]}))}))},t.prototype.setCustomSignFunc=function(t){this.getCustomSignTicketFn=t},t.prototype.signInWithCustomTicket=function(){return S(this,void 0,void 0,(function(){var t;return O(this,(function(e){switch(e.label){case 0:return[4,this.getCustomSignTicketFn()];case 1:return t=e.sent(),[2,this.signInWithProvider({provider_id:"custom",provider_token:t})]}}))}))},t.prototype.resetPassword=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.AUTH_RESET_PASSWORD,{method:"POST",body:t})]}))}))},t.prototype.deviceAuthorize=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.checkUsername=function(t){return S(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.config.request(g.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]}))}))},t.prototype.checkIfUserExist=function(t){return S(this,void 0,void 0,(function(){var e;return O(this,(function(n){return e=new URLSearchParams(t),[2,this.config.request(g.CHECK_IF_USER_EXIST+"?"+e.toString(),{method:"GET"})]}))}))},t.prototype.loginScope=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.config.credentialsClient.getScope()]}))}))},t.prototype.loginGroups=function(){return S(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.config.credentialsClient.getGroups()]}))}))},t}(),T=(n(12),function(){return(T=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)}),N=function(t){var e=t.apiOrigin,n=t.clientId,r=t.storage,o=t.request,i=t.anonymousSignInFunc;this.oauth2client=new w({apiOrigin:e,clientId:n,storage:r,baseRequest:o,anonymousSignInFunc:i}),this.authApi=new A(T(T({credentialsClient:this.oauth2client},t),{request:o?this.oauth2client.request.bind(this.oauth2client):void 0}))},R=function(){return(R=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},x=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},C=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},L=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},P=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},U=i.f.printWarn,D=i.f.throwError,j=i.c.ERRORS,k=i.c.COMMUNITY_SITE_URL,M=i.e.catchErrorsDecorator,B=i.d.CloudbaseEventEmitter,q="loginStateChanged",F=new B,W=function(){function t(t){var e=t.cache,n=t.oauthInstance;this.cache=e,this.oauthInstance=n,this.setUserInfo()}return t.prototype.checkLocalInfo=function(){return L(this,void 0,void 0,(function(){return P(this,(function(t){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return L(this,void 0,void 0,(function(){var t,e,n,r;return P(this,(function(o){switch(o.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=o.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),n=this,[4,this.getLocalUserInfoAsync("email")];case 3:return n.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),r=this,[4,this.getLocalUserInfoAsync("username")];case 4:return r.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}}))}))},t.prototype.update=function(t){return L(this,void 0,void 0,(function(){var e;return P(this,(function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(R({},t))];case 1:return e=n.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&D(j.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(){return L(this,void 0,void 0,(function(){var t;return P(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo()];case 1:return t=e.sent(),this.setLocalUserInfo(t),[2,t]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;return this.cache.getStore(e)[t]},t.prototype.getLocalUserInfoAsync=function(t){return L(this,void 0,void 0,(function(){var e;return P(this,(function(n){switch(n.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,n.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,n=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username"].forEach((function(e){t[e]=n[e]}))},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},x([M({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"update",null),x([M({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[String,String]),C("design:returntype",void 0)],t.prototype,"updatePassword",null),x([M({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",void 0)],t.prototype,"updateUsername",null),x([M({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"refresh",null),t}(),$=function(){function t(t){var e=t.envId,n=t.cache,r=t.oauthInstance;e||D(j.INVALID_PARAMS,"envId is not defined"),this.cache=n,this.oauthInstance=r,this.user=new W({cache:this.cache,oauthInstance:r})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return L(this,void 0,void 0,(function(){return P(this,(function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}}))}))},t}(),V=function(){function t(t){this.config=t,this.cache=t.cache,this.oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.bindPhone(t)]}))}))},t.prototype.unbindProvider=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},t.prototype.bindEmail=function(t){return this.oauthInstance.authApi.bindEmail(t)},t.prototype.verify=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.getVerification(t)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}U(j.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return L(this,void 0,void 0,(function(){var t;return P(this,(function(e){switch(e.label){case 0:return[4,this.getLoginState()];case 1:return(t=e.sent())?[4,t.user.checkLocalInfoAsync()]:[3,3];case 2:return e.sent(),[2,t.user||null];case 3:return[2,null]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),L(this,void 0,void 0,(function(){return P(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(){return L(this,void 0,void 0,(function(){return P(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signIn=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signUp=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signUp(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setPassword=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&D(j.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,e.sent().exist]}}))}))},t.prototype.signOut=function(){return L(this,void 0,void 0,(function(){var t;return P(this,(function(e){switch(e.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut()];case 1:return e.sent(),[4,this.cache.removeStoreAsync(t)];case 2:return e.sent(),F.fire(q),[2]}}))}))},t.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new $({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;U(j.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return L(this,void 0,void 0,(function(){return P(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.getLoginState()];case 1:return t.sent()?[2,new $({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(){return L(this,void 0,void 0,(function(){return P(this,(function(t){return[2,this.oauthInstance.authApi.getUserInfo()]}))}))},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return L(this,void 0,void 0,(function(){return P(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}}))}))},t.prototype.grantProviderToken=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.patchProviderToken=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.grantToken=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return L(this,void 0,void 0,(function(){return P(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return L(this,void 0,void 0,(function(){return P(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return L(this,void 0,void 0,(function(){return P(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return L(this,void 0,void 0,(function(){return P(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return L(this,void 0,void 0,(function(){var e,n=this;return P(this,(function(r){switch(r.label){case 0:return F.on(q,(function(){return L(n,void 0,void 0,(function(){var e;return P(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=r.sent(),t.call(this,e),[2]}}))}))},t.prototype.createLoginState=function(){return L(this,void 0,void 0,(function(){var t;return P(this,(function(e){switch(e.label){case 0:return[4,(t=new $({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return e.sent(),[4,t.user.refresh()];case 2:return e.sent(),F.fire(q),[2,t]}}))}))},x([M({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),x([M({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"unbindProvider",null),x([M({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",void 0)],t.prototype,"bindEmail",null),x([M({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"verify",null),x([M({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"getVerification",null),x([M({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"getCurrentUser",null),x([M({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"signInAnonymously",null),x([M({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),x([M({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"signUp",null),x([M({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),x([M({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"signOut",null),x([M({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"getLoginState",null),x([M({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"getUserInfo",null),x([M({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"bindWithProvider",null),t}(),H={name:"auth",namespace:"auth",entity:function(t){if(void 0===t&&(t={region:"",persistence:"local"}),this.authInstance)return U(j.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var e=this.platform,n=e.adapter,r=e.runtime,o=t.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=this.config,s=i.env,a=i.persistence,u=i.debug,c=i.clientId,f=i.storage,l=new N({clientId:c,apiOrigin:this.request.getBaseEndPoint(),storage:(null==t?void 0:t.storage)||f,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc});return this.oauthInstance=l,this.authInstance=new V({env:s,region:t.region,persistence:a,debug:u,cache:this.cache,runtime:r,_fromApp:this,oauthInstance:l}),this.authInstance}};try{cloudbase.registerComponent(H)}catch(t){}function G(t){try{t.registerComponent(H)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"registerRealtime",(function(){return q}));var r=n(15),o=n.n(r),i=n(16),s=n.n(i),a=n(17),u=n.n(a);function c(t){return void 0===t&&(t=""),(t?t+"_":"")+ +new Date+"_"+Math.random()}var f,l,h=function(t){this.close=t.close,this.onChange=t.onChange,this.onError=t.onError,t.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return t.virtualClient}})},p=function(t){var e,n,r=t.id,o=t.docChanges,i=t.docs,s=t.msgType,a=t.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return e||(e=JSON.parse(JSON.stringify(o))),e},enumerable:!0},docs:{get:function(){return n||(n=JSON.parse(JSON.stringify(i))),n},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})},d=(f=function(t,e){return(f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),y=function(t){function e(e){var n=t.call(this,"Watch Error "+JSON.stringify(e.msgData)+" (requestid: "+e.requestId+")")||this;return n.isRealtimeErrorMessageError=!0,n.payload=e,n}return d(e,t),e}(Error),g=function(t){return null==t?void 0:t.isRealtimeErrorMessageError},v=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="timeout",e.payload=null,e.generic=!0,e}return d(e,t),e}(Error),m=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="cancelled",e.payload=null,e.generic=!0,e}return d(e,t),e}(Error),b=function(t){function e(e){var n=t.call(this,e.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: "+this.errCode+" "+(w[this.errCode]||"")+" | errMsg: "+this.errMsg},set:function(t){this.errMsg=t}}}),n.errCode=e.errCode||"UNKNOWN_ERROR",n.errMsg=e.errMsg,n}return d(e,t),Object.defineProperty(e.prototype,"message",{get:function(){return"errCode: "+this.errCode+" | errMsg: "+this.errMsg},set:function(t){this.errMsg=t},enumerable:!1,configurable:!0}),e}(Error),w={UNKNOWN_ERROR:"UNKNOWN_ERROR",SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG:"SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG",SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA:"SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED",SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL",SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR:"SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR"},_=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},E=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},I=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},S=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};!function(t){t.LOGGINGIN="LOGGINGIN",t.INITING="INITING",t.REBUILDING="REBUILDING",t.ACTIVE="ACTIVE",t.ERRORED="ERRORED",t.CLOSING="CLOSING",t.CLOSED="CLOSED",t.PAUSED="PAUSED",t.RESUMING="RESUMING"}(l||(l={}));var O=function(){function t(t){var e=this;this.watchStatus=l.INITING,this.wsLogin=function(t,n){return E(e,void 0,void 0,(function(){var e;return I(this,(function(r){switch(r.label){case 0:return this.watchStatus=l.LOGGINGIN,[4,this.login(t,n)];case 1:return e=r.sent(),this.envId||(this.envId=e.envId),[2,e]}}))}))},this.initWatch=function(t){return E(e,void 0,void 0,(function(){var e,n=this;return I(this,(function(r){switch(r.label){case 0:if(null!==this.initWatchPromise&&void 0!==this.initWatchPromise)return[2,this.initWatchPromise];this.initWatchPromise=new Promise((function(e,r){E(n,void 0,void 0,(function(){var n,o,i,s,a,u,f,h,d,y;return I(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):[4,this.wsLogin(this.envId,t)];case 1:return n=g.sent().envId,this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):(this.watchStatus=l.INITING,o={watchId:this.watchId,requestId:c(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(i=g.sent(),s=i.msgData,a=s.events,u=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:u-1,currentDocs:[]},a.length>0){for(f=0,h=a;f<h.length;f++)h[f].ID=u;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=u,d=new p({id:u,docChanges:[],docs:[],type:"init"}),this.listener.onChange(d),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=l.ACTIVE,this.availableRetries.INIT_WATCH=2,e(),[3,4];case 3:return y=g.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:e,reject:r}),[3,4];case 4:return[2]}}))}))})),e=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return r.sent(),e=!0,[3,4];case 3:return this.initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch "+(e?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(t){return E(e,void 0,void 0,(function(){var e,n=this;return I(this,(function(r){switch(r.label){case 0:if(null!==this.rebuildWatchPromise&&void 0!==this.rebuildWatchPromise)return[2,this.rebuildWatchPromise];this.rebuildWatchPromise=new Promise((function(e,r){E(n,void 0,void 0,(function(){var n,o,i,s;return I(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):[4,this.wsLogin(this.envId,t)];case 1:if(n=a.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):(this.watchStatus=l.REBUILDING,o={watchId:this.watchId,requestId:c(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return i=a.sent(),this.handleServerEvents(i),this.watchStatus=l.ACTIVE,this.availableRetries.REBUILD_WATCH=2,e(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:e,reject:r}),[3,4];case 4:return[2]}}))}))})),e=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return r.sent(),e=!0,[3,4];case 3:return this.rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch "+(e?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(t,n){return E(e,void 0,void 0,(function(){var e,r,o,i=this;return I(this,(function(s){return e="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new b({errCode:e?w.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:w.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:t})),n.reject(t)},o=function(t){i.useRetryTicket(n.operationName)?e?(i.initWatchPromise=void 0,n.resolve(i.initWatch(t))):(i.rebuildWatchPromise=void 0,n.resolve(i.rebuildWatch(t))):r()},this.handleCommonError(t,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){E(i,void 0,void 0,(function(){var t,e=this;return I(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),t=function(){return E(e,void 0,void 0,(function(){return I(this,(function(t){switch(t.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return t.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,t()];case 1:return r.sent(),[3,7];case 2:return[4,_(100)];case 3:return r.sent(),this.watchStatus!==l.PAUSED?[3,4]:(n.reject(new m(n.operationName+" cancelled due to pause after unknownError")),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,t()];case 5:return r.sent(),[3,7];case 6:o(!1),r.label=7;case 7:return[3,9];case 8:return r.sent(),o(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return E(e,void 0,void 0,(function(){var t,e,n;return I(this,(function(r){switch(r.label){case 0:if(t=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==l.ACTIVE)return this.watchStatus=l.CLOSED,this.onWatchClose(this,t),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=l.CLOSING,e={watchId:this.watchId,requestId:c(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:e})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=l.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,t),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){e.clearACKSchedule(),e.ackTimeoutId=setTimeout((function(){e.waitExpectedTimeoutId?e.scheduleSendACK():e.sendACK()}),1e4)},this.clearACKSchedule=function(){e.ackTimeoutId&&clearTimeout(e.ackTimeoutId)},this.sendACK=function(){return E(e,void 0,void 0,(function(){var t,e,n;return I(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==l.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(t={watchId:this.watchId,requestId:c(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:t})]):(console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"),[2]);case 1:return r.sent(),this.scheduleSendACK(),[3,3];case 2:if(e=r.sent(),g(e))switch((n=e.payload).msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return this.rebuildWatch(),[2];case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":return this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:n.msgData.code})),[2]}return this.availableRetries.CHECK_LAST&&this.availableRetries.CHECK_LAST>0?(this.availableRetries.CHECK_LAST-=1,this.scheduleSendACK()):this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:e})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(t,e){if(g(t)){switch(t.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void e.onSignError(t);case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":default:return void e.onNotRetryableError(t)}}else{if(function(t){return"timeout"===t.type}(t))return void e.onTimeoutError(t);if(function(t){return"cancelled"===t.type}(t))return void e.onCancelledError(t)}e.onUnknownError(t)},this.watchId="watchid_"+ +new Date+"_"+Math.random(),this.envId=t.envId,this.collectionName=t.collectionName,this.query=t.query,this.limit=t.limit,this.orderBy=t.orderBy,this.send=t.send,this.login=t.login,this.isWSConnected=t.isWSConnected,this.onceWSConnected=t.onceWSConnected,this.getWaitExpectedTimeoutLength=t.getWaitExpectedTimeoutLength,this.onWatchStart=t.onWatchStart,this.onWatchClose=t.onWatchClose,this.debug=t.debug,this.availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new h({close:function(){e.closeWatch()},onChange:t.onChange,onError:t.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return t.prototype.onMessage=function(t){var e=this;switch(this.watchStatus){case l.PAUSED:if("ERROR"!==t.msgType)return;break;case l.LOGGINGIN:case l.INITING:case l.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while "+this.watchStatus);case l.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case l.ERRORED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has ended with error")}if(this.sessionInfo)switch(this.scheduleSendACK(),t.msgType){case"NEXT_EVENT":console.warn("nextevent "+t.msgData.currEvent+" ignored",t),this.handleServerEvents(t);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<t.msgData.currEvent&&(this.sessionInfo.expectEventId=t.msgData.currEvent,this.clearWaitExpectedEvent(),this.waitExpectedTimeoutId=setTimeout((function(){e.rebuildWatch()}),this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength "+this.getWaitExpectedTimeoutLength()));break;case"ERROR":this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:t.msgData.code+" - "+t.msgData.message}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg "+t.msgType+": ",t)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},t.prototype.closeWithError=function(t){var e;this.watchStatus=l.ERRORED,this.clearACKSchedule(),this.listener.onError(t),this.onWatchClose(this,(null===(e=this.sessionInfo)||void 0===e?void 0:e.queryID)||""),console.log("[realtime] client closed ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},t.prototype.pause=function(){this.watchStatus=l.PAUSED,console.log("[realtime] client paused ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},t.prototype.resume=function(){return E(this,void 0,void 0,(function(){var t;return I(this,(function(e){switch(e.label){case 0:this.watchStatus=l.RESUMING,console.log("[realtime] client resuming with "+(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH")+" ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return e.sent(),console.log("[realtime] client successfully resumed ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),[3,4];case 3:return t=e.sent(),console.error("[realtime] client resume failed ("+this.collectionName+" "+this.query+") ("+this.watchId+")",t),[3,4];case 4:return[2]}}))}))},t.prototype.useRetryTicket=function(t){return!!(this.availableRetries[t]&&this.availableRetries[t]>0)&&(this.availableRetries[t]-=1,console.log("[realtime] "+t+" use a retry ticket, now only "+this.availableRetries[t]+" retry left"),!0)},t.prototype.handleServerEvents=function(t){return E(this,void 0,void 0,(function(){var e;return I(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(t)];case 1:return n.sent(),this.postHandleServerEventsValidityCheck(t),[3,3];case 2:throw e=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",e),e;case 3:return[2]}}))}))},t.prototype.handleServerEventsInternel=function(t){return E(this,void 0,void 0,(function(){var e,n,r,i,a,c,f,l,h,d,y,g;return I(this,(function(v){switch(v.label){case 0:if(e=t.requestId,n=t.msgData.events,r=t.msgType,!n.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=n.map(A)}catch(t){return this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:t})),[2]}c=S(i.currentDocs),f=!1,l=function(n,l){var d,y,g,v,m,_,E,O,A,T,N,R;return I(this,(function(I){switch(I.label){case 0:return d=a[n],i.currentEventId>=d.id?(!a[n-1]||d.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur "+i.currentEventId+" but got "+d.id):console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId "+e+")"),[2,"continue"]):[3,1];case 1:if(i.currentEventId!==d.id-1)return[3,2];switch(d.dataType){case"update":if(!d.doc)switch(d.queueType){case"update":case"dequeue":if(y=c.find((function(t){return t._id===d.docId}))){if(g=u()(y),d.updatedFields&&Object.keys(d.updatedFields).forEach((function(t){o()(g,t,d.updatedFields[t])})),d.removedFields)for(v=0,m=d.removedFields;v<m.length;v++)_=m[v],s()(g,_);d.doc=g}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw O=new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '+t.requestId+")"}),h.closeWithError(O),O}break;case"replace":if(!d.doc)throw O=new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '+t.requestId+")"}),h.closeWithError(O),O;break;case"remove":(E=c.find((function(t){return t._id===d.docId})))?d.doc=E:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!d.doc)switch(d.queueType){case"dequeue":(E=c.find((function(t){return t._id===d.docId})))?d.doc=E:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw O=new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '+t.requestId+")"}),h.closeWithError(O),O}}switch(d.queueType){case"init":f?c.push(d.doc):(f=!0,c=[d.doc]);break;case"enqueue":c.push(d.doc);break;case"dequeue":(A=c.findIndex((function(t){return t._id===d.docId})))>-1?c.splice(A,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":(A=c.findIndex((function(t){return t._id===d.docId})))>-1?c[A]=d.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===l-1||a[n+1]&&a[n+1].id!==d.id)&&(T=S(c),N=a.slice(0,n+1).filter((function(t){return t.id===d.id})),h.sessionInfo.currentEventId=d.id,h.sessionInfo.currentDocs=c,R=new p({id:d.id,docChanges:N,docs:T,msgType:r}),h.listener.onChange(R)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur "+h.sessionInfo.currentEventId+" but got "+d.id),[4,h.rebuildWatch()];case 3:return I.sent(),[2,{value:void 0}];case 4:return[2]}}))},h=this,d=0,y=a.length,v.label=1;case 1:return d<y?[5,l(d,y)]:[3,4];case 2:if("object"==typeof(g=v.sent()))return[2,g.value];v.label=3;case 3:return d++,[3,1];case 4:return[2]}}))}))},t.prototype.postHandleServerEventsValidityCheck=function(t){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<t.msgData.currEvent&&console.warn("[realtime listener] internal non-fatal error: client eventId does not match with server event id after server event handling")):console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur")},t.prototype.clearWaitExpectedEvent=function(){this.waitExpectedTimeoutId&&(clearTimeout(this.waitExpectedTimeoutId),this.waitExpectedTimeoutId=void 0)},t}();function A(t){var e={id:t.ID,dataType:t.DataType,queueType:t.QueueType,docId:t.DocID,doc:t.Doc&&"{}"!==t.Doc?JSON.parse(t.Doc):void 0};return"update"===t.DataType&&(t.UpdatedFields&&(e.updatedFields=JSON.parse(t.UpdatedFields)),(t.removedFields||t.RemovedFields)&&(e.removedFields=JSON.parse(t.removedFields))),e}var T,N={1e3:{code:1e3,name:"Normal Closure",description:"Normal closure; the connection successfully completed whatever purpose for which it was created."},1001:{code:1001,name:"Going Away",description:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{code:1002,name:"Protocol Error",description:"The endpoint is terminating the connection due to a protocol error."},1003:{code:1003,name:"Unsupported Data",description:"The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)."},1005:{code:1005,name:"No Status Received",description:"Indicates that no status code was provided even though one was expected."},1006:{code:1006,name:"Abnormal Closure",description:"Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{code:1007,name:"Invalid frame payload data",description:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{code:1008,name:"Policy Violation",description:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{code:1009,name:"Message too big",description:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{code:1010,name:"Missing Extension",description:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{code:1011,name:"Internal Error",description:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{code:1012,name:"Service Restart",description:"The server is terminating the connection because it is restarting."},1013:{code:1013,name:"Try Again Later",description:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{code:1014,name:"Bad Gateway",description:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{code:1015,name:"TLS Handshake",description:"Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},3e3:{code:3e3,name:"Reconnect WebSocket",description:"The client is terminating the connection because it wants to reconnect"},3001:{code:3001,name:"No Realtime Listeners",description:"The client is terminating the connection because no more realtime listeners exist"},3002:{code:3002,name:"Heartbeat Ping Error",description:"The client is terminating the connection due to its failure in sending heartbeat messages"},3003:{code:3003,name:"Heartbeat Pong Timeout Error",description:"The client is terminating the connection because no heartbeat response is received from the server"},3050:{code:3050,name:"Server Close",description:"The client is terminating the connection because no heartbeat response is received from the server"}};!function(t){t[t.NormalClosure=1e3]="NormalClosure",t[t.GoingAway=1001]="GoingAway",t[t.ProtocolError=1002]="ProtocolError",t[t.UnsupportedData=1003]="UnsupportedData",t[t.NoStatusReceived=1005]="NoStatusReceived",t[t.AbnormalClosure=1006]="AbnormalClosure",t[t.InvalidFramePayloadData=1007]="InvalidFramePayloadData",t[t.PolicyViolation=1008]="PolicyViolation",t[t.MessageTooBig=1009]="MessageTooBig",t[t.MissingExtension=1010]="MissingExtension",t[t.InternalError=1011]="InternalError",t[t.ServiceRestart=1012]="ServiceRestart",t[t.TryAgainLater=1013]="TryAgainLater",t[t.BadGateway=1014]="BadGateway",t[t.TLSHandshake=1015]="TLSHandshake",t[t.ReconnectWebSocket=3e3]="ReconnectWebSocket",t[t.NoRealtimeListeners=3001]="NoRealtimeListeners",t[t.HeartbeatPingError=3002]="HeartbeatPingError",t[t.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",t[t.NoAuthentication=3050]="NoAuthentication"}(T||(T={}));var R=function(t,e){var n=N[t],r=n?n.name+", code "+t+", reason "+(e||n.description):"code "+t;return new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},x=null,C="web";function L(){return C}var P=function(){return(P=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},U=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},D=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},j=1,k=function(){function t(t){var e=this;this.virtualWSClient=new Set,this.queryIdClientMap=new Map,this.watchIdClientMap=new Map,this.pingFailed=0,this.pongMissed=0,this.logins=new Map,this.wsReadySubsribers=[],this.wsResponseWait=new Map,this.rttObserved=[],this.send=function(t){return U(e,void 0,void 0,(function(){var e=this;return D(this,(function(n){return[2,new Promise((function(n,r){U(e,void 0,void 0,(function(){var e,o,i,s,a,u,c,f,l=this;return D(this,(function(h){switch(h.label){case 0:o=!1,i=!1,s=function(t){o=!0,e&&clearTimeout(e),n(t)},a=function(t){i=!0,e&&clearTimeout(e),r(t)},t.timeout&&(e=setTimeout((function(){U(l,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return o&&i?[3,2]:[4,_(0)];case 1:t.sent(),o&&i||a(new v("wsclient.send timedout")),t.label=2;case 2:return[2]}}))}))}),t.timeout)),h.label=1;case 1:return h.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:h.sent(),h.label=3;case 3:if(!this.ws)return a(new Error("invalid state: ws connection not exists, can not send message")),[2];if(this.ws.readyState!==j)return a(new Error("ws readyState invalid: "+this.ws.readyState+", can not send message")),[2];t.waitResponse&&(u={resolve:s,reject:a,skipOnMessage:t.skipOnMessage},this.wsResponseWait.set(t.msg.requestId,u)),h.label=4;case 4:return h.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(t.msg))];case 5:return h.sent(),t.waitResponse||s(void 0),[3,7];case 6:return(c=h.sent())&&(a(c),t.waitResponse&&this.wsResponseWait.delete(t.msg.requestId)),[3,7];case 7:return[3,9];case 8:return f=h.sent(),a(f),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(t){e.virtualWSClient.forEach((function(e){e.closeWithError(t)}))},this.pauseClients=function(t){(t||e.virtualWSClient).forEach((function(t){t.pause()}))},this.resumeClients=function(t){(t||e.virtualWSClient).forEach((function(t){t.resume()}))},this.initWebSocketConnection=function(t,n){return void 0===n&&(n=e.maxReconnect),U(e,void 0,void 0,(function(){var e=this;return D(this,(function(r){switch(r.label){case 0:if(t&&this.reconnectState)return[2];if(t&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];t&&this.pauseClients(),this.close(T.ReconnectWebSocket),this.wsInitPromise=new Promise((function(r,o){U(e,void 0,void 0,(function(){var e,i,s=this;return D(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return e=a.sent(),[4,new Promise((function(t){var n=e.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=x;s.ws=r?new r(n):new WebSocket(n),t(void 0)}))];case 2:return a.sent(),this.ws.connect?[4,this.ws.connect()]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return a.sent(),r(),t&&(this.resumeClients(),this.reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),n>0?(this.wsInitPromise=void 0,[4,_(this.reconnectInterval)]):[3,9];case 7:a.sent(),t&&(this.reconnectState=!1),a.label=8;case 8:return r(this.initWebSocketConnection(t,n-1)),[3,10];case 9:o(i),t&&this.closeAllClients(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:i})),a.label=10;case 10:return[3,11];case 11:return[2]}}))}))})),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this.wsInitPromise];case 2:return r.sent(),this.wsReadySubsribers.forEach((function(t){return(0,t.resolve)()})),[3,5];case 3:return r.sent(),this.wsReadySubsribers.forEach((function(t){return(0,t.reject)()})),[3,5];case 4:return this.wsInitPromise=void 0,this.wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(t,n){if(!e.ws)throw new Error("can not initWebSocketEvent, ws not exists");var r=!1;e.ws.onopen=function(e){console.warn("[realtime] ws event: open",e),r=!0,t()},e.ws.onerror=function(t){e.logins=new Map,r?(console.error("[realtime] ws event: error",t),e.clearHeartbeat(),e.virtualWSClient.forEach((function(e){return e.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:t}))}))):(console.error("[realtime] ws open failed with ws event: error",t),n(t))},e.ws.onclose=function(t){switch(console.warn("[realtime] ws event: close",t),e.logins=new Map,e.clearHeartbeat(),t.code){case T.ReconnectWebSocket:case T.NoRealtimeListeners:break;case T.HeartbeatPingError:case T.HeartbeatPongTimeoutError:case T.NormalClosure:case T.AbnormalClosure:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients(R(t.code));break;case T.NoAuthentication:e.closeAllClients(R(t.code,t.reason));break;default:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients(R(t.code))}},e.ws.onmessage=function(t){var n,r=t.data;e.heartbeat();try{n=JSON.parse(r)}catch(t){throw new Error("[realtime] onMessage parse res.data error: "+t)}if("ERROR"===n.msgType){var o=null;e.virtualWSClient.forEach((function(t){t.watchId===n.watchId&&(o=t)})),o&&o.listener.onError(n)}var i=e.wsResponseWait.get(n.requestId);if(i){try{"ERROR"===n.msgType?i.reject(new y(n)):i.resolve(n)}catch(t){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",t)}finally{e.wsResponseWait.delete(n.requestId)}if(i.skipOnMessage)return}if("PONG"!==n.msgType){var s=n.watchId&&e.watchIdClientMap.get(n.watchId);if(s)s.onMessage(n);else switch(console.error("[realtime] no realtime listener found responsible for watchId "+n.watchId+": ",n),n.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(s=e.queryIdClientMap.get(n.msgData.queryID))&&s.onMessage(n);break;default:for(var a=0,u=Array.from(e.watchIdClientMap.entries());a<u.length;a++){u[a][1].onMessage(n);break}}}else if(e.lastPingSendTS){var c=Date.now()-e.lastPingSendTS;if(c>1e4)return void console.warn("[realtime] untrusted rtt observed: "+c);e.rttObserved.length>=3&&e.rttObserved.splice(0,e.rttObserved.length-3+1),e.rttObserved.push(c)}},e.heartbeat()}))},this.isWSConnected=function(){return Boolean(e.ws&&e.ws.readyState===j)},this.onceWSConnected=function(){return U(e,void 0,void 0,(function(){var t=this;return D(this,(function(e){return this.isWSConnected()?[2]:null!==this.wsInitPromise&&void 0!==this.wsInitPromise?[2,this.wsInitPromise]:[2,new Promise((function(e,n){t.wsReadySubsribers.push({resolve:e,reject:n})}))]}))}))},this.webLogin=function(t,n){return U(e,void 0,void 0,(function(){var e,r,o,i,s,a,u,f,l=this;return D(this,(function(h){switch(h.label){case 0:if(!n)if(t){if(e=this.logins.get(t)){if(e.loggedIn&&e.loginResult)return[2,e.loginResult];if(null!==e.loggingInPromise&&void 0!==e.loggingInPromise)return[2,e.loggingInPromise]}}else if(null!==(null==(r=this.logins.get(""))?void 0:r.loggingInPromise)&&void 0!==(null==r?void 0:r.loggingInPromise))return[2,r.loggingInPromise];o=new Promise((function(t,e){U(l,void 0,void 0,(function(){var n,r,o,i,s;return D(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return n=a.sent(),r={envId:n.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:c(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:L(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(i=a.sent()).msgData.code?e(new Error(i.msgData.code+" "+i.msgData.message)):t({envId:n.envId}),[3,4];case 3:return s=a.sent(),e(s),[3,4];case 4:return[2]}}))}))})),i=t&&this.logins.get(t),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this.logins.set(t||"",i)),h.label=1;case 1:return h.trys.push([1,3,,4]),[4,o];case 2:if(a=h.sent(),(u=t&&this.logins.get(t))&&u===i&&u.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(u){if(u.loggedIn&&u.loginResult)return[2,u.loginResult];if(null!==u.loggingInPromise&&void 0!==u.loggingInPromise)return[2,u.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw f=h.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,f;case 4:return[2]}}))}))},this.getWsSign=function(){return U(e,void 0,void 0,(function(){var t,e,n,r,o,i,s;return D(this,(function(a){switch(a.label){case 0:return this.wsSign&&this.wsSign.expiredTs>Date.now()?[2,this.wsSign]:(t=Date.now()+6e4,[4,this.context.appConfig.request.send("auth.wsWebSign",{runtime:L()})]);case 1:if((e=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: "+e.code);if(e.data)return n=e.data,r=n.signStr,o=n.wsUrl,i=n.secretVersion,s=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:i,envId:s,expiredTs:t}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return e.rttObserved.length?e.rttObserved.reduce((function(t,e){return t+e}))/e.rttObserved.length*1.5:5e3},this.ping=function(){return U(e,void 0,void 0,(function(){var t;return D(this,(function(e){switch(e.label){case 0:return t={watchId:void 0,requestId:c(),msgType:"PING",msgData:null},[4,this.send({msg:t})];case 1:return e.sent(),[2]}}))}))},this.onWatchStart=function(t,n){e.queryIdClientMap.set(n,t)},this.onWatchClose=function(t,n){n&&e.queryIdClientMap.delete(n),e.watchIdClientMap.delete(t.watchId),e.virtualWSClient.delete(t),e.virtualWSClient.size||e.close(T.NoRealtimeListeners)},this.maxReconnect=t.maxReconnect||5,this.reconnectInterval=t.reconnectInterval||1e4,this.context=t.context}return t.prototype.clearHeartbeat=function(){this.pingTimeoutId&&clearTimeout(this.pingTimeoutId),this.pongTimeoutId&&clearTimeout(this.pongTimeoutId)},t.prototype.close=function(t){this.clearHeartbeat(),this.ws&&(this.ws.close(t,N[t].name),this.ws=void 0)},t.prototype.watch=function(t){this.ws||void 0!==this.wsInitPromise&&null!==this.wsInitPromise||this.initWebSocketConnection(!1);var e=new O(P(P({},t),{send:this.send,login:this.webLogin,isWSConnected:this.isWSConnected,onceWSConnected:this.onceWSConnected,getWaitExpectedTimeoutLength:this.getWaitExpectedTimeoutLength,onWatchStart:this.onWatchStart,onWatchClose:this.onWatchClose,debug:!0}));return this.virtualWSClient.add(e),this.watchIdClientMap.set(e.watchId,e),e.listener},t.prototype.heartbeat=function(t){var e=this;this.clearHeartbeat(),this.pingTimeoutId=setTimeout((function(){U(e,void 0,void 0,(function(){var t=this;return D(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),this.ws&&this.ws.readyState===j?(this.lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return e.sent(),this.pingFailed=0,this.pongTimeoutId=setTimeout((function(){console.error("pong timed out"),t.pongMissed<2?(t.pongMissed+=1,t.heartbeat(!0)):t.initWebSocketConnection(!0)}),this.context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return e.sent(),this.pingFailed<2?(this.pingFailed+=1,this.heartbeat()):this.close(T.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),t?0:this.context.appConfig.realtimePingInterval)},t}(),M={target:"database",entity:function(){var t,e=this.platform,n=e.adapter,r=e.runtime;t=n.wsClass,x=t,function(t){C=t}(r)}},B={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=k}};try{cloudbase.registerComponent(B),cloudbase.registerHook(M)}catch(t){}function q(t){try{t.registerComponent(B),t.registerHook(M)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"getBaseEndPoint",(function(){return O.b})),n.d(e,"cloudbase",(function(){return Q}));var r,o=n(0),i=n(5),s=(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),a=function(){return(a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},u=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},c=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};var f=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return s(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(n,r){var o=t.url,s=t.data,a=t.headers,u=wx.request({url:Object(i.d)("https:",o),data:s,timeout:e._timeout,method:"POST",header:a,success:function(t){n(t)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&(e._timeout&&-1!==e._restrictedMethods.indexOf("post")&&"request:fail timeout"===t.errMsg)){console.warn(e._timeoutMsg);try{u.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,n=this;return new Promise((function(r){return u(e,void 0,void 0,(function(){var e,o,i,s,u,f;return c(this,(function(c){return e=t.url,o=t.file,i=t.data,s=t.headers,u=t.onUploadProgress,f=wx.uploadFile({url:e,filePath:o,name:"file",formData:a({},i),header:s,timeout:this._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&i.success_action_status&&(e.statusCode=parseInt(i.success_action_status,10)),r(e)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg)){console.warn(n._timeoutMsg);try{f.abort()}catch(t){}}}}),u&&f.onProgressUpdate((function(t){u(t)})),[2]}))}))}))},e.prototype.download=function(t){var e=this,n=this;return new Promise((function(r,o){var s=t.url,a=t.headers,u=wx.downloadFile({url:Object(i.d)("https:",s),header:a,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?r({statusCode:200,tempFilePath:t.tempFilePath}):r(t)},fail:function(t){o(t)},complete:function(t){if(t&&t.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg)){console.warn(n._timeoutMsg);try{u.abort()}catch(t){}}}})}))},e}(i.a),l={setItem:function(t,e){wx.setStorageSync(t,e)},getItem:function(t){return wx.getStorageSync(t)},removeItem:function(t){wx.removeStorageSync(t)},clear:function(){wx.clearStorageSync()}},h=function(t,e){void 0===e&&(e={});var n=wx.connectSocket(a({url:t},e));return{set onopen(t){n.onOpen(t)},set onmessage(t){n.onMessage(t)},set onclose(t){n.onClose(t)},set onerror(t){n.onError(t)},send:function(t){return n.send({data:t})},close:function(t,e){return n.close({code:t,reason:e})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};var p={genAdapter:function(){return{root:{},reqClass:f,wsClass:h,localStorage:l,primaryStorage:i.c.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0},runtime:"wx_mp"},d=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r},y=o.c.ERRORS,g={};function v(t,e){var n=e.name,r=e.namespace,o=e.entity,i=e.injectEvents,s=e.IIFE,a=void 0!==s&&s;if(g[n]||r&&t[r])throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"Duplicate component "+n}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:y.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(t)}if(g[n]=e,r?t.prototype[r]=o:function t(e,n){if(!(n instanceof Object))return n;switch(n.constructor){case Date:return new Date(n.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return n}for(var r=Object.keys(n),o=0,i=r;o<i.length;o++){var s=i[o];Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=t(e[s],n[s]))}return e}(t.prototype,o),i){var u=i.bus,c=i.events;if(!u||!c||0===c.length)return;var f=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[n]?t.prototype.events[n].events=d(t.prototype.events[n].events,c):t.prototype.events[n]={bus:u,events:c},t.prototype.fire=function(t,e){f(t,e);for(var n=0,r=Object.keys(this.events);n<r.length;n++){var o=r[n],i=this.events[o],s=i.bus;if(i.events.includes(t)){s.fire(t,e);break}}}}}var m={},b=function(){return(b=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},w=o.b.CloudbaseCache,_={},E={};function I(t){var e=t.env,n=t.platformInfo,r={userInfoKey:"user_info_"+e};_[e]=_[e]||new w(b(b({},t),{keys:r,platformInfo:n})),E[e]=E[e]||new w(b(b({},t),{keys:r,platformInfo:n,persistence:"local"}))}function S(t){return E[t]}var O=n(3),A=function(){return(A=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},T=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},N=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},R=o.c.ERRORS,x=o.f.genSeqId,C=o.f.isFormData,L=o.f.formatUrl,P=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function U(t,e,n){var r=t[e];t[e]=function(e){var o={},i={};n.forEach((function(n){var r=n.call(t,e),s=r.data,a=r.headers;Object.assign(o,s),Object.assign(i,a)}));var s=e.data;return s&&(C(s)?Object.keys(o).forEach((function(t){s.append(t,o[t])})):e.data=A(A({},s),o)),e.headers=A(A({},e.headers||{}),i),r.call(t,e)}}function D(){var t=x();return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+Object(O.e)(),"x-seqid":t}}}var j=function(){function t(t){this.throwWhenRequestFail=!1,this.config=t;var e={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post","put"]};this.reqClass=new m.adapter.reqClass(e),this.throwWhenRequestFail=t.throw||!1,this.localCache=S(this.config.env),U(this.reqClass,"post",[D]),U(this.reqClass,"upload",[D]),U(this.reqClass,"download",[D])}return t.prototype.post=function(t){return T(this,void 0,void 0,(function(){return N(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.upload=function(t){return T(this,void 0,void 0,(function(){return N(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.upload(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return T(this,void 0,void 0,(function(){return N(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.download(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(){return Object(O.b)()},t.prototype.getOauthAccessTokenV2=function(t){return T(this,void 0,void 0,(function(){var e,n;return N(this,(function(r){switch(r.label){case 0:return[4,t.getAccessToken()];case 1:return e=r.sent(),[4,t.getCredentials()];case 2:return n=r.sent(),[2,{accessToken:e,accessTokenExpire:new Date(n.expires_at).getTime()}]}}))}))},t.prototype.request=function(t,e,n){var r;return T(this,void 0,void 0,(function(){var o,i,s,a,u,c,f,l,h,p,d,y,g,v,m,b,w,_,E,I;return N(this,(function(S){switch(S.label){case 0:if(o="x-tcb-trace_"+this.config.env,i="application/x-www-form-urlencoded",s=A({action:t,dataVersion:O.a,env:this.config.env},e),-1!==P.indexOf(t))return[3,2];if(!(a=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return u=a.oauthInstance,c=u.oauth2client,f=s,[4,this.getOauthAccessTokenV2(c)];case 1:f.access_token=S.sent().accessToken,S.label=2;case 2:return"storage.uploadFile"===t?(l=new FormData,Object.keys(l).forEach((function(t){Object.prototype.hasOwnProperty.call(l,t)&&void 0!==l[t]&&l.append(t,s[t])})),i="multipart/form-data"):(i="application/json;charset=UTF-8",l={},Object.keys(s).forEach((function(t){void 0!==s[t]&&(l[t]=s[t])}))),h={headers:{"content-type":i}},(null==n?void 0:n.onUploadProgress)&&(h.onUploadProgress=n.onUploadProgress),this.config.region&&(h.headers["X-TCB-Region"]=this.config.region),(p=this.localCache.getStore(o))&&(h.headers["X-TCB-Trace"]=p),d=e.parse,y=e.inQuery,g=e.search,v={env:this.config.env},d&&(v.parse=!0),y&&(v=A(A({},y),v)),m=Object(O.c)(),b=m.BASE_URL,w=m.PROTOCOL,_=L(w,b,v),g&&(_+=g),[4,this.post(A({url:_,data:l},h))];case 3:if(E=S.sent(),(I=null===(r=E.header)||void 0===r?void 0:r["x-tcb-trace"])&&this.localCache.setStore(o,I),200!==Number(E.status)&&200!==Number(E.statusCode)||!E.data)throw new Error("network request error");return[2,E]}}))}))},t.prototype.send=function(t,e){return void 0===e&&(e={}),T(this,void 0,void 0,(function(){var n;return N(this,(function(r){switch(r.label){case 0:return[4,this.request(t,e,{onUploadProgress:e.onUploadProgress})];case 1:if((n=r.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:R.OPERATION_FAIL,msg:"["+n.data.code+"] "+n.data.message}));return[2,n.data]}}))}))},t}(),k={};var M=function(){return(M=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},B=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},q=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},F=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},W=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},$=o.a.useAdapters,V=o.a.useDefaultAdapter,H=o.c.ERRORS,G=o.c.COMMUNITY_SITE_URL,J=o.f.printWarn,K=o.e.catchErrorsDecorator,Y={timeout:15e3,persistence:"local"},z={},Q=new(function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return m},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this.cloudbaseConfig.env,_[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return S(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this.cloudbaseConfig.env,k[t];var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){if(!e.env)throw new Error(JSON.stringify({code:H.INVALID_PARAMS,msg:"env must not be specified"}));m.adapter||this.useDefaultAdapter();var n={timeout:e.timeout||5e3,timeoutMsg:"["+Object(O.d)()+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+e.timeout/1e3+"s"};this.requestClient=new m.adapter.reqClass(n),this.cloudbaseConfig=M(M({},Y),e),this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var r=this.cloudbaseConfig,o=r.env,i=r.persistence,s=r.debug,a=r.timeout,u=r.oauthClient;I({env:o,persistence:i,debug:s,platformInfo:this.platform}),Object(O.g)(o,e.region||"");var c=new t(this.cloudbaseConfig);return function(t){k[t.env]=new j(A(A({},t),{throw:!0}))}({env:o,region:e.region||"",timeout:a,oauthClient:u,_fromApp:c}),c.requestClient=this.requestClient,c},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=n,I({env:this.cloudbaseConfig.env,persistence:e,debug:n,platformInfo:this.platform})},t.prototype.registerExtension=function(t){z[t.name]=t},t.prototype.invokeExtension=function(t,e){return F(this,void 0,void 0,(function(){var n;return W(this,(function(r){switch(r.label){case 0:if(!(n=z[t]))throw new Error(JSON.stringify({code:H.INVALID_PARAMS,msg:"extension:"+t+" must be registered before invoke"}));return[4,n.invoke(e,this)];case 1:return[2,r.sent()]}}))}))},t.prototype.useAdapters=function(t){var e=$(t)||{},n=e.adapter,r=e.runtime;n&&(m.adapter=n),r&&(m.runtime=r)},t.prototype.registerHook=function(e){!function(t,e){var n=e.entity,r=e.target;if(Object.prototype.hasOwnProperty.call(t,r))throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"target:"+r+" is not exist"}));var o=t.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"target:"+r+" is not a function which is the only type supports hook"}));t.prototype[r]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.call.apply(n,d([this],t)),o.call.apply(o,d([this],t))}}(t,e)},t.prototype.registerComponent=function(e){v(t,e)},t.prototype.registerVersion=function(t){Object(O.i)(t)},t.prototype.registerSdkName=function(t){Object(O.h)(t)},t.prototype.registerEndPoint=function(t,e){Object(O.f)(t,e)},t.prototype.useDefaultAdapter=function(){var t=V(),e=t.adapter,n=t.runtime;m.adapter=e,m.runtime=n},t.prototype.formatTimeout=function(t){switch(!0){case t>6e5:return J(H.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),6e5;case t<100:return J(H.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},B([K({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+G]}),q("design:type",Function),q("design:paramtypes",[Object]),q("design:returntype",t)],t.prototype,"init",null),B([K({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+G]}),q("design:type",Function),q("design:paramtypes",[String,Object]),q("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}());Q.useAdapters(p);e.default=Q}])}));
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase",[],e):"object"==typeof exports?exports.cloudbase=e():t.cloudbase=e()}("undefined"!=typeof window?window:this,(function(){return function(){var t={829:function(t,e,n){"use strict";var r;n.d(e,{jJ:function(){return o},x_:function(){return i},Z1:function(){return r},CN:function(){return s}}),function(t){t.local="local",t.none="none",t.session="session"}(r||(r={}));var o=function(){},i=function(){};function s(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";for(var i in n)""===o?!r&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},195:function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=r(n(805)),i=n(755),s=n(338),a=n(766),u=n(337),c=n(98),f=n(529),l=r(n(536)).default.version;o.default.registerVersion(l);try{(0,i.registerAuth)(o.default),(0,s.registerFunctions)(o.default),(0,a.registerStorage)(o.default),(0,f.registerDatabase)(o.default),(0,u.registerRealtime)(o.default),(0,c.registerAnalytics)(o.default)}catch(t){}try{window.cloudbase=o.default}catch(t){}e.default=o.default,t.exports=o.default},98:function(t,e,n){"use strict";n.r(e),n.d(e,{registerAnalytics:function(){return h}});var r=n(142),o=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},i=r._G.Sg,s=r._G.vM,a=r.BM.D,u="analytics",c=["mall"],f=new(function(){function t(){}return t.prototype.analytics=function(t){return e=this,n=void 0,o=function(){var e,n,r;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(o){if(!function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))return!1;var e=t.report_data,n=t.report_type;return!1!==c.includes(n)&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!(void 0!==e.action_time&&!Number.isInteger(e.action_time))&&"string"==typeof e.action_type}(t))throw new Error(JSON.stringify({code:i.INVALID_PARAMS,msg:"[".concat(u,".analytics] invalid report data")}));return e=void 0===t.report_data.action_time?Math.floor(Date.now()/1e3):t.report_data.action_time,n={analytics_scene:t.report_type,analytics_data:Object.assign({},t.report_data,{action_time:e})},r={requestData:n},this.request.send("analytics.report",r),[2]}))},new((r=void 0)||(r=Promise))((function(t,i){function s(t){try{u(o.next(t))}catch(t){i(t)}}function a(t){try{u(o.throw(t))}catch(t){i(t)}}function u(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(s,a)}u((o=o.apply(e,n||[])).next())}));var e,n,r,o},function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);i>3&&s&&Object.defineProperty(e,n,s)}([a({customInfo:{className:"Cloudbase",methodName:"analytics"},title:"上报调用失败",messages:["请确认以下各项:"," 1 - 调用 analytics() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(s)]}),o("design:type",Function),o("design:paramtypes",[Object]),o("design:returntype",Promise)],t.prototype,"analytics",null),t}()),l={name:u,entity:{analytics:f.analytics}};try{cloudbase.registerComponent(l)}catch(t){}function h(t){try{t.registerComponent(l)}catch(t){console.warn(t)}}},805:function(t,e,n){"use strict";n.r(e),n.d(e,{cloudbase:function(){return st},default:function(){return at},getBaseEndPoint:function(){return U}});var r,o=n(142),i=n(829),s=(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},r(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),a=function(){return a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)},u=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return s(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(n,r){var o=t.url,s=t.data,a=t.headers,u=wx.request({url:(0,i.CN)("https:",o),data:s,timeout:e._timeout,method:"POST",header:a,success:function(t){n(t)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("post")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{u.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,n=this;return new Promise((function(r){return o=e,i=void 0,u=function(){var e,o,i,s,u,c;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(f){return e=t.url,o=t.file,i=t.data,s=t.headers,u=t.onUploadProgress,c=wx.uploadFile({url:e,filePath:o,name:"file",formData:a({},i),header:s,timeout:this._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&i.success_action_status&&(e.statusCode=parseInt(i.success_action_status,10)),r(e)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{c.abort()}catch(t){}}}}),u&&c.onProgressUpdate((function(t){u(t)})),[2]}))},new((s=void 0)||(s=Promise))((function(t,e){function n(t){try{a(u.next(t))}catch(t){e(t)}}function r(t){try{a(u.throw(t))}catch(t){e(t)}}function a(e){var o;e.done?t(e.value):(o=e.value,o instanceof s?o:new s((function(t){t(o)}))).then(n,r)}a((u=u.apply(o,i||[])).next())}));var o,i,s,u}))},e.prototype.download=function(t){var e=this,n=this;return new Promise((function(r,o){var s=t.url,a=t.headers,u=wx.downloadFile({url:(0,i.CN)("https:",s),header:a,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?r({statusCode:200,tempFilePath:t.tempFilePath}):r(t)},fail:function(t){o(t)},complete:function(t){if(t&&t.errMsg&&n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{u.abort()}catch(t){}}}})}))},e}(i.jJ),c={setItem:function(t,e){wx.setStorageSync(t,e)},getItem:function(t){return wx.getStorageSync(t)},removeItem:function(t){wx.removeStorageSync(t)},clear:function(){wx.clearStorageSync()}},f=function(t,e){void 0===e&&(e={});var n=wx.connectSocket(a({url:t},e));return{set onopen(t){n.onOpen(t)},set onmessage(t){n.onMessage(t)},set onclose(t){n.onClose(t)},set onerror(t){n.onError(t)},send:function(t){return n.send({data:t})},close:function(t,e){return n.close({code:t,reason:e})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}},l={genAdapter:function(){return{root:{},reqClass:u,wsClass:f,localStorage:c,primaryStorage:i.Z1.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0},runtime:"wx_mp"},h=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},p=o._G.Sg,d={};function y(t,e){var n=e.name,r=e.namespace,o=e.entity,i=e.injectEvents,s=e.IIFE,a=void 0!==s&&s;if(d[n]||r&&t[r])throw new Error(JSON.stringify({code:p.INVALID_OPERATION,msg:"Duplicate component ".concat(n)}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:p.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(t)}if(d[n]=e,r?t.prototype[r]=o:g(t.prototype,o),i){var u=i.bus,c=i.events;if(!u||!c||0===c.length)return;var f=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[n]?t.prototype.events[n].events=h(h([],t.prototype.events[n].events,!0),c,!0):t.prototype.events[n]={bus:u,events:c},t.prototype.fire=function(t,e){f(t,e);for(var n=0,r=Object.keys(this.events);n<r.length;n++){var o=r[n],i=this.events[o],s=i.bus;if(i.events.includes(t)){s.fire(t,e);break}}}}}function g(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=g(t[o],e[o]))}return t}var v={},m=function(){return m=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},m.apply(this,arguments)},w="user_info",b=o.Fs.q,_={},E={};function I(t){var e=t.env,n=t.platformInfo,r={userInfoKey:"".concat(w,"_").concat(e)};_[e]=_[e]||new b(m(m({},t),{keys:r,platformInfo:n})),E[e]=E[e]||new b(m(m({},t),{keys:r,platformInfo:n,persistence:"local"}))}function S(t){return E[t]}var O,A=o._G.tC,T=o._G.pM,N="",R="@cloudbase/js-sdk",C="https:",x="//tcb-api.tencentcloudapi.com/web";function L(t,e){x=t,e&&(C=e,T(e))}function P(){return{BASE_URL:x,PROTOCOL:C}}function U(){var t=P(),e=t.PROTOCOL,n=t.BASE_URL;return"".concat(e).concat(n).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]}!function(t){t.NULL="NULL",t.ANONYMOUS="ANONYMOUS",t.WECHAT="WECHAT",t.WECHAT_PUBLIC="WECHAT-PUBLIC",t.WECHAT_OPEN="WECHAT-OPEN",t.CUSTOM="CUSTOM",t.EMAIL="EMAIL",t.USERNAME="USERNAME",t.PHONE="PHONE"}(O||(O={}));var D=function(){return D=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},D.apply(this,arguments)},j=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},k=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},M=o._G.Sg,B=o.P6.Jc,q=o.P6.hp,F=o.P6.CN,W=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function $(t,e,n){var r=t[e];t[e]=function(e){var o={},i={};n.forEach((function(n){var r=n.call(t,e),s=r.data,a=r.headers;Object.assign(o,s),Object.assign(i,a)}));var s=e.data;return s&&(q(s)?Object.keys(o).forEach((function(t){s.append(t,o[t])})):e.data=D(D({},s),o)),e.headers=D(D({},e.headers||{}),i),r.call(t,e)}}function H(){var t=B();return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(N),"x-seqid":t}}}var V=function(){function t(t){this.throwWhenRequestFail=!1,this.config=t;var e={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"]};this.reqClass=new v.adapter.reqClass(e),this.throwWhenRequestFail=t.throw||!1,this.localCache=S(this.config.env),$(this.reqClass,"post",[H]),$(this.reqClass,"upload",[H]),$(this.reqClass,"download",[H])}return t.prototype.post=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.upload=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.upload(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.download(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(){return U()},t.prototype.getOauthAccessTokenV2=function(t){return j(this,void 0,void 0,(function(){var e,n;return k(this,(function(r){switch(r.label){case 0:return[4,t.getAccessToken()];case 1:return e=r.sent(),[4,t.getCredentials()];case 2:return n=r.sent(),[2,{accessToken:e,accessTokenExpire:new Date(n.expires_at).getTime()}]}}))}))},t.prototype.request=function(t,e,n){var r;return j(this,void 0,void 0,(function(){var o,i,s,a,u,c,f,l,h,p,d,y,g,v,m,w,b,_,E,I;return k(this,(function(S){switch(S.label){case 0:if(o="x-tcb-trace_".concat(this.config.env),i="application/x-www-form-urlencoded",s=D({action:t,dataVersion:"2020-01-10",env:this.config.env},e),-1!==W.indexOf(t))return[3,2];if(!(a=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return u=a.oauthInstance,c=u.oauth2client,f=s,[4,this.getOauthAccessTokenV2(c)];case 1:f.access_token=S.sent().accessToken,S.label=2;case 2:return"storage.uploadFile"===t?(l=new FormData,Object.keys(l).forEach((function(t){Object.prototype.hasOwnProperty.call(l,t)&&void 0!==l[t]&&l.append(t,s[t])})),i="multipart/form-data"):(i="application/json;charset=UTF-8",l={},Object.keys(s).forEach((function(t){void 0!==s[t]&&(l[t]=s[t])}))),h={headers:{"content-type":i}},(null==n?void 0:n.onUploadProgress)&&(h.onUploadProgress=n.onUploadProgress),this.config.region&&(h.headers["X-TCB-Region"]=this.config.region),(p=this.localCache.getStore(o))&&(h.headers["X-TCB-Trace"]=p),d=e.parse,y=e.inQuery,g=e.search,v={env:this.config.env},d&&(v.parse=!0),y&&(v=D(D({},y),v)),m=P(),w=m.BASE_URL,b=m.PROTOCOL,_=F(b,w,v),g&&(_+=g),[4,this.post(D({url:_,data:l},h))];case 3:if(E=S.sent(),(I=null===(r=E.header)||void 0===r?void 0:r["x-tcb-trace"])&&this.localCache.setStore(o,I),200!==Number(E.status)&&200!==Number(E.statusCode)||!E.data)throw new Error("network request error");return[2,E]}}))}))},t.prototype.send=function(t,e){return void 0===e&&(e={}),j(this,void 0,void 0,(function(){var n;return k(this,(function(r){switch(r.label){case 0:return[4,this.request(t,e,{onUploadProgress:e.onUploadProgress})];case 1:if((n=r.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:M.OPERATION_FAIL,msg:"[".concat(n.data.code,"] ").concat(n.data.message)}));return[2,n.data]}}))}))},t}(),G={},J=function(){return J=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},J.apply(this,arguments)},K=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},Y=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},z=o.j$.Fk,Q=o.j$.xY,X=o._G.Sg,Z=o._G.vM,tt=o.P6.xe,et=o.BM.D,nt={timeout:15e3,persistence:"local"},rt=6e5,ot={},it=function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return v},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this.cloudbaseConfig.env,_[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return S(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this.cloudbaseConfig.env,G[t];var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){if(!e.env)throw new Error(JSON.stringify({code:X.INVALID_PARAMS,msg:"env must not be specified"}));v.adapter||this.useDefaultAdapter();var n={timeout:e.timeout||5e3,timeoutMsg:"[".concat(R,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(e.timeout/1e3,"s")};this.requestClient=new v.adapter.reqClass(n),this.cloudbaseConfig=J(J({},nt),e),this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var r=this.cloudbaseConfig,o=r.env,i=r.persistence,s=r.debug,a=r.timeout,u=r.oauthClient;I({env:o,persistence:i,debug:s,platformInfo:this.platform}),function(t,e,n){L(e?"//".concat(t,".").concat(e,".tcb-api.tencentcloudapi.com/web"):"//".concat(t,".ap-shanghai.tcb-api.tencentcloudapi.com/web"),void 0)}(o,e.region||"");var c=new t(this.cloudbaseConfig);return function(t){G[t.env]=new V(D(D({},t),{throw:!0}))}({env:o,region:e.region||"",timeout:a,oauthClient:u,_fromApp:c}),c.requestClient=this.requestClient,c},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=n,I({env:this.cloudbaseConfig.env,persistence:e,debug:n,platformInfo:this.platform})},t.prototype.registerExtension=function(t){ot[t.name]=t},t.prototype.invokeExtension=function(t,e){return n=this,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(r){switch(r.label){case 0:if(!(n=ot[t]))throw new Error(JSON.stringify({code:X.INVALID_PARAMS,msg:"extension:".concat(t," must be registered before invoke")}));return[4,n.invoke(e,this)];case 1:return[2,r.sent()]}}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{u(i.next(t))}catch(t){e(t)}}function a(t){try{u(i.throw(t))}catch(t){e(t)}}function u(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(s,a)}u((i=i.apply(n,r||[])).next())}));var n,r,o,i},t.prototype.useAdapters=function(t){var e=z(t)||{},n=e.adapter,r=e.runtime;n&&(v.adapter=n),r&&(v.runtime=r)},t.prototype.registerHook=function(e){!function(t,e){var n=e.entity,r=e.target;if(Object.prototype.hasOwnProperty.call(t,r))throw new Error(JSON.stringify({code:p.INVALID_OPERATION,msg:"target:".concat(r," is not exist")}));var o=t.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:p.INVALID_OPERATION,msg:"target:".concat(r," is not a function which is the only type supports hook")}));t.prototype[r]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.call.apply(n,h([this],t,!1)),o.call.apply(o,h([this],t,!1))}}(t,e)},t.prototype.registerComponent=function(e){y(t,e)},t.prototype.registerVersion=function(t){!function(t){N=t}(t)},t.prototype.registerSdkName=function(t){!function(t){R=t,A(t)}(t)},t.prototype.registerEndPoint=function(t,e){L(t,e)},t.prototype.useDefaultAdapter=function(){var t=Q(),e=t.adapter,n=t.runtime;v.adapter=e,v.runtime=n},t.prototype.formatTimeout=function(t){switch(!0){case t>rt:return tt(X.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),rt;case t<100:return tt(X.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},K([et({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z)]}),Y("design:type",Function),Y("design:paramtypes",[Object]),Y("design:returntype",t)],t.prototype,"init",null),K([et({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z)]}),Y("design:type",Function),Y("design:paramtypes",[String,Object]),Y("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}(),st=new it;st.useAdapters(l);var at=st},755:function(t,e,n){"use strict";n.r(e),n.d(e,{Auth:function(){return K},LoginState:function(){return J},registerAuth:function(){return z}});var r,o,i,s=n(142);function a(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}!function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(r||(r={})),(i=o||(o={})).UNREACHABLE="unreachable",i.LOCAL="local",i.CANCELLED="cancelled",i.UNKNOWN="unknown",i.INVALID_ARGUMENT="invalid_argument",i.DEADLINE_EXCEEDED="deadline_exceeded",i.NOT_FOUND="not_found",i.ALREADY_EXISTS="already_exists",i.PERMISSION_DENIED="permission_denied",i.UNAUTHENTICATED="unauthenticated",i.RESOURCE_EXHAUSTED="resource_exhausted",i.FAILED_PRECONDITION="failed_precondition",i.ABORTED="aborted",i.OUT_OF_RANGE="out_of_range",i.UNIMPLEMENTED="unimplemented",i.INTERNAL="internal",i.UNAVAILABLE="unavailable",i.DATA_LOSS="data_loss",i.CAPTCHA_REQUIRED="captcha_required",i.CAPTCHA_INVALID="captcha_invalid",i.INVALID_PASSWORD="invalid_password",i.INVALID_STATUS="invalid_status",i.USER_PENDING="user_pending",i.USER_BLOCKED="user_blocked",i.INVALID_VERIFICATION_CODE="invalid_verification_code",i.TWO_FACTOR_REQUIRED="two_factor_required",i.INVALID_TWO_FACTOR="invalid_two_factor",i.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",i.UNDER_REVIEW="under_review",i.INVALID_REQUEST="invalid_request",i.UNAUTHORIZED_CLIENT="unauthorized_client",i.ACCESS_DENIED="access_denied",i.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",i.INVALID_SCOPE="invalid_scope",i.INVALID_GRANT="invalid_grant",i.SERVER_ERROR="server_error",i.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",i.INTERACTION_REQUIRED="interaction_required",i.LOGIN_REQUIRED="login_required",i.ACCOUNT_SELECTION_REQUIRED="account_selection_required",i.CONSENT_REQUIRED="consent_required",i.INVALID_REQUEST_URI="invalid_request_uri",i.INVALID_REQUEST_OBJECT="invalid_request_object",i.REQUEST_NOT_SUPPORTED="request_not_supported",i.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",i.REGISTRATION_NOT_SUPPORTED="registration_not_supported";var u=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},c=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},f=function(){function t(){this.fnPromiseMap=new Map}return t.prototype.run=function(t,e){return u(this,void 0,void 0,(function(){var n,r=this;return c(this,(function(o){switch(o.label){case 0:return[4,n=this.fnPromiseMap.get(t)];case 1:return o.sent()||(n=new Promise((function(n,o){u(r,void 0,void 0,(function(){var r,i,s;return c(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return a.sent(),r=e(),i=n,[4,r];case 2:return i.apply(void 0,[a.sent()]),[3,5];case 3:return s=a.sent(),o(s),[3,5];case 4:return this.fnPromiseMap.delete(t),[7];case 5:return[2]}}))}))})),this.fnPromiseMap.set(t,n)),[2,n]}}))}))},t.prototype.runIdlePromise=function(){return Promise.resolve()},t}(),l=function(){return l=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},l.apply(this,arguments)},h=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},p=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},d="x-request-id",y="x-device-id",g="device_id",v=function(t,e){return h(this,void 0,void 0,(function(){var n,r,i,s,a;return p(this,(function(u){switch(u.label){case 0:n=null,r=null,u.label=1;case 1:return u.trys.push([1,4,,5]),(i=Object.assign({},e)).method||(i.method="GET"),i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body)),[4,fetch(t,i)];case 2:return[4,u.sent().json()];case 3:return(null==(s=u.sent())?void 0:s.error)?(r=s).error_uri=new URL(t).pathname:n=s,[3,5];case 4:return a=u.sent(),r={error:o.UNREACHABLE,error_description:a.message,error_uri:new URL(t).pathname},[3,5];case 5:if(r)throw r;return[2,n]}}))}))},m=new(function(){function t(){}return t.prototype.getItem=function(t){return h(this,void 0,void 0,(function(){return p(this,(function(e){return[2,window.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return h(this,void 0,void 0,(function(){return p(this,(function(e){return window.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return h(this,void 0,void 0,(function(){return p(this,(function(n){return window.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return window.localStorage.getItem(t)},t.prototype.removeItemSync=function(t){window.localStorage.removeItem(t)},t.prototype.setItemSync=function(t,e){window.localStorage.setItem(t,e)},t}());function w(t){var e=!0;return(null==t?void 0:t.expires_at)&&(null==t?void 0:t.access_token)&&(e=t.expires_at<new Date),e}var b,_,E,I=function(){function t(t){this.credentials=null,this.singlePromise=new f,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage}return t.prototype.getStorageCredentialsSync=function(){var t=null,e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t},t.prototype.setCredentials=function(t){return h(this,void 0,void 0,(function(){var e;return p(this,(function(n){switch(n.label){case 0:return(null==t?void 0:t.expires_in)?(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30)),this.storage?(e=JSON.stringify(t),[4,this.storage.setItem(this.tokenSectionName,e)]):[3,2]):[3,3];case 1:n.sent(),n.label=2;case 2:return this.credentials=t,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:n.sent(),n.label=5;case 5:this.credentials=null,n.label=6;case 6:return[2]}}))}))},t.prototype.getCredentials=function(){return h(this,void 0,void 0,(function(){var t=this;return p(this,(function(e){return[2,this.singlePromise.run("getCredentials",(function(){return h(t,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return w(this.credentials)?(t=this,[4,this.getStorageCredentials()]):[3,2];case 1:t.credentials=e.sent(),e.label=2;case 2:return[2,this.credentials]}}))}))}))]}))}))},t.prototype.getStorageCredentials=function(){return h(this,void 0,void 0,(function(){var t=this;return p(this,(function(e){return[2,this.singlePromise.run("_getStorageCredentials",(function(){return h(t,void 0,void 0,(function(){var t,e;return p(this,(function(n){switch(n.label){case 0:return t=null,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),t=null,[3,5];case 5:return[2,t]}}))}))}))]}))}))},t}(),S=function(){function t(e){this.singlePromise=new f,this.apiOrigin=e.apiOrigin,this.clientId=e.clientId,this.retry=this.formatRetry(e.retry,t.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=v,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||m,this.localCredentials=new I({tokenSectionName:"credentials_".concat(e.clientId),storage:this.storage}),this.clientSecret=e.clientSecret,this.refreshTokenFunc=e.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=e.anonymousSignInFunc}return t.prototype.setCredentials=function(t){return this.localCredentials.setCredentials(t)},t.prototype.getAccessToken=function(){return h(this,void 0,void 0,(function(){var t,e;return p(this,(function(n){switch(n.label){case 0:return[4,this.getCredentials()];case 1:return(null==(t=n.sent())?void 0:t.access_token)?[2,Promise.resolve(t.access_token)]:(e={error:o.UNAUTHENTICATED},[2,Promise.reject(e)])}}))}))},t.prototype.request=function(e,n){return h(this,void 0,void 0,(function(){var r,i,s,u,c,f,h;return p(this,(function(p){switch(p.label){case 0:return n||(n={}),r=this.formatRetry(n.retry,this.retry),n.headers=n.headers||{},this.headers&&(n.headers=l(l({},this.headers),n.headers)),n.headers[d]||(n.headers[d]=a()),n.headers[y]?[3,2]:[4,this.getDeviceId()];case 1:i=p.sent(),n.headers[y]=i,p.label=2;case 2:return(null==n?void 0:n.withCredentials)?[4,this.getCredentials()]:[3,4];case 3:return(s=p.sent())&&(this.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token=".concat(s.access_token)):n.headers.Authorization="".concat(s.token_type," ").concat(s.access_token)),[3,5];case 4:this.clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id=".concat(this.clientId)),p.label=5;case 5:e.startsWith("/")&&(e=this.apiOrigin+e),u=null,c=r+1,f=0,p.label=6;case 6:if(!(f<c))return[3,15];p.label=7;case 7:return p.trys.push([7,9,,12]),[4,this.baseRequest(e,n)];case 8:return u=p.sent(),[3,15];case 9:return h=p.sent(),n.withCredentials&&h&&h.error===o.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,11];case 10:return p.sent(),[2,Promise.reject(h)];case 11:return f!==r&&h&&"unreachable"===h.error?[3,12]:[2,Promise.reject(h)];case 12:return[4,this.sleep(t.retryInterval)];case 13:p.sent(),p.label=14;case 14:return f++,[3,6];case 15:return[2,u]}}))}))},t.prototype.getCredentials=function(){return h(this,void 0,void 0,(function(){var t,e,n;return p(this,(function(r){switch(r.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return w(t=r.sent())?t&&"anonymous"===t.scope?this.anonymousSignInFunc?[4,this.anonymousSignInFunc(t)]:[3,5]:[3,8]:[3,10];case 2:return e=r.sent(),(n=e)?[3,4]:[4,this.localCredentials.getCredentials()];case 3:n=r.sent(),r.label=4;case 4:return t=n,[3,7];case 5:return[4,this.anonymousSignIn(t)];case 6:t=r.sent(),r.label=7;case 7:return[3,10];case 8:return[4,this.refreshToken(t)];case 9:t=r.sent(),r.label=10;case 10:return[2,t]}}))}))},t.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},t.prototype.getCredentialsAsync=function(){return this.getCredentials()},t.prototype.getScope=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=e.sent())?[2,t.scope]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},t.prototype.getGroups=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=e.sent())?[2,t.groups]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},t.prototype.checkRetry=function(e){var n=null;if(("number"!=typeof e||e<t.minRetry||e>t.maxRetry)&&(n={error:o.UNREACHABLE,error_description:"wrong options param: retry"}),n)throw n;return e},t.prototype.formatRetry=function(t,e){return void 0===t?e:this.checkRetry(t)},t.prototype.sleep=function(t){return h(this,void 0,void 0,(function(){return p(this,(function(e){return[2,new Promise((function(e){setTimeout((function(){e()}),t)}))]}))}))},t.prototype.refreshToken=function(t){return h(this,void 0,void 0,(function(){var e=this;return p(this,(function(n){return[2,this.singlePromise.run("_refreshToken",(function(){return h(e,void 0,void 0,(function(){var e,n;return p(this,(function(r){switch(r.label){case 0:if(!t||!t.refresh_token)return[2,this.unAuthenticatedError("no refresh token found in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.refreshTokenFunc(t.refresh_token)];case 2:return e=r.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return r.sent(),[2,e];case 4:return(n=r.sent()).error!==o.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},t.prototype.anonymousSignIn=function(t){return h(this,void 0,void 0,(function(){var e=this;return p(this,(function(n){return[2,this.singlePromise.run("_anonymous",(function(){return h(e,void 0,void 0,(function(){var e,n;return p(this,(function(r){switch(r.label){case 0:if(!t||"anonymous"!==t.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.request("/auth/v1/signin/anonymously",{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret}})];case 2:return e=r.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return r.sent(),[2,e];case 4:return(n=r.sent()).error!==o.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},t.prototype.defaultRefreshTokenFunc=function(t){return void 0===t||""===t?this.unAuthenticatedError("refresh token not found"):this.request("/auth/v1/token",{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}})},t.prototype.getDeviceId=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(g)];case 1:return"string"==typeof(t=e.sent())&&t.length>=16&&t.length<=48?[3,3]:(t=a(),[4,this.storage.setItem(g,t)]);case 2:e.sent(),e.label=3;case 3:return this.deviceID=t,[2,t]}}))}))},t.prototype.unAuthenticatedError=function(t){var e={error:o.UNAUTHENTICATED,error_description:t};return Promise.reject(e)},t.defaultRetry=2,t.minRetry=0,t.maxRetry=5,t.retryInterval=1e3,t}();!function(t){t.AUTH_SIGN_IN_URL="/auth/v1/signin",t.AUTH_SIGN_IN_ANONYMOUSLY_URL="/auth/v1/signin/anonymously",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v1/signin/with/provider",t.AUTH_SIGN_UP_URL="/auth/v1/signup",t.AUTH_TOKEN_URL="/auth/v1/token",t.AUTH_REVOKE_URL="/auth/v1/revoke",t.PROVIDER_BIND_URL="/auth/v1/user/provider/bind",t.PROVIDER_TOKEN_URL="/auth/v1/provider/token",t.PROVIDER_URI_URL="/auth/v1/provider/uri",t.USER_ME_URL="/auth/v1/user/me",t.USER_QUERY_URL="/auth/v1/user/query",t.USER_PRIFILE_URL="/auth/v1/user/profile",t.USER_TRANS_BY_PROVIDER_URL="/auth/v1/user/trans/by/provider",t.VERIFICATION_URL="/auth/v1/verification",t.VERIFY_URL="/auth/v1/verification/verify",t.PROVIDER_LIST="/auth/v1/user/provider",t.PROVIDER_UNBIND_URL="/auth/v1/user/provider",t.CHECK_PWD_URL="/auth/v1/user/sudo",t.SUDO_URL="/auth/v1/user/sudo",t.BIND_CONTACT_URL="/auth/v1/user/contact",t.AUTH_SET_PASSWORD="/auth/v1/user/password",t.AUTH_RESET_PASSWORD="/auth/v1/reset",t.AUTH_GET_DEVICE_CODE="/auth/v1/device/code",t.CHECK_USERNAME="/auth/v1/checkUsername",t.CHECK_IF_USER_EXIST="/auth/v1/checkIfUserExist"}(b||(b={})),function(t){t.REGISTER="REGISTER",t.SIGN_IN="SIGN_IN",t.PASSWORD_RESET="PASSWORD_RESET",t.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",t.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(_||(_={})),function(t){t.INVALID_ARGUMENT="invalid_argument",t.DEADLINE_EXCEEDED="deadline_exceeded",t.NOT_FOUND="not_found",t.ALREADY_EXISTS="already_exists",t.PERMISSION_DENIED="permission_denied",t.ABORTED="aborted",t.OUT_OF_RANGE="out_of_range",t.UNIMPLEMENTED="unimplemented",t.INTERNAL="internal",t.UNAVAILABLE="unavailable",t.DATA_LOSS="data_loss",t.CAPTCHA_REQUIRED="captcha_required",t.CAPTCHA_INVALID="captcha_invalid",t.INVALID_PASSWORD="invalid_password",t.PASSWORD_NOT_SET="password_not_set",t.INVALID_STATUS="invalid_status",t.USER_PENDING="user_pending",t.USER_BLOCKED="user_blocked"}(E||(E={}));var O=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},A=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},T=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=m),this.config=t,this.tokenSectionName="captcha_".concat(t.clientId)}return t.prototype.request=function(t,e){return O(this,void 0,void 0,(function(){var n,r,o,i;return A(this,(function(s){switch(s.label){case 0:return e||(e={}),e.method||(e.method="GET"),n="".concat(e.method,":").concat(t),r=t,e.withCaptcha?[4,this.appendCaptchaTokenToURL(t,n,!1)]:[3,2];case 1:r=s.sent(),s.label=2;case 2:return s.trys.push([2,4,,7]),[4,this.config.request(r,e)];case 3:return o=s.sent(),[3,7];case 4:return"captcha_required"!==(i=s.sent()).error&&"captcha_invalid"!==i.error?[3,6]:[4,this.appendCaptchaTokenToURL(t,n,"captcha_invalid"===i.error)];case 5:return t=s.sent(),[2,this.config.request(t,e)];case 6:return[2,Promise.reject(i)];case 7:return[2,o]}}))}))},t.prototype.getDefaultOpenURIWithCallback=function(){if(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap")){var t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((function(){document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback},t.prototype.defaultOpenURIWithCallback=function(t){return O(this,void 0,void 0,(function(){var e,n;return A(this,(function(r){return e=document.getElementById("captcha_panel_wrap"),n=document.createElement("iframe"),e.innerHTML="",n.setAttribute("src",t),n.setAttribute("id","review-panel-iframe"),n.style.cssText="min-width:355px;display:block;height:355px;margin:0 auto;background-color: rgb(255, 255, 255);border: none;",e.appendChild(n),e.style.display="block",[2,new Promise((function(t,r){n.onload=function(){try{var o=window.location,i=n.contentWindow.location;if(i.host+i.pathname===o.host+o.pathname){e.style.display="none";var s=new URLSearchParams(i.search),a=s.get("captcha_token");return a?t({captcha_token:a,expires_in:Number(s.get("expires_in"))}):r({error:s.get("error"),error_description:s.get("error_description")})}e.style.display="block"}catch(t){e.style.display="block"}}}))]}))}))},t.prototype.getCaptchaToken=function(t,e){return O(this,void 0,void 0,(function(){var n,r,o,i,s;return A(this,(function(a){switch(a.label){case 0:return t?[3,2]:[4,this.findCaptchaToken()];case 1:if(n=a.sent())return[2,n];a.label=2;case 2:return r="".concat(window.location.origin+window.location.pathname,"?__captcha=on"),[4,this.config.request("/auth/v1/captcha/init",{method:"POST",body:{client_id:this.config.clientId,redirect_uri:r,state:e},withCredentials:!1})];case 3:return(o=a.sent()).captcha_token?(i={captcha_token:o.captcha_token,expires_in:o.expires_in},this.saveCaptchaToken(i),[2,o.captcha_token]):[4,this.config.openURIWithCallback(o.url)];case 4:return s=a.sent(),this.saveCaptchaToken(s),[2,s.captcha_token]}}))}))},t.prototype.appendCaptchaTokenToURL=function(t,e,n){return O(this,void 0,void 0,(function(){var r;return A(this,(function(o){switch(o.label){case 0:return[4,this.getCaptchaToken(n,e)];case 1:return r=o.sent(),t.indexOf("?")>0?t+="&captcha_token=".concat(r):t+="?captcha_token=".concat(r),[2,t]}}))}))},t.prototype.saveCaptchaToken=function(t){return O(this,void 0,void 0,(function(){var e;return A(this,(function(n){switch(n.label){case 0:return t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10)),e=JSON.stringify(t),[4,this.config.storage.setItem(this.tokenSectionName,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.findCaptchaToken=function(){return O(this,void 0,void 0,(function(){var t,e;return A(this,(function(n){switch(n.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(t=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?[2,null]:[2,e.captcha_token];case 3:return n.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),[2,null];case 5:return[2,null]}}))}))},t}(),N=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},R=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},C=function(){function t(t){var e=t.request,n=t.credentialsClient;if(!n){var r={apiOrigin:t.apiOrigin,clientId:t.clientId,storage:t.storage};n=new S(r)}if(!e){var o=n.request.bind(n),i=new T({clientId:t.clientId,request:o,storage:t.storage});e=i.request.bind(i)}this.config={apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:n,storage:t.storage||m}}return t.parseParamsToSearch=function(t){return Object.keys(t).forEach((function(e){t[e]||delete t[e]})),new URLSearchParams(t).toString()},t.prototype.signIn=function(t){return N(this,void 0,void 0,(function(){var e;return R(this,(function(n){switch(n.label){case 0:return[4,this.config.request(b.AUTH_SIGN_IN_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),N(this,void 0,void 0,(function(){var e;return R(this,(function(n){switch(n.label){case 0:return[4,this.config.request(b.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signUp=function(t){return N(this,void 0,void 0,(function(){var e;return R(this,(function(n){switch(n.label){case 0:return[4,this.config.request(b.AUTH_SIGN_UP_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signOut=function(){return N(this,void 0,void 0,(function(){var t,e;return R(this,(function(n){switch(n.label){case 0:return[4,this.config.credentialsClient.getAccessToken()];case 1:return t=n.sent(),[4,this.config.request(b.AUTH_REVOKE_URL,{method:"POST",body:{token:t}})];case 2:return e=n.sent(),[4,this.config.credentialsClient.setCredentials()];case 3:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.getVerification=function(t){return N(this,void 0,void 0,(function(){var e;return R(this,(function(n){switch(n.label){case 0:return e=!1,"CUR_USER"!==t.target?[3,1]:(e=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:n.sent()&&(e=!0),n.label=3;case 3:return[2,this.config.request(b.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:!0,withCredentials:e})]}}))}))},t.prototype.verify=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request(b.VERIFY_URL,{method:"POST",body:t})]}))}))},t.prototype.genProviderRedirectUri=function(t){return N(this,void 0,void 0,(function(){var e,n;return R(this,(function(r){return e="".concat(b.PROVIDER_URI_URL,"?client_id=").concat(this.config.clientId,"&provider_id=").concat(t.provider_id,"&redirect_uri=").concat(encodeURIComponent(t.provider_redirect_uri),"&state=").concat(t.state),(n=t.other_params)&&"string"==typeof n.sign_out_uri&&n.sign_out_uri.length>0&&(e+="&other_params[sign_out_uri]=".concat(n.sign_out_uri)),[2,this.config.request(e,{method:"GET"})]}))}))},t.prototype.grantProviderToken=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request(b.PROVIDER_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.patchProviderToken=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request(b.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]}))}))},t.prototype.signInWithProvider=function(t){return N(this,void 0,void 0,(function(){var e;return R(this,(function(n){switch(n.label){case 0:return[4,this.config.request(b.AUTH_SIGN_IN_WITH_PROVIDER_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.bindWithProvider=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request(b.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.getUserProfile=function(){return N(this,void 0,void 0,(function(){return R(this,(function(t){return[2,this.getUserInfo()]}))}))},t.prototype.getUserInfo=function(){return N(this,void 0,void 0,(function(){var t;return R(this,(function(e){switch(e.label){case 0:return[4,this.config.request(b.USER_ME_URL,{method:"GET",withCredentials:!0})];case 1:return(t=e.sent()).sub&&(t.uid=t.sub),[2,t]}}))}))},t.prototype.deleteMe=function(e){return N(this,void 0,void 0,(function(){var n;return R(this,(function(r){return n="".concat(b.USER_ME_URL,"?").concat(t.parseParamsToSearch(e)),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.hasLoginState=function(){return N(this,void 0,void 0,(function(){return R(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},t.prototype.getLoginState=function(){return N(this,void 0,void 0,(function(){return R(this,(function(t){return[2,this.config.credentialsClient.getCredentialsAsync()]}))}))},t.prototype.transByProvider=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request(b.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.grantToken=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request(b.AUTH_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.getProviders=function(){return N(this,void 0,void 0,(function(){return R(this,(function(t){return[2,this.config.request(b.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},t.prototype.unbindProvider=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request("".concat(b.PROVIDER_UNBIND_URL,"/").concat(t.provider_id),{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.checkPassword=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request("".concat(b.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.bindPhone=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request("".concat(b.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.bindEmail=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request("".concat(b.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.setPassword=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request("".concat(b.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.updatePasswordByOld=function(t){return N(this,void 0,void 0,(function(){var e;return R(this,(function(n){switch(n.label){case 0:return[4,this.sudo({password:t.old_password})];case 1:return e=n.sent(),[2,this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})]}}))}))},t.prototype.sudo=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request("".concat(b.SUDO_URL),{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.getCurUserVerification=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return t.target="CUR_USER",[2,this.config.request(b.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]}))}))},t.prototype.changeBindedProvider=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request("".concat(b.PROVIDER_LIST,"/").concat(t.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})]}))}))},t.prototype.setUserProfile=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request(b.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.queryUserProfile=function(t){return N(this,void 0,void 0,(function(){var e;return R(this,(function(n){return e=new URLSearchParams(t),[2,this.config.request("".concat(b.USER_QUERY_URL,"?").concat(e.toString()),{method:"GET",withCredentials:!0})]}))}))},t.prototype.setCustomSignFunc=function(t){this.getCustomSignTicketFn=t},t.prototype.signInWithCustomTicket=function(){return N(this,void 0,void 0,(function(){var t;return R(this,(function(e){switch(e.label){case 0:return[4,this.getCustomSignTicketFn()];case 1:return t=e.sent(),[2,this.signInWithProvider({provider_id:"custom",provider_token:t})]}}))}))},t.prototype.resetPassword=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request(b.AUTH_RESET_PASSWORD,{method:"POST",body:t})]}))}))},t.prototype.deviceAuthorize=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request(b.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.checkUsername=function(t){return N(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this.config.request(b.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]}))}))},t.prototype.checkIfUserExist=function(t){return N(this,void 0,void 0,(function(){var e;return R(this,(function(n){return e=new URLSearchParams(t),[2,this.config.request("".concat(b.CHECK_IF_USER_EXIST,"?").concat(e.toString()),{method:"GET"})]}))}))},t.prototype.loginScope=function(){return N(this,void 0,void 0,(function(){return R(this,(function(t){return[2,this.config.credentialsClient.getScope()]}))}))},t.prototype.loginGroups=function(){return N(this,void 0,void 0,(function(){return R(this,(function(t){return[2,this.config.credentialsClient.getGroups()]}))}))},t}(),x=function(){return x=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},x.apply(this,arguments)},L=function(t){var e=t.apiOrigin,n=t.clientId,r=t.storage,o=t.request,i=t.anonymousSignInFunc;this.oauth2client=new S({apiOrigin:e,clientId:n,storage:r,baseRequest:o,anonymousSignInFunc:i}),this.authApi=new C(x(x({credentialsClient:this.oauth2client},t),{request:o?this.oauth2client.request.bind(this.oauth2client):void 0}))},P=function(){return P=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},P.apply(this,arguments)},U=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},D=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},j=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},k=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},M=s.P6.xe,B=s.P6._y,q=s._G.Sg,F=s._G.vM,W=s.BM.D,$=s.U3.yE,H="loginStateChanged",V=new $,G=function(){function t(t){var e=t.cache,n=t.oauthInstance;this.cache=e,this.oauthInstance=n,this.setUserInfo()}return t.prototype.checkLocalInfo=function(){return j(this,void 0,void 0,(function(){return k(this,(function(t){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return j(this,void 0,void 0,(function(){var t,e,n,r;return k(this,(function(o){switch(o.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=o.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),n=this,[4,this.getLocalUserInfoAsync("email")];case 3:return n.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),r=this,[4,this.getLocalUserInfoAsync("username")];case 4:return r.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}}))}))},t.prototype.update=function(t){return j(this,void 0,void 0,(function(){var e;return k(this,(function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(P({},t))];case 1:return e=n.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&B(q.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(){return j(this,void 0,void 0,(function(){var t;return k(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo()];case 1:return t=e.sent(),this.setLocalUserInfo(t),[2,t]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;return this.cache.getStore(e)[t]},t.prototype.getLocalUserInfoAsync=function(t){return j(this,void 0,void 0,(function(){var e;return k(this,(function(n){switch(n.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,n.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,n=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username"].forEach((function(e){t[e]=n[e]}))},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},U([W({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[Object]),D("design:returntype",Promise)],t.prototype,"update",null),U([W({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[String,String]),D("design:returntype",void 0)],t.prototype,"updatePassword",null),U([W({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[String]),D("design:returntype",void 0)],t.prototype,"updateUsername",null),U([W({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Promise)],t.prototype,"refresh",null),t}(),J=function(){function t(t){var e=t.envId,n=t.cache,r=t.oauthInstance;e||B(q.INVALID_PARAMS,"envId is not defined"),this.cache=n,this.oauthInstance=r,this.user=new G({cache:this.cache,oauthInstance:r})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return j(this,void 0,void 0,(function(){return k(this,(function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}}))}))},t}(),K=function(){function t(t){this.config=t,this.cache=t.cache,this.oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.bindPhone(t)]}))}))},t.prototype.unbindProvider=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},t.prototype.bindEmail=function(t){return this.oauthInstance.authApi.bindEmail(t)},t.prototype.verify=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.getVerification(t)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}M(q.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return j(this,void 0,void 0,(function(){var t;return k(this,(function(e){switch(e.label){case 0:return[4,this.getLoginState()];case 1:return(t=e.sent())?[4,t.user.checkLocalInfoAsync()]:[3,3];case 2:return e.sent(),[2,t.user||null];case 3:return[2,null]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),j(this,void 0,void 0,(function(){return k(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(){return j(this,void 0,void 0,(function(){return k(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signIn=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signUp=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signUp(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setPassword=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&B(q.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,e.sent().exist]}}))}))},t.prototype.signOut=function(){return j(this,void 0,void 0,(function(){var t;return k(this,(function(e){switch(e.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut()];case 1:return e.sent(),[4,this.cache.removeStoreAsync(t)];case 2:return e.sent(),V.fire(H),[2]}}))}))},t.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new J({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;M(q.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return j(this,void 0,void 0,(function(){return k(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.getLoginState()];case 1:return t.sent()?[2,new J({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(){return j(this,void 0,void 0,(function(){return k(this,(function(t){return[2,this.oauthInstance.authApi.getUserInfo()]}))}))},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return j(this,void 0,void 0,(function(){return k(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}}))}))},t.prototype.grantProviderToken=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.patchProviderToken=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.grantToken=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return j(this,void 0,void 0,(function(){return k(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return j(this,void 0,void 0,(function(){return k(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return j(this,void 0,void 0,(function(){return k(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return j(this,void 0,void 0,(function(){return k(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return j(this,void 0,void 0,(function(){var e,n=this;return k(this,(function(r){switch(r.label){case 0:return V.on(H,(function(){return j(n,void 0,void 0,(function(){var e;return k(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=r.sent(),t.call(this,e),[2]}}))}))},t.prototype.createLoginState=function(){return j(this,void 0,void 0,(function(){var t;return k(this,(function(e){switch(e.label){case 0:return[4,(t=new J({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return e.sent(),[4,t.user.refresh()];case 2:return e.sent(),V.fire(H),[2,t]}}))}))},U([W({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[Object]),D("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),U([W({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[Object]),D("design:returntype",Promise)],t.prototype,"unbindProvider",null),U([W({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[Object]),D("design:returntype",void 0)],t.prototype,"bindEmail",null),U([W({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[Object]),D("design:returntype",Promise)],t.prototype,"verify",null),U([W({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[Object]),D("design:returntype",Promise)],t.prototype,"getVerification",null),U([W({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Promise)],t.prototype,"getCurrentUser",null),U([W({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[Object]),D("design:returntype",Promise)],t.prototype,"signInAnonymously",null),U([W({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),U([W({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[Object]),D("design:returntype",Promise)],t.prototype,"signUp",null),U([W({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[String]),D("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),U([W({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Promise)],t.prototype,"signOut",null),U([W({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Promise)],t.prototype,"getLoginState",null),U([W({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Promise)],t.prototype,"getUserInfo",null),U([W({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(F)]}),D("design:type",Function),D("design:paramtypes",[Object]),D("design:returntype",Promise)],t.prototype,"bindWithProvider",null),t}(),Y={name:"auth",namespace:"auth",entity:function(t){if(void 0===t&&(t={region:"",persistence:"local"}),this.authInstance)return M(q.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var e=this.platform,n=e.adapter,r=e.runtime,o=t.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=this.config,s=i.env,a=i.persistence,u=i.debug,c=i.clientId,f=i.storage,l=new L({clientId:c,apiOrigin:this.request.getBaseEndPoint(),storage:(null==t?void 0:t.storage)||f,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc});return this.oauthInstance=l,this.authInstance=new K({env:s,region:t.region,persistence:a,debug:u,cache:this.cache,runtime:r,_fromApp:this,oauthInstance:l}),this.authInstance}};try{cloudbase.registerComponent(Y)}catch(t){}function z(t){try{t.registerComponent(Y)}catch(t){console.warn(t)}}},529:function(t,e,n){"use strict";n.r(e),n.d(e,{registerDatabase:function(){return Mn}});var r,o,i={};n.r(i),n.d(i,{LineString:function(){return H},MultiLineString:function(){return Y},MultiPoint:function(){return J},MultiPolygon:function(){return Q},Point:function(){return ot},Polygon:function(){return G}}),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a,u="Object",c="GeoPoint",f="GeoLineString",l="GeoPolygon",h="GeoMultiPoint",p="GeoMultiLineString",d="GeoMultiPolygon",y="Date",g="ServerDate",v=["desc","asc"],m=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(s||(s={})),(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte",function(t){t.WHERE="WHERE",t.DOC="DOC"}(a||(a={}));var w,b=(w=function(t,e){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},w(t,e)},function(t,e){function n(){this.constructor=t}w(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),_=[],E={},I=function(t){function e(e,n){if(n!==E)throw new TypeError("InternalSymbol cannot be constructed with new operator");return t.call(this,e)||this}return b(e,t),e.for=function(t){for(var n=0,r=_.length;n<r;n++)if(_[n].target===t)return _[n].instance;var o=new e(t,E);return _.push({target:t,instance:o}),o},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})})),S=I,O=S.for("UNSET_FIELD_NAME"),A=S.for("UPDATE_COMMAND"),T=S.for("QUERY_COMMAND"),N=S.for("LOGIC_COMMAND"),R=S.for("GEO_POINT"),C=S.for("SYMBOL_GEO_LINE_STRING"),x=S.for("SYMBOL_GEO_POLYGON"),L=S.for("SYMBOL_GEO_MULTI_POINT"),P=S.for("SYMBOL_GEO_MULTI_LINE_STRING"),U=S.for("SYMBOL_GEO_MULTI_POLYGON"),D=S.for("SERVER_DATE"),j=S.for("REGEXP"),k=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},M=function(t){return"object"===k(t)},B=function(t){return"number"===k(t)},q=function(t){return Array.isArray(t)},F=function(t){return"date"===k(t)},W=function(t){return"regexp"===k(t)},$=function(t){return t&&t._internalType instanceof I},H=function(){function t(t){if(!q(t))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t);if(t.length<2)throw new Error('"points" must contain 2 points at least');t.forEach((function(t){if(!(t instanceof ot))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t+"[]")})),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"LineString",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))},e},t.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))}},t.validate=function(t){var e,n;if("LineString"!==t.type||!q(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!B(i[0])||!B(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},t.isClosed=function(t){var e=t.points[0],n=t.points[t.points.length-1];if(e.latitude===n.latitude&&e.longitude===n.longitude)return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return C},enumerable:!0,configurable:!0}),t}(),V=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},G=function(){function t(t){if(!q(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof H))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]");if(!H.isClosed(t))throw new Error("LineString "+t.points.map((function(t){return t.toReadableString()}))+" is not a closed cycle")})),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Polygon",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))},e},t.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}},t.validate=function(t){var e,n,r,o;if("Polygon"!==t.type||!q(t.coordinates))return!1;try{for(var i=V(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var u=(r=void 0,V(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!B(f[0])||!B(f[1]))return!1}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},t.isCloseLineString=function(t){var e=t[0],n=t[t.length-1];return e[0]===n[0]&&e[1]===n[1]},Object.defineProperty(t.prototype,"_internalType",{get:function(){return U},enumerable:!0,configurable:!0}),t}(),J=function(){function t(t){if(!q(t))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t);if(0===t.length)throw new Error('"points" must contain 1 point at least');t.forEach((function(t){if(!(t instanceof ot))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t+"[]")})),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPoint",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))},e},t.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))}},t.validate=function(t){var e,n;if("MultiPoint"!==t.type||!q(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!B(i[0])||!B(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return L},enumerable:!0,configurable:!0}),t}(),K=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Y=function(){function t(t){if(!q(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof H))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]")})),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiLineString",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))},e},t.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}},t.validate=function(t){var e,n,r,o;if("MultiLineString"!==t.type||!q(t.coordinates))return!1;try{for(var i=K(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var u=(r=void 0,K(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!B(f[0])||!B(f[1]))return!1}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return P},enumerable:!0,configurable:!0}),t}(),z=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Q=function(){function t(t){var e,n;if(!q(t))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof t);if(0===t.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=z(t),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof G))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof i+"[]")}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.polygons=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPolygon",coordinates:this.polygons.map((function(t){return t.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}))},e},t.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(t){return t.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}))}},t.validate=function(t){var e,n,r,o,i,s;if("MultiPolygon"!==t.type||!q(t.coordinates))return!1;try{for(var a=z(t.coordinates),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var f=(r=void 0,z(c)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,z(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!B(y[0])||!B(y[1]))return!1}}catch(t){i={error:t}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return x},enumerable:!0,configurable:!0}),t}(),X=function(){function t(t){var e=(void 0===t?{}:t).offset,n=void 0===e?0:e;this.offset=n}return Object.defineProperty(t.prototype,"_internalType",{get:function(){return D},enumerable:!0,configurable:!0}),t.prototype.parse=function(){return{$date:{offset:this.offset}}},t}();function Z(t){return new X(t)}var tt,et=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},nt=function(){function t(){}return t.formatResDocumentData=function(e){return e.map((function(e){return t.formatField(e)}))},t.formatField=function(e){var n=Object.keys(e),r={};return Array.isArray(e)&&(r=[]),n.forEach((function(n){var o,i=e[n];switch(t.whichType(i)){case c:o=new ot(i.coordinates[0],i.coordinates[1]);break;case f:o=new H(i.coordinates.map((function(t){return new ot(t[0],t[1])})));break;case l:o=new G(i.coordinates.map((function(t){return new H(t.map((function(t){var e=et(t,2),n=e[0],r=e[1];return new ot(n,r)})))})));break;case h:o=new J(i.coordinates.map((function(t){return new ot(t[0],t[1])})));break;case p:o=new Y(i.coordinates.map((function(t){return new H(t.map((function(t){var e=et(t,2),n=e[0],r=e[1];return new ot(n,r)})))})));break;case d:o=new Q(i.coordinates.map((function(t){return new G(t.map((function(t){return new H(t.map((function(t){var e=et(t,2),n=e[0],r=e[1];return new ot(n,r)})))})))})));break;case y:o=new Date(1e3*i.$timestamp);break;case u:case"Array":o=t.formatField(i);break;case g:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o})),r},t.whichType=function(t){var e=Object.prototype.toString.call(t).slice(8,-1);if(e===y)return"BsonDate";if(e===u){if(t instanceof ot)return c;if(t instanceof Date)return y;if(t instanceof X)return g;t.$timestamp?e=y:t.$date?e=g:ot.validate(t)?e=c:H.validate(t)?e=f:G.validate(t)?e=l:J.validate(t)?e=h:Y.validate(t)?e=p:Q.validate(t)&&(e=d)}return e},t.generateDocId=function(){for(var t="ABCDEFabcdef0123456789",e="",n=0;n<24;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},t}(),rt=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==nt.whichType(e))throw new Error("Geo Point must be number type");var n=Math.abs(e);if("latitude"===t&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===t&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},t.isInteger=function(t,e){if(!Number.isInteger(e))throw new Error(t+o.IntergerError);return!0},t.isFieldOrder=function(t){if(-1===v.indexOf(t))throw new Error(o.DirectionError);return!0},t.isFieldPath=function(t){if(!/^[a-zA-Z0-9-_\.]/.test(t))throw new Error;return!0},t.isOperator=function(t){if(-1===m.indexOf(t))throw new Error(o.OpStrError);return!0},t.isCollName=function(t){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(t))throw new Error(o.CollNameError);return!0},t.isDocID=function(t){if(!/^([a-fA-F0-9]){24}$/.test(t))throw new Error(o.DocIDError);return!0},t}(),ot=function(){function t(t,e){rt.isGeopoint("longitude",t),rt.isGeopoint("latitude",e),this.longitude=t,this.latitude=e}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Point",coordinates:[this.longitude,this.latitude]},e},t.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},t.prototype.toReadableString=function(){return"["+this.longitude+","+this.latitude+"]"},t.validate=function(t){return"Point"===t.type&&q(t.coordinates)&&rt.isGeopoint("longitude",t.coordinates[0])&&rt.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return R},enumerable:!0,configurable:!0}),t}(),it=function(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t};!function(t){t.SET="set",t.REMOVE="remove",t.INC="inc",t.MUL="mul",t.PUSH="push",t.PULL="pull",t.PULL_ALL="pullAll",t.POP="pop",t.SHIFT="shift",t.UNSHIFT="unshift",t.ADD_TO_SET="addToSet",t.BIT="bit",t.RENAME="rename",t.MAX="max",t.MIN="min"}(tt||(tt={}));var st,at=function(){function t(t,e,n){this._internalType=A,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||O}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function ut(t){return t&&t instanceof at&&t._internalType===A}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(st||(st={}));var ct=function(){function t(t,e,n){if(this._internalType=N,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||O,this.fieldName!==O)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++)(ft(i=e[r])||dt(i))&&(e[r]=i._setFieldName(this.fieldName))}else{var i;(ft(i=e)||dt(i))&&(e=i._setFieldName(this.fieldName))}}return t.prototype._setFieldName=function(e){var n=this.operands.map((function(n){return n instanceof t?n._setFieldName(e):n}));return new t(this.operator,n,e)},t.prototype.and=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(st.AND,r,this.fieldName)},t.prototype.or=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(st.OR,r,this.fieldName)},t}();function ft(t){return t&&t instanceof ct&&t._internalType===N}var lt,ht=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t.EQ="eq",t.NEQ="neq",t.GT="gt",t.GTE="gte",t.LT="lt",t.LTE="lte",t.IN="in",t.NIN="nin",t.ALL="all",t.ELEM_MATCH="elemMatch",t.EXISTS="exists",t.SIZE="size",t.MOD="mod",t.GEO_NEAR="geoNear",t.GEO_WITHIN="geoWithin",t.GEO_INTERSECTS="geoIntersects"}(lt||(lt={}));var pt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.operator=e,o._internalType=T,o}return ht(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case lt.IN:case lt.NIN:return(t={})["$"+this.operator]=this.operands,t;default:return(e={})["$"+this.operator]=this.operands[0],e}},e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e.prototype.eq=function(t){var n=new e(lt.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(lt.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(lt.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(lt.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(lt.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(lt.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(lt.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(lt.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof ot))throw new TypeError('"geometry" must be of type Point. Received type '+typeof t.geometry);if(void 0!==t.maxDistance&&!B(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof t.maxDistance);if(void 0!==t.minDistance&&!B(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof t.minDistance);var n=new e(lt.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof Q||t.geometry instanceof G))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof t.geometry);var n=new e(lt.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof ot||t.geometry instanceof H||t.geometry instanceof G||t.geometry instanceof J||t.geometry instanceof Y||t.geometry instanceof Q))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof t.geometry);var n=new e(lt.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(ct);function dt(t){return t&&t instanceof pt&&t._internalType===T}function yt(t){return dt(t)}var gt={};for(var vt in lt)gt[vt]="$"+vt;for(var vt in st)gt[vt]="$"+vt;for(var vt in tt)gt[vt]="$"+vt;function mt(t){return gt[t]||"$"+t}gt[lt.NEQ]="$ne",gt[tt.REMOVE]="$unset",gt[tt.SHIFT]="$pop",gt[tt.UNSHIFT]="$push";var wt=function(){return wt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},wt.apply(this,arguments)},bt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},_t=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(bt(arguments[e]));return t};function Et(t){return It(t,[t])}function It(t,e){if(!$(t)){if(F(t))return{$date:+t};if(W(t))return{$regex:t.source,$options:t.flags};if(q(t))return t.map((function(t){if(e.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return It(t,_t(e,[t]))}));if(M(t)){var n=wt({},t);for(var r in n){if(e.indexOf(n[r])>-1)throw new Error("Cannot convert circular structure to JSON");n[r]=It(n[r],_t(e,[n[r]]))}return n}return t}switch(t._internalType){case R:return t.toJSON();case D:case j:return t.parse();default:return t.toJSON?t.toJSON():t}}var St=function(){return St=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},St.apply(this,arguments)},Ot=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},At=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ot(arguments[e]));return t};function Tt(t,e,n,r){var o=St({},t);for(var i in t)if(!/^\$/.test(i)){var s=t[i];if(s&&M(s)&&!e(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Tt(s,e,At(n,[i]),At(r,[s]));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o[i+"."+c]=a[c],delete o[i][c]);u||delete o[i]}}return o}function Nt(t){return Tt(t,Ct,[],[t])}function Rt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?q(t[r])?t[r].push(e[r]):M(t[r])?M(e[r])?Object.assign(t[r],e[r]):(console.warn("unmergable condition, query is object but condition is "+k(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+k(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]}function Ct(t){return $(t)||F(t)||W(t)}function xt(t){return Et(t)}var Lt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return ut(t)?this.encodeUpdateCommand(t):"object"===k(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case tt.PUSH:case tt.PULL:case tt.PULL_ALL:case tt.POP:case tt.SHIFT:case tt.UNSHIFT:case tt.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=mt(t.operator);return t.operator===tt.REMOVE?((e={})[i]=((n={})[t.fieldName]="",n),e):((r={})[i]=((o={})[t.fieldName]=t.operands[0],o),r)},t.prototype.encodeArrayUpdateCommand=function(t){var e,n,r,o,i,s,a,u,c,f,l=mt(t.operator);switch(t.operator){case tt.PUSH:var h=void 0;return h=q(t.operands)?{$each:t.operands.map(xt)}:t.operands,(e={})[l]=((n={})[t.fieldName]=h,n),e;case tt.UNSHIFT:return h={$each:t.operands.map(xt),$position:0},(r={})[l]=((o={})[t.fieldName]=h,o),r;case tt.POP:return(i={})[l]=((s={})[t.fieldName]=1,s),i;case tt.SHIFT:return(a={})[l]=((u={})[t.fieldName]=-1,u),a;default:return(c={})[l]=((f={})[t.fieldName]=xt(t.operands),f),c}},t.prototype.encodeUpdateObject=function(t){var e=Nt(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(ut(r))e[n]=r._setFieldName(n),Rt(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=xt(r);var o=new at(tt.SET,[r],n);Rt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),Pt={};function Ut(t){if(!Dn.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return Pt[e]||(Pt[e]=new Dn.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new Dn.reqClass(t.config)}}})),Pt[e]}for(var Dt=function(){return Dt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Dt.apply(this,arguments)},jt=function(){function t(t,e,n,r){var o=this;void 0===r&&(r={}),this.watch=function(t){return Ut(o._db).watch(Dt(Dt({},t),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=t,this._coll=e,this.id=n,this.request=new Dn.reqClass(this._db.config),this.projection=r}return t.prototype.create=function(t,e){e=e||it();var n={collectionName:this._coll,data:Et(t)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(t){t.code?e(0,t):e(0,{id:t.data._id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.set=function(t,e){if(e=e||it(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(t){if("object"==typeof t)for(var e in t)t[e]instanceof at?n=!0:"object"==typeof t[e]&&r(t[e])};if(r(t),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:a.DOC,data:Et(t),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.update=function(t,e){if(e=e||it(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:Lt.encode(t),query:n,queryType:a.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.remove=function(t){t=t||it();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(e){e.code?t(0,e):t(0,{deleted:e.data.deleted,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},t.prototype.get=function(t){t=t||it();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n=nt.formatResDocumentData(e.data.list);t(0,{data:n,requestId:e.requestId,total:e.TotalCount,limit:e.Limit,offset:e.Offset})}})).catch((function(e){t(e)})),t.promise},t.prototype.field=function(e){for(var n in e)e[n]?e[n]=1:e[n]=0;return new t(this._db,this._coll,this.id,e)},t}(),kt=function(){function t(){}return t.encode=function(t){return(new Mt).encodeQuery(t)},t}(),Mt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return Ct(t)?ft(t)?this.encodeLogicCommand(t):dt(t)?this.encodeQueryCommand(t):((n={})[e]=this.encodeQueryObject(t),n):M(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regex:t.source,$options:t.flags}},t.prototype.encodeLogicCommand=function(t){var e,n,r,o,i,s,a,u=this;switch(t.operator){case st.NOR:case st.AND:case st.OR:var c=mt(t.operator),f=t.operands.map((function(e){return u.encodeQuery(e,t.fieldName)}));return(e={})[c]=f,e;case st.NOT:c=mt(t.operator);var l=t.operands[0];return W(l)?((n={})[t.fieldName]=((r={})[c]=this.encodeRegExp(l),r),n):(f=this.encodeQuery(l)[t.fieldName],(o={})[t.fieldName]=((i={})[c]=f,i),o);default:if(c=mt(t.operator),1===t.operands.length){var h=this.encodeQuery(t.operands[0]);return(s={})[c]=h,s}return f=t.operands.map(this.encodeQuery.bind(this)),(a={})[c]=f,a}},t.prototype.encodeQueryCommand=function(t){return yt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,s,a,u,c;if(t.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");var f=mt(t.operator);switch(t.operator){case lt.EQ:case lt.NEQ:case lt.LT:case lt.LTE:case lt.GT:case lt.GTE:case lt.ELEM_MATCH:case lt.EXISTS:case lt.SIZE:case lt.MOD:return(e={})[t.fieldName]=((n={})[f]=xt(t.operands[0]),n),e;case lt.IN:case lt.NIN:case lt.ALL:return(r={})[t.fieldName]=((o={})[f]=xt(t.operands),o),r;case lt.GEO_NEAR:var l=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case lt.GEO_WITHIN:return l=t.operands[0],(s={})[t.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case lt.GEO_INTERSECTS:return l=t.operands[0],(a={})[t.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(u={})[t.fieldName]=((c={})[f]=xt(t.operands[0]),c),u}},t.prototype.encodeQueryObject=function(t){var e=Nt(t);for(var n in e){var r=e[n];if(ft(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else yt(r)?(e[n]=r._setFieldName(n),o=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,o,n)):Ct(r)&&(e[n]=xt(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?q(t[r])?t[r]=t[r].concat(e[r]):M(t[r])?M(e[r])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is "+k(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+k(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),Bt=function(){return Bt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Bt.apply(this,arguments)},qt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return Ut(i._db).watch(Bt(Bt({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(t,e){return t[e.field]=e.direction,t}),{}):void 0}))},this._db=t,this._coll=e,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=new Dn.reqClass(this._db.config)}return t.prototype.get=function(t){t=t||it();var e=[];this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)}));var n={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),e.length>0&&(n.order=e),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n={data:nt.formatResDocumentData(e.data.list),requestId:e.requestId};e.TotalCount&&(n.total=e.TotalCount),e.Limit&&(n.limit=e.Limit),e.Offset&&(n.offset=e.Offset),t(0,n)}})).catch((function(e){t(e)})),t.promise},t.prototype.count=function(t){t=t||it();var e={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(e.query=this._fieldFilters),this._request.send("database.countDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,total:e.data.total})})).catch((function(e){t(e)})),t.promise},t.prototype.where=function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(e),r=n.some((function(t){return void 0!==e[t]}));if(n.length&&!r)throw Error(o.QueryParamValueError);return new t(this._db,this._coll,kt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){rt.isFieldPath(e),rt.isFieldOrder(n);var r={field:e,direction:n},o=this._fieldOrders.concat(r);return new t(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){rt.isInteger("limit",e);var n=Bt({},this._queryOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){rt.isInteger("offset",e);var n=Bt({},this._queryOptions);return n.offset=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.update=function(t,e){if(e=e||it(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:a.WHERE,multi:!0,merge:!0,upsert:!1,data:Lt.encode(t)};return this._request.send("database.updateDocument",n).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,updated:t.data.updated,upsertId:t.data.upsert_id})})).catch((function(t){e(t)})),e.promise},t.prototype.field=function(e){for(var n in e)e[n]?"object"!=typeof e[n]&&(e[n]=1):e[n]=0;var r=Bt({},this._queryOptions);return r.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.remove=function(t){t=t||it(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var e={collectionName:this._coll,query:kt.encode(this._fieldFilters),queryType:a.WHERE,multi:!0};return this._request.send("database.deleteDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,deleted:e.data.deleted})})).catch((function(e){t(e)})),t.promise},t}(),Ft=[],Wt=[],$t="undefined"!=typeof Uint8Array?Uint8Array:Array,Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Vt=0,Gt=Ht.length;Vt<Gt;++Vt)Ft[Vt]=Ht[Vt],Wt[Ht.charCodeAt(Vt)]=Vt;function Jt(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function Kt(t,e,n){for(var r,o,i=[],s=e;s<n;s+=3)r=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),i.push(Ft[(o=r)>>18&63]+Ft[o>>12&63]+Ft[o>>6&63]+Ft[63&o]);return i.join("")}Wt["-".charCodeAt(0)]=62,Wt["_".charCodeAt(0)]=63;var Yt=function(t){var e,n,r=Jt(t),o=r[0],i=r[1],s=new $t(function(t,e,n){return 3*(e+n)/4-n}(0,o,i)),a=0,u=i>0?o-4:o;for(n=0;n<u;n+=4)e=Wt[t.charCodeAt(n)]<<18|Wt[t.charCodeAt(n+1)]<<12|Wt[t.charCodeAt(n+2)]<<6|Wt[t.charCodeAt(n+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===i&&(e=Wt[t.charCodeAt(n)]<<2|Wt[t.charCodeAt(n+1)]>>4,s[a++]=255&e),1===i&&(e=Wt[t.charCodeAt(n)]<<10|Wt[t.charCodeAt(n+1)]<<4|Wt[t.charCodeAt(n+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e),s},zt=function(t){for(var e,n=t.length,r=n%3,o=[],i=16383,s=0,a=n-r;s<a;s+=i)o.push(Kt(t,s,s+i>a?a:s+i));return 1===r?(e=t[n-1],o.push(Ft[e>>2]+Ft[e<<4&63]+"==")):2===r&&(e=(t[n-2]<<8)+t[n-1],o.push(Ft[e>>10]+Ft[e>>4&63]+Ft[e<<2&63]+"=")),o.join("")},Qt=function(t,e,n,r,o){var i,s,a=8*o-r-1,u=(1<<a)-1,c=u>>1,f=-7,l=n?o-1:0,h=n?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+t[e+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=r;f>0;s=256*s+t[e+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),i-=c}return(p?-1:1)*s*Math.pow(2,i-r)},Xt=function(t,e,n,r,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,d=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(e*u-1)*Math.pow(2,o),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[n+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;t[n+p]=255&s,p+=d,s/=256,c-=8);t[n+p-d]|=128*y},Zt=function(t,e){return function(t,e){var n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=i,e.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},e.INSPECT_MAX_BYTES=50;var r=2147483647;function o(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,i.prototype),e}function i(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,n)}function s(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!i.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var n=0|h(t,e),r=o(n),s=r.write(t,e);return s!==n&&(r=r.slice(0,s)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(M(t,Uint8Array)){var e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t));if(M(t,ArrayBuffer)||t&&M(t.buffer,ArrayBuffer))return f(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(M(t,SharedArrayBuffer)||t&&M(t.buffer,SharedArrayBuffer)))return f(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return i.from(r,e,n);var s=function(t){if(i.isBuffer(t)){var e=0|l(t.length),n=o(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||B(t.length)?o(0):c(t):"Buffer"===t.type&&Array.isArray(t.data)?c(t.data):void 0}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return i.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t))}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(t){return a(t),o(t<0?0:0|l(t))}function c(t){for(var e=t.length<0?0:0|l(t.length),n=o(e),r=0;r<e;r+=1)n[r]=255&t[r];return n}function f(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,i.prototype),r}function l(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function h(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||M(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+babelHelpers.typeof(t));var n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return j(t).length;default:if(o)return r?-1:D(t).length;e=(""+e).toLowerCase(),o=!0}}function p(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,n);case"utf8":case"utf-8":return I(this,e,n);case"ascii":return O(this,e,n);case"latin1":case"binary":return A(this,e,n);case"base64":return E(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function d(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function y(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),B(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=i.from(e,r)),i.isBuffer(e))return 0===e.length?-1:g(t,e,n,r,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):g(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,n,r,o){var i,s=1,a=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var f=-1;for(i=n;i<a;i++)if(c(t,i)===c(e,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===u)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(n+u>a&&(n=a-u),i=n;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(c(t,i+h)!==c(e,h)){l=!1;break}if(l)return i}return-1}function v(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=e.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(e.substr(2*s,2),16);if(B(a))return s;t[n+s]=a}return s}function m(t,e,n,r){return k(D(e,t.length-n),t,n,r)}function w(t,e,n,r){return k(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function b(t,e,n,r){return k(j(e),t,n,r)}function _(t,e,n,r){return k(function(t,e){for(var n,r,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)r=(n=t.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function E(t,e,n){return 0===e&&n===t.length?zt(t):zt(t.slice(e,n))}function I(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o<n;){var i,s,a,u,c=t[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),o+=l}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);for(var n="",r=0;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=S));return n}(r)}e.kMaxLength=r,i.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(t,e,n){return s(t,e,n)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,e,n){return function(t,e,n){return a(t),t<=0?o(t):void 0!==e?"string"==typeof n?o(t).fill(e,n):o(t).fill(e):o(t)}(t,e,n)},i.allocUnsafe=function(t){return u(t)},i.allocUnsafeSlow=function(t){return u(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(M(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),M(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,r=e.length,o=0,s=Math.min(n,r);o<s;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=i.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var s=t[n];if(M(s,Uint8Array))o+s.length>r.length?i.from(s).copy(r,o):Uint8Array.prototype.set.call(r,s,o);else{if(!i.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o)}o+=s.length}return r},i.byteLength=h,i.prototype._isBuffer=!0,i.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)d(this,e,e+1);return this},i.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)d(this,e,e+3),d(this,e+1,e+2);return this},i.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},i.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?I(this,0,t):p.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(i.prototype[n]=i.prototype.inspect),i.prototype.compare=function(t,e,n,r,o){if(M(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+babelHelpers.typeof(t));if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var s=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0),u=Math.min(s,a),c=this.slice(r,o),f=t.slice(e,n),l=0;l<u;++l)if(c[l]!==f[l]){s=c[l],a=f[l];break}return s<a?-1:a<s?1:0},i.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},i.prototype.indexOf=function(t,e,n){return y(this,t,e,n,!0)},i.prototype.lastIndexOf=function(t,e,n){return y(this,t,e,n,!1)},i.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return m(this,t,e,n);case"ascii":case"latin1":case"binary":return w(this,t,e,n);case"base64":return b(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function O(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function A(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function T(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=e;i<n;++i)o+=q[t[i]];return o}function N(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length-1;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function R(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,n,r,o,s){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function x(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(t,e,n,r,o){return e=+e,n>>>=0,o||x(t,0,n,4),Xt(t,e,n,r,23,4),n+4}function P(t,e,n,r,o){return e=+e,n>>>=0,o||x(t,0,n,8),Xt(t,e,n,r,52,8),n+8}i.prototype.slice=function(t,e){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r=this.subarray(t,e);return Object.setPrototypeOf(r,i.prototype),r},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},i.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),Qt(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),Qt(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),Qt(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),Qt(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||C(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||C(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);C(this,t,e,n,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<n&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+n},i.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);C(this,t,e,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+n},i.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,n){return L(this,t,e,!0,n)},i.prototype.writeFloatBE=function(t,e,n){return L(this,t,e,!1,n)},i.prototype.writeDoubleLE=function(t,e,n){return P(this,t,e,!0,n)},i.prototype.writeDoubleBE=function(t,e,n){return P(this,t,e,!1,n)},i.prototype.copy=function(t,e,n,r){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),o},i.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!i.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){var o=t.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var s;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=e;s<n;++s)this[s]=t;else{var a=i.isBuffer(t)?t:i.from(t,r),u=a.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-e;++s)this[s+e]=a[s%u]}return this};var U=/[^+/0-9A-Za-z-_]/g;function D(t,e){var n;e=e||1/0;for(var r=t.length,o=null,i=[],s=0;s<r;++s){if((n=t.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function j(t){return Yt(function(t){if((t=(t=t.split("=")[0]).trim().replace(U,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function k(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function M(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function B(t){return t!=t}var q=function(){for(var t="0123456789abcdef",e=new Array(256),n=0;n<16;++n)for(var r=16*n,o=0;o<16;++o)e[r+o]=t[n]+t[o];return e}()}(e={exports:{}},e.exports),e.exports}(),te=Zt.Buffer;Zt.SlowBuffer,Zt.INSPECT_MAX_BYTES,Zt.kMaxLength;var ee=function(t,e){return ee=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},ee(t,e)};function ne(t,e){function n(){this.constructor=t}ee(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var re=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return ne(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),e}(Error),oe=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return ne(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),e}(TypeError);function ie(t){return t&&t.Math==Math&&t}function se(){return ie("object"==typeof globalThis&&globalThis)||ie("object"==typeof window&&window)||ie("object"==typeof self&&self)||ie("object"==typeof n.g&&n.g)||Function("return this")()}var ae=function(t){var e,n="object"==typeof(e=se()).navigator&&"ReactNative"===e.navigator.product?"BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.":"BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.";console.warn(n);for(var r=te.alloc(t),o=0;o<t;++o)r[o]=Math.floor(256*Math.random());return r},ue=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(t&&t.getRandomValues)return function(e){return t.getRandomValues(te.alloc(e))}}return void 0!==n.g&&n.g.crypto&&n.g.crypto.getRandomValues?function(t){return n.g.crypto.getRandomValues(te.alloc(t))}:ae}();function ce(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function fe(t){return"object"==typeof t&&null!==t}function le(t,e){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return n||(console.warn(e),n=!0),t.apply(this,r)}}function he(t){if(ArrayBuffer.isView(t))return te.from(t.buffer,t.byteOffset,t.byteLength);if(e=t,["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e)))return te.from(t);var e;throw new oe("Must use either Buffer or TypedArray")}var pe=/^(?:[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,de=function(t){return"string"==typeof t&&pe.test(t)},ye=function(t){if(!de(t))throw new oe('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var e=t.replace(/-/g,"");return te.from(e,"hex")},ge=function(t,e){return void 0===e&&(e=!0),e?t.toString("hex",0,4)+"-"+t.toString("hex",4,6)+"-"+t.toString("hex",6,8)+"-"+t.toString("hex",8,10)+"-"+t.toString("hex",10,16):t.toString("hex")},ve=(Math.pow(2,63),Math.pow(2,63),Math.pow(2,53)),me=-Math.pow(2,53),we=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(!(null==e||"string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Array.isArray(e)))throw new oe("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=n?n:t.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=te.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=te.from(e,"binary"):Array.isArray(e)?this.buffer=te.from(e):this.buffer=he(e),this.position=this.buffer.byteLength)}return t.prototype.put=function(e){if("string"==typeof e&&1!==e.length)throw new oe("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new oe("only accepts single character Uint8Array or Array");var n;if((n="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0])<0||n>255)throw new oe("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=n;else{var r=te.alloc(t.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=n}},t.prototype.write=function(t,e){if(e="number"==typeof e?e:this.position,this.buffer.length<e+t.length){var n=te.alloc(this.buffer.length+t.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n}ArrayBuffer.isView(t)?(this.buffer.set(he(t),e),this.position=e+t.byteLength>this.position?e+t.length:this.position):"string"==typeof t&&(this.buffer.write(t,e,t.length,"binary"),this.position=e+t.length>this.position?e+t.length:this.position)},t.prototype.read=function(t,e){return e=e&&e>0?e:this.position,this.buffer.slice(t,t+e)},t.prototype.value=function(t){return(t=!!t)&&this.buffer.length===this.position?this.buffer:t?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)},t.prototype.length=function(){return this.position},t.prototype.toJSON=function(){return this.buffer.toString("base64")},t.prototype.toString=function(t){return this.buffer.toString(t)},t.prototype.toExtendedJSON=function(t){t=t||{};var e=this.buffer.toString("base64"),n=Number(this.sub_type).toString(16);return t.legacy?{$binary:e,$type:1===n.length?"0"+n:n}:{$binary:{base64:e,subType:1===n.length?"0"+n:n}}},t.prototype.toUUID=function(){if(this.sub_type===t.SUBTYPE_UUID)return new be(this.buffer.slice(0,this.position));throw new re('Binary sub_type "'.concat(this.sub_type,'" is not supported for converting to UUID. Only "').concat(t.SUBTYPE_UUID,'" is currently supported.'))},t.fromExtendedJSON=function(e,n){var r,o;if(n=n||{},"$binary"in e?n.legacy&&"string"==typeof e.$binary&&"$type"in e?(o=e.$type?parseInt(e.$type,16):0,r=te.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=te.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,r=ye(e.$uuid)),!r)throw new oe("Unexpected Binary Extended JSON format ".concat(JSON.stringify(e)));return 4===o?new be(r):new t(r,o)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.value(!0);return'new Binary(Buffer.from("'.concat(t.toString("hex"),'", "hex"), ').concat(this.sub_type,")")},t.BSON_BINARY_SUBTYPE_DEFAULT=0,t.BUFFER_SIZE=256,t.SUBTYPE_DEFAULT=0,t.SUBTYPE_FUNCTION=1,t.SUBTYPE_BYTE_ARRAY=2,t.SUBTYPE_UUID_OLD=3,t.SUBTYPE_UUID=4,t.SUBTYPE_MD5=5,t.SUBTYPE_ENCRYPTED=6,t.SUBTYPE_COLUMN=7,t.SUBTYPE_USER_DEFINED=128,t}();Object.defineProperty(we.prototype,"_bsontype",{value:"Binary"});var be=function(t){function e(n){var r,o,i=this;if(null==n)r=e.generate();else if(n instanceof e)r=te.from(n.buffer),o=n.__id;else if(ArrayBuffer.isView(n)&&16===n.byteLength)r=he(n);else{if("string"!=typeof n)throw new oe("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");r=ye(n)}return(i=t.call(this,r,4)||this).__id=o,i}return ne(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.buffer},set:function(t){this.buffer=t,e.cacheHexString&&(this.__id=ge(t))},enumerable:!1,configurable:!0}),e.prototype.toHexString=function(t){if(void 0===t&&(t=!0),e.cacheHexString&&this.__id)return this.__id;var n=ge(this.id,t);return e.cacheHexString&&(this.__id=n),n},e.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},e.prototype.toJSON=function(){return this.toHexString()},e.prototype.equals=function(t){if(!t)return!1;if(t instanceof e)return t.id.equals(this.id);try{return new e(t).id.equals(this.id)}catch(t){return!1}},e.prototype.toBinary=function(){return new we(this.id,we.SUBTYPE_UUID)},e.generate=function(){var t=ue(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,te.from(t)},e.isValid=function(t){return!!t&&(t instanceof e||("string"==typeof t?de(t):!!ce(t)&&16===t.length&&64==(240&t[6])&&128==(128&t[8])))},e.createFromHexString=function(t){return new e(ye(t))},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},e}(we),_e=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);this.code=e,this.scope=n}return t.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},t.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},t.fromExtendedJSON=function(e){return new t(e.$code,e.$scope)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toJSON();return'new Code("'.concat(String(t.code),'"').concat(t.scope?", ".concat(JSON.stringify(t.scope)):"",")")},t}();Object.defineProperty(_e.prototype,"_bsontype",{value:"Code"});var Ee=function(){function t(e,n,r,o){if(!(this instanceof t))return new t(e,n,r,o);var i=e.split(".");2===i.length&&(r=i.shift(),e=i.shift()),this.collection=e,this.oid=n,this.db=r,this.fields=o||{}}return Object.defineProperty(t.prototype,"namespace",{get:function(){return this.collection},set:function(t){this.collection=t},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){var t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(t.$db=this.db),t},t.prototype.toExtendedJSON=function(t){t=t||{};var e={$ref:this.collection,$id:this.oid};return t.legacy?e:(this.db&&(e.$db=this.db),e=Object.assign(e,this.fields))},t.fromExtendedJSON=function(e){var n=Object.assign({},e);return delete n.$ref,delete n.$id,delete n.$db,new t(e.$ref,e.$id,e.$db,n)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return'new DBRef("'.concat(this.namespace,'", new ObjectId("').concat(String(t),'")').concat(this.db?', "'.concat(this.db,'"'):"",")")},t}();Object.defineProperty(Ee.prototype,"_bsontype",{value:"DBRef"});var Ie=void 0;try{Ie=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(r){}var Se=4294967296,Oe=0x10000000000000000,Ae=Oe/2,Te={},Ne={},Re=function(){function t(e,n,r){if(void 0===e&&(e=0),!(this instanceof t))return new t(e,n,r);"bigint"==typeof e?Object.assign(this,t.fromBigInt(e,!!n)):"string"==typeof e?Object.assign(this,t.fromString(e,!!n)):(this.low=0|e,this.high=0|n,this.unsigned=!!r),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return t.fromBits=function(e,n,r){return new t(e,n,r)},t.fromInt=function(e,n){var r,o,i;return n?(i=0<=(e>>>=0)&&e<256)&&(o=Ne[e])?o:(r=t.fromBits(e,(0|e)<0?-1:0,!0),i&&(Ne[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(o=Te[e])?o:(r=t.fromBits(e,e<0?-1:0,!1),i&&(Te[e]=r),r)},t.fromNumber=function(e,n){if(isNaN(e))return n?t.UZERO:t.ZERO;if(n){if(e<0)return t.UZERO;if(e>=Oe)return t.MAX_UNSIGNED_VALUE}else{if(e<=-Ae)return t.MIN_VALUE;if(e+1>=Ae)return t.MAX_VALUE}return e<0?t.fromNumber(-e,n).neg():t.fromBits(e%Se|0,e/Se|0,n)},t.fromBigInt=function(e,n){return t.fromString(e.toString(),n)},t.fromString=function(e,n,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t.ZERO;if("number"==typeof n?(r=n,n=!1):n=!!n,(r=r||10)<2||36<r)throw RangeError("radix");var o;if((o=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===o)return t.fromString(e.substring(1),n,r).neg();for(var i=t.fromNumber(Math.pow(r,8)),s=t.ZERO,a=0;a<e.length;a+=8){var u=Math.min(8,e.length-a),c=parseInt(e.substring(a,a+u),r);if(u<8){var f=t.fromNumber(Math.pow(r,u));s=s.mul(f).add(t.fromNumber(c))}else s=(s=s.mul(i)).add(t.fromNumber(c))}return s.unsigned=n,s},t.fromBytes=function(e,n,r){return r?t.fromBytesLE(e,n):t.fromBytesBE(e,n)},t.fromBytesLE=function(e,n){return new t(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)},t.fromBytesBE=function(e,n){return new t(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)},t.isLong=function(t){return fe(t)&&!0===t.__isLong__},t.fromValue=function(e,n){return"number"==typeof e?t.fromNumber(e,n):"string"==typeof e?t.fromString(e,n):t.fromBits(e.low,e.high,"boolean"==typeof n?n:e.unsigned)},t.prototype.add=function(e){t.isLong(e)||(e=t.fromValue(e));var n=this.high>>>16,r=65535&this.high,o=this.low>>>16,i=65535&this.low,s=e.high>>>16,a=65535&e.high,u=e.low>>>16,c=0,f=0,l=0,h=0;return l+=(h+=i+(65535&e.low))>>>16,h&=65535,f+=(l+=o+u)>>>16,l&=65535,c+=(f+=r+a)>>>16,f&=65535,c+=n+s,c&=65535,t.fromBits(l<<16|h,c<<16|f,this.unsigned)},t.prototype.and=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low&e.low,this.high&e.high,this.unsigned)},t.prototype.compare=function(e){if(t.isLong(e)||(e=t.fromValue(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},t.prototype.comp=function(t){return this.compare(t)},t.prototype.divide=function(e){if(t.isLong(e)||(e=t.fromValue(e)),e.isZero())throw Error("division by zero");if(Ie){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;var n=(this.unsigned?Ie.div_u:Ie.div_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,Ie.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?t.UZERO:t.ZERO;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return t.UZERO;if(e.gt(this.shru(1)))return t.UONE;i=t.UZERO}else{if(this.eq(t.MIN_VALUE))return e.eq(t.ONE)||e.eq(t.NEG_ONE)?t.MIN_VALUE:e.eq(t.MIN_VALUE)?t.ONE:(r=this.shr(1).div(e).shl(1)).eq(t.ZERO)?e.isNegative()?t.ONE:t.NEG_ONE:(o=this.sub(e.mul(r)),i=r.add(o.div(e)));if(e.eq(t.MIN_VALUE))return this.unsigned?t.UZERO:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=t.ZERO}for(o=this;o.gte(e);){r=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),a=s<=48?1:Math.pow(2,s-48),u=t.fromNumber(r),c=u.mul(e);c.isNegative()||c.gt(o);)r-=a,c=(u=t.fromNumber(r,this.unsigned)).mul(e);u.isZero()&&(u=t.ONE),i=i.add(u),o=o.sub(c)}return i},t.prototype.div=function(t){return this.divide(t)},t.prototype.equals=function(e){return t.isLong(e)||(e=t.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},t.prototype.eq=function(t){return this.equals(t)},t.prototype.getHighBits=function(){return this.high},t.prototype.getHighBitsUnsigned=function(){return this.high>>>0},t.prototype.getLowBits=function(){return this.low},t.prototype.getLowBitsUnsigned=function(){return this.low>>>0},t.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(t.MIN_VALUE)?64:this.neg().getNumBitsAbs();var e,n=0!==this.high?this.high:this.low;for(e=31;e>0&&0==(n&1<<e);e--);return 0!==this.high?e+33:e+1},t.prototype.greaterThan=function(t){return this.comp(t)>0},t.prototype.gt=function(t){return this.greaterThan(t)},t.prototype.greaterThanOrEqual=function(t){return this.comp(t)>=0},t.prototype.gte=function(t){return this.greaterThanOrEqual(t)},t.prototype.ge=function(t){return this.greaterThanOrEqual(t)},t.prototype.isEven=function(){return 0==(1&this.low)},t.prototype.isNegative=function(){return!this.unsigned&&this.high<0},t.prototype.isOdd=function(){return 1==(1&this.low)},t.prototype.isPositive=function(){return this.unsigned||this.high>=0},t.prototype.isZero=function(){return 0===this.high&&0===this.low},t.prototype.lessThan=function(t){return this.comp(t)<0},t.prototype.lt=function(t){return this.lessThan(t)},t.prototype.lessThanOrEqual=function(t){return this.comp(t)<=0},t.prototype.lte=function(t){return this.lessThanOrEqual(t)},t.prototype.modulo=function(e){if(t.isLong(e)||(e=t.fromValue(e)),Ie){var n=(this.unsigned?Ie.rem_u:Ie.rem_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,Ie.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},t.prototype.mod=function(t){return this.modulo(t)},t.prototype.rem=function(t){return this.modulo(t)},t.prototype.multiply=function(e){if(this.isZero())return t.ZERO;if(t.isLong(e)||(e=t.fromValue(e)),Ie){var n=Ie.mul(this.low,this.high,e.low,e.high);return t.fromBits(n,Ie.get_high(),this.unsigned)}if(e.isZero())return t.ZERO;if(this.eq(t.MIN_VALUE))return e.isOdd()?t.MIN_VALUE:t.ZERO;if(e.eq(t.MIN_VALUE))return this.isOdd()?t.MIN_VALUE:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(t.TWO_PWR_24)&&e.lt(t.TWO_PWR_24))return t.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,o=65535&this.high,i=this.low>>>16,s=65535&this.low,a=e.high>>>16,u=65535&e.high,c=e.low>>>16,f=65535&e.low,l=0,h=0,p=0,d=0;return p+=(d+=s*f)>>>16,d&=65535,h+=(p+=i*f)>>>16,p&=65535,h+=(p+=s*c)>>>16,p&=65535,l+=(h+=o*f)>>>16,h&=65535,l+=(h+=i*c)>>>16,h&=65535,l+=(h+=s*u)>>>16,h&=65535,l+=r*f+o*c+i*u+s*a,l&=65535,t.fromBits(p<<16|d,l<<16|h,this.unsigned)},t.prototype.mul=function(t){return this.multiply(t)},t.prototype.negate=function(){return!this.unsigned&&this.eq(t.MIN_VALUE)?t.MIN_VALUE:this.not().add(t.ONE)},t.prototype.neg=function(){return this.negate()},t.prototype.not=function(){return t.fromBits(~this.low,~this.high,this.unsigned)},t.prototype.notEquals=function(t){return!this.equals(t)},t.prototype.neq=function(t){return this.notEquals(t)},t.prototype.ne=function(t){return this.notEquals(t)},t.prototype.or=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low|e.low,this.high|e.high,this.unsigned)},t.prototype.shiftLeft=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):t.fromBits(0,this.low<<e-32,this.unsigned)},t.prototype.shl=function(t){return this.shiftLeft(t)},t.prototype.shiftRight=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):t.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},t.prototype.shr=function(t){return this.shiftRight(t)},t.prototype.shiftRightUnsigned=function(e){if(t.isLong(e)&&(e=e.toInt()),0==(e&=63))return this;var n=this.high;if(e<32){var r=this.low;return t.fromBits(r>>>e|n<<32-e,n>>>e,this.unsigned)}return 32===e?t.fromBits(n,0,this.unsigned):t.fromBits(n>>>e-32,0,this.unsigned)},t.prototype.shr_u=function(t){return this.shiftRightUnsigned(t)},t.prototype.shru=function(t){return this.shiftRightUnsigned(t)},t.prototype.subtract=function(e){return t.isLong(e)||(e=t.fromValue(e)),this.add(e.neg())},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},t.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*Se+(this.low>>>0):this.high*Se+(this.low>>>0)},t.prototype.toBigInt=function(){return BigInt(this.toString())},t.prototype.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},t.prototype.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},t.prototype.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},t.prototype.toSigned=function(){return this.unsigned?t.fromBits(this.low,this.high,!1):this},t.prototype.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(t.MIN_VALUE)){var n=t.fromNumber(e),r=this.div(n),o=r.mul(n).sub(this);return r.toString(e)+o.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=t.fromNumber(Math.pow(e,6),this.unsigned),s=this,a="";;){var u=s.div(i),c=(s.sub(u.mul(i)).toInt()>>>0).toString(e);if((s=u).isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}},t.prototype.toUnsigned=function(){return this.unsigned?this:t.fromBits(this.low,this.high,!0)},t.prototype.xor=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low^e.low,this.high^e.high,this.unsigned)},t.prototype.eqz=function(){return this.isZero()},t.prototype.le=function(t){return this.lessThanOrEqual(t)},t.prototype.toExtendedJSON=function(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}},t.fromExtendedJSON=function(e,n){var r=t.fromString(e.$numberLong);return n&&n.relaxed?r.toNumber():r},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Long("'.concat(this.toString(),'"').concat(this.unsigned?", true":"",")")},t.TWO_PWR_24=t.fromInt(16777216),t.MAX_UNSIGNED_VALUE=t.fromBits(-1,-1,!0),t.ZERO=t.fromInt(0),t.UZERO=t.fromInt(0,!0),t.ONE=t.fromInt(1),t.UONE=t.fromInt(1,!0),t.NEG_ONE=t.fromInt(-1),t.MAX_VALUE=t.fromBits(-1,2147483647,!1),t.MIN_VALUE=t.fromBits(0,-2147483648,!1),t}();Object.defineProperty(Re.prototype,"__isLong__",{value:!0}),Object.defineProperty(Re.prototype,"_bsontype",{value:"Long"});var Ce=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,xe=/^(\+|-)?(Infinity|inf)$/i,Le=/^(\+|-)?NaN$/i,Pe=6111,Ue=-6176,De=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),je=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),ke=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),Me=/^([-+])?(\d+)?$/;function Be(t){return!isNaN(parseInt(t,10))}function qe(t){var e=Re.fromNumber(1e9),n=Re.fromNumber(0);if(!(t.parts[0]||t.parts[1]||t.parts[2]||t.parts[3]))return{quotient:t,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new Re(t.parts[r],0)),t.parts[r]=n.div(e).low,n=n.modulo(e);return{quotient:t,rem:n}}function Fe(t,e){throw new oe('"'.concat(t,'" is not a valid Decimal128 string - ').concat(e))}var We=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!ce(e))throw new oe("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new oe("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(e){var n,r=!1,o=!1,i=!1,s=0,a=0,u=0,c=0,f=0,l=[0],h=0,p=0,d=0,y=0,g=0,v=0,m=new Re(0,0),w=new Re(0,0),b=0;if(e.length>=7e3)throw new oe(e+" not a valid Decimal128 string");var _=e.match(Ce),E=e.match(xe),I=e.match(Le);if(!_&&!E&&!I||0===e.length)throw new oe(e+" not a valid Decimal128 string");if(_){var S=_[2],O=_[4],A=_[5],T=_[6];O&&void 0===T&&Fe(e,"missing exponent power"),O&&void 0===S&&Fe(e,"missing exponent base"),void 0===O&&(A||T)&&Fe(e,"missing e before exponent")}if("+"!==e[b]&&"-"!==e[b]||(r="-"===e[b++]),!Be(e[b])&&"."!==e[b]){if("i"===e[b]||"I"===e[b])return new t(te.from(r?je:ke));if("N"===e[b])return new t(te.from(De))}for(;Be(e[b])||"."===e[b];)"."!==e[b]?(h<34&&("0"!==e[b]||i)&&(i||(f=a),i=!0,l[p++]=parseInt(e[b],10),h+=1),i&&(u+=1),o&&(c+=1),a+=1,b+=1):(o&&Fe(e,"contains multiple periods"),o=!0,b+=1);if(o&&!a)throw new oe(e+" not a valid Decimal128 string");if("e"===e[b]||"E"===e[b]){var N=e.substr(++b).match(Me);if(!N||!N[2])return new t(te.from(De));g=parseInt(N[0],10),b+=N[0].length}if(e[b])return new t(te.from(De));if(d=0,h){if(y=h-1,1!==(s=u))for(;0===l[f+s-1];)s-=1}else d=0,y=0,l[0]=0,u=1,h=1,s=0;for(g<=c&&c-g>16384?g=Ue:g-=c;g>Pe;){if((y+=1)-d>34){if(l.join("").match(/^0+$/)){g=Pe;break}Fe(e,"overflow")}g-=1}for(;g<Ue||h<u;){if(0===y&&s<h){g=Ue,s=0;break}if(h<u?u-=1:y-=1,g<Pe)g+=1;else{if(l.join("").match(/^0+$/)){g=Pe;break}Fe(e,"overflow")}}if(y-d+1<s){var R=a;o&&(f+=1,R+=1),r&&(f+=1,R+=1);var C=parseInt(e[f+y+1],10),x=0;if(C>=5&&(x=1,5===C))for(x=l[y]%2==1?1:0,v=f+y+2;v<R;v++)if(parseInt(e[v],10)){x=1;break}if(x)for(var L=y;L>=0;L--)if(++l[L]>9&&(l[L]=0,0===L)){if(!(g<Pe))return new t(te.from(r?je:ke));g+=1,l[L]=1}}if(m=Re.fromNumber(0),w=Re.fromNumber(0),0===s)m=Re.fromNumber(0),w=Re.fromNumber(0);else if(y-d<17)for(L=d,w=Re.fromNumber(l[L++]),m=new Re(0,0);L<=y;L++)w=(w=w.multiply(Re.fromNumber(10))).add(Re.fromNumber(l[L]));else{for(L=d,m=Re.fromNumber(l[L++]);L<=y-17;L++)m=(m=m.multiply(Re.fromNumber(10))).add(Re.fromNumber(l[L]));for(w=Re.fromNumber(l[L++]);L<=y;L++)w=(w=w.multiply(Re.fromNumber(10))).add(Re.fromNumber(l[L]))}var P,U,D,j,k=function(t,e){if(!t&&!e)return{high:Re.fromNumber(0),low:Re.fromNumber(0)};var n=t.shiftRightUnsigned(32),r=new Re(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new Re(e.getLowBits(),0),s=n.multiply(o),a=n.multiply(i),u=r.multiply(o),c=r.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new Re(a.getLowBits(),0).add(u).add(c.shiftRightUnsigned(32)),{high:s=s.add(a.shiftRightUnsigned(32)),low:c=a.shiftLeft(32).add(new Re(c.getLowBits(),0))}}(m,Re.fromString("100000000000000000"));k.low=k.low.add(w),U=w,((D=(P=k.low).high>>>0)<(j=U.high>>>0)||D===j&&P.low>>>0<U.low>>>0)&&(k.high=k.high.add(Re.fromNumber(1))),n=g+6176;var M={low:Re.fromNumber(0),high:Re.fromNumber(0)};k.high.shiftRightUnsigned(49).and(Re.fromNumber(1)).equals(Re.fromNumber(1))?(M.high=M.high.or(Re.fromNumber(3).shiftLeft(61)),M.high=M.high.or(Re.fromNumber(n).and(Re.fromNumber(16383).shiftLeft(47))),M.high=M.high.or(k.high.and(Re.fromNumber(0x7fffffffffff)))):(M.high=M.high.or(Re.fromNumber(16383&n).shiftLeft(49)),M.high=M.high.or(k.high.and(Re.fromNumber(562949953421311)))),M.low=k.low,r&&(M.high=M.high.or(Re.fromString("9223372036854775808")));var B=te.alloc(16);return b=0,B[b++]=255&M.low.low,B[b++]=M.low.low>>8&255,B[b++]=M.low.low>>16&255,B[b++]=M.low.low>>24&255,B[b++]=255&M.low.high,B[b++]=M.low.high>>8&255,B[b++]=M.low.high>>16&255,B[b++]=M.low.high>>24&255,B[b++]=255&M.high.low,B[b++]=M.high.low>>8&255,B[b++]=M.high.low>>16&255,B[b++]=M.high.low>>24&255,B[b++]=255&M.high.high,B[b++]=M.high.high>>8&255,B[b++]=M.high.high>>16&255,B[b++]=M.high.high>>24&255,new t(B)},t.prototype.toString=function(){for(var t,e=0,n=new Array(36),r=0;r<n.length;r++)n[r]=0;var o,i,s,a=0,u=!1,c={parts:[0,0,0,0]},f=[];a=0;var l=this.bytes,h=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,p=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,d=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,y=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24;a=0,(new Re(h,p),new Re(d,y)).lessThan(Re.ZERO)&&f.push("-");var g=y>>26&31;if(g>>3==3){if(30===g)return f.join("")+"Infinity";if(31===g)return"NaN";t=y>>15&16383,o=8+(y>>14&1)}else o=y>>14&7,t=y>>17&16383;var v=t-6176;if(c.parts[0]=(16383&y)+((15&o)<<14),c.parts[1]=d,c.parts[2]=p,c.parts[3]=h,0===c.parts[0]&&0===c.parts[1]&&0===c.parts[2]&&0===c.parts[3])u=!0;else for(s=3;s>=0;s--){var m=0,w=qe(c);if(c=w.quotient,m=w.rem.low)for(i=8;i>=0;i--)n[9*s+i]=m%10,m=Math.floor(m/10)}if(u)e=1,n[a]=0;else for(e=36;!n[a];)e-=1,a+=1;var b=e-1+v;if(b>=34||b<=-7||v>0){if(e>34)return f.push("".concat(0)),v>0?f.push("E+".concat(v)):v<0&&f.push("E".concat(v)),f.join("");for(f.push("".concat(n[a++])),(e-=1)&&f.push("."),r=0;r<e;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<e;r++)f.push("".concat(n[a++]));else{var _=e+v;if(_>0)for(r=0;r<_;r++)f.push("".concat(n[a++]));else f.push("0");for(f.push(".");_++<0;)f.push("0");for(r=0;r<e-Math.max(_-1,0);r++)f.push("".concat(n[a++]))}return f.join("")},t.prototype.toJSON=function(){return{$numberDecimal:this.toString()}},t.prototype.toExtendedJSON=function(){return{$numberDecimal:this.toString()}},t.fromExtendedJSON=function(e){return t.fromString(e.$numberDecimal)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Decimal128("'.concat(this.toString(),'")')},t}();Object.defineProperty(We.prototype,"_bsontype",{value:"Decimal128"});var $e=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toJSON=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toExtendedJSON=function(t){return t&&(t.legacy||t.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-".concat(this.value.toFixed(1))}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}},t.fromExtendedJSON=function(e,n){var r=parseFloat(e.$numberDouble);return n&&n.relaxed?r:new t(r)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toExtendedJSON();return"new Double(".concat(t.$numberDouble,")")},t}();Object.defineProperty($e.prototype,"_bsontype",{value:"Double"});var He=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=0|+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(t){return t&&(t.relaxed||t.legacy)?this.value:{$numberInt:this.value.toString()}},t.fromExtendedJSON=function(e,n){return n&&n.relaxed?parseInt(e.$numberInt,10):new t(e.$numberInt)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new Int32(".concat(this.valueOf(),")")},t}();Object.defineProperty(He.prototype,"_bsontype",{value:"Int32"});var Ve=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$maxKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MaxKey()"},t}();Object.defineProperty(Ve.prototype,"_bsontype",{value:"MaxKey"});var Ge=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$minKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MinKey()"},t}();Object.defineProperty(Ge.prototype,"_bsontype",{value:"MinKey"});var Je=new RegExp("^[0-9a-fA-F]{24}$"),Ke=null,Ye=Symbol("id"),ze=function(){function t(e){if(!(this instanceof t))return new t(e);var n;if("object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new oe("Argument passed in must have an id that is of type string or Buffer");n="toHexString"in e&&"function"==typeof e.toHexString?te.from(e.toHexString(),"hex"):e.id}else n=e;if(null==n||"number"==typeof n)this[Ye]=t.generate("number"==typeof n?n:void 0);else if(ArrayBuffer.isView(n)&&12===n.byteLength)this[Ye]=n instanceof te?n:he(n);else{if("string"!=typeof n)throw new oe("Argument passed in does not match the accepted types");if(12===n.length){var r=te.from(n);if(12!==r.byteLength)throw new oe("Argument passed in must be a string of 12 bytes");this[Ye]=r}else{if(24!==n.length||!Je.test(n))throw new oe("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[Ye]=te.from(n,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[Ye]},set:function(e){this[Ye]=e,t.cacheHexString&&(this.__id=e.toString("hex"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"generationTime",{get:function(){return this.id.readInt32BE(0)},set:function(t){this.id.writeUInt32BE(t,0)},enumerable:!1,configurable:!0}),t.prototype.toHexString=function(){if(t.cacheHexString&&this.__id)return this.__id;var e=this.id.toString("hex");return t.cacheHexString&&!this.__id&&(this.__id=e),e},t.getInc=function(){return t.index=(t.index+1)%16777215},t.generate=function(e){"number"!=typeof e&&(e=Math.floor(Date.now()/1e3));var n=t.getInc(),r=te.alloc(12);return r.writeUInt32BE(e,0),null===Ke&&(Ke=ue(5)),r[4]=Ke[0],r[5]=Ke[1],r[6]=Ke[2],r[7]=Ke[3],r[8]=Ke[4],r[11]=255&n,r[10]=n>>8&255,r[9]=n>>16&255,r},t.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},t.prototype.toJSON=function(){return this.toHexString()},t.prototype.equals=function(e){if(null==e)return!1;if(e instanceof t)return this[Ye][11]===e[Ye][11]&&this[Ye].equals(e[Ye]);if("string"==typeof e&&t.isValid(e)&&12===e.length&&ce(this.id))return e===te.prototype.toString.call(this.id,"latin1");if("string"==typeof e&&t.isValid(e)&&24===e.length)return e.toLowerCase()===this.toHexString();if("string"==typeof e&&t.isValid(e)&&12===e.length)return te.from(e).equals(this.id);if("object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString){var n=e.toHexString(),r=this.toHexString().toLowerCase();return"string"==typeof n&&n.toLowerCase()===r}return!1},t.prototype.getTimestamp=function(){var t=new Date,e=this.id.readUInt32BE(0);return t.setTime(1e3*Math.floor(e)),t},t.createPk=function(){return new t},t.createFromTime=function(e){var n=te.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n.writeUInt32BE(e,0),new t(n)},t.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new oe("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(te.from(e,"hex"))},t.isValid=function(e){if(null==e)return!1;try{return new t(e),!0}catch(t){return!1}},t.prototype.toExtendedJSON=function(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}},t.fromExtendedJSON=function(e){return new t(e.$oid)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new ObjectId("'.concat(this.toHexString(),'")')},t.index=Math.floor(16777215*Math.random()),t}();Object.defineProperty(ze.prototype,"generate",{value:le((function(t){return ze.generate(t)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(ze.prototype,"getInc",{value:le((function(){return ze.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(ze.prototype,"get_inc",{value:le((function(){return ze.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(ze,"get_inc",{value:le((function(){return ze.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(ze.prototype,"_bsontype",{value:"ObjectID"});var Qe=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(this.pattern=e,this.options=(null!=n?n:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new re("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new re("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 re("The regular expression option [".concat(this.options[r],"] is not supported"))}return t.parseOptions=function(t){return t?t.split("").sort().join(""):""},t.prototype.toExtendedJSON=function(t){return(t=t||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}},t.fromExtendedJSON=function(e){if("$regex"in e){if("string"==typeof e.$regex)return new t(e.$regex,t.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new t(e.$regularExpression.pattern,t.parseOptions(e.$regularExpression.options));throw new oe("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(e)))},t}();Object.defineProperty(Qe.prototype,"_bsontype",{value:"BSONRegExp"});var Xe=function(){function t(e){if(!(this instanceof t))return new t(e);this.value=e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(){return this.value},t.prototype.inspect=function(){return'new BSONSymbol("'.concat(this.value,'")')},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(){return{$symbol:this.value}},t.fromExtendedJSON=function(e){return new t(e.$symbol)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t}();Object.defineProperty(Xe.prototype,"_bsontype",{value:"Symbol"});var Ze=function(t){function e(n,r){var o=this;return o instanceof e?(o=Re.isLong(n)?t.call(this,n.low,n.high,!0)||this:fe(n)&&void 0!==n.t&&void 0!==n.i?t.call(this,n.i,n.t,!0)||this:t.call(this,n,r,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new e(n,r)}return ne(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(Re.fromInt(t,!0))},e.fromNumber=function(t){return new e(Re.fromNumber(t,!0))},e.fromBits=function(t,n){return new e(t,n)},e.fromString=function(t,n){return new e(Re.fromString(t,!0,n))},e.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},e.fromExtendedJSON=function(t){return new e(t.$timestamp)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Timestamp({ t: ".concat(this.getHighBits(),", i: ").concat(this.getLowBits()," })")},e.MAX_VALUE=Re.MAX_UNSIGNED_VALUE,e}(Re);var tn=2147483647,en=-2147483648,nn=0x8000000000000000,rn=-0x8000000000000000,on={$oid:ze,$binary:we,$uuid:we,$symbol:Xe,$numberInt:He,$numberDecimal:We,$numberDouble:$e,$numberLong:Re,$minKey:Ge,$maxKey:Ve,$regex:Qe,$regularExpression:Qe,$timestamp:Ze};function sn(t,e){if(void 0===e&&(e={}),"number"==typeof t){if(e.relaxed||e.legacy)return t;if(Math.floor(t)===t){if(t>=en&&t<=tn)return new He(t);if(t>=rn&&t<=nn)return Re.fromNumber(t)}return new $e(t)}if(null==t||"object"!=typeof t)return t;if(t.$undefined)return null;for(var n=Object.keys(t).filter((function(e){return e.startsWith("$")&&null!=t[e]})),r=0;r<n.length;r++){var o=on[n[r]];if(o)return o.fromExtendedJSON(t,e)}if(null!=t.$date){var i=t.$date,s=new Date;return e.legacy?"number"==typeof i?s.setTime(i):"string"==typeof i&&s.setTime(Date.parse(i)):"string"==typeof i?s.setTime(Date.parse(i)):Re.isLong(i)?s.setTime(i.toNumber()):"number"==typeof i&&e.relaxed&&s.setTime(i),s}if(null!=t.$code){var a=Object.assign({},t);return t.$scope&&(a.$scope=sn(t.$scope)),_e.fromExtendedJSON(t)}if(function(t){return fe(t)&&null!=t.$id&&"string"==typeof t.$ref&&(null==t.$db||"string"==typeof t.$db)}(t)||t.$dbPointer){var u=t.$ref?t:t.$dbPointer;if(u instanceof Ee)return u;var c=Object.keys(u).filter((function(t){return t.startsWith("$")})),f=!0;if(c.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(f=!1)})),f)return Ee.fromExtendedJSON(u)}return t}function an(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function un(t,e){if(("object"==typeof t||"function"==typeof t)&&null!==t){var n=e.seenObjects.findIndex((function(e){return e.obj===t}));if(-1!==n){var r=e.seenObjects.map((function(t){return t.propertyName})),o=r.slice(0,n).map((function(t){return"".concat(t," -> ")})).join(""),i=r[n],s=" -> "+r.slice(n+1,r.length-1).map((function(t){return"".concat(t," -> ")})).join(""),a=r[r.length-1],u=" ".repeat(o.length+i.length/2),c="-".repeat(s.length+(i.length+a.length)/2-1);throw new oe("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(s).concat(a,"\n")+" ".concat(u,"\\").concat(c,"/"))}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((function(t,n){e.seenObjects.push({propertyName:"index ".concat(n),obj:null});try{return un(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||fe(h=t)&&"[object Date]"===Object.prototype.toString.call(h)){var f=t.getTime(),l=f>-1&&f<2534023188e5;return e.legacy?e.relaxed&&l?{$date:t.getTime()}:{$date:an(t)}:e.relaxed&&l?{$date:an(t)}:{$date:{$numberLong:t.getTime().toString()}}}var h;if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Math.floor(t)===t){var p=t>=rn&&t<=nn;if(t>=en&&t<=tn)return{$numberInt:t.toString()};if(p)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||function(t){return"[object RegExp]"===Object.prototype.toString.call(t)}(t)){var d=t.flags;if(void 0===d){var y=t.toString().match(/[gimuy]*$/);y&&(d=y[0])}return new Qe(t.source,d).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new re("not an object instance");var n=t._bsontype;if(void 0===n){var r={};for(var o in t){e.seenObjects.push({propertyName:o,obj:null});try{var i=un(t[o],e);"__proto__"===o?Object.defineProperty(r,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):r[o]=i}finally{e.seenObjects.pop()}}return r}if(function(t){return fe(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}(t)){var s=t;if("function"!=typeof s.toExtendedJSON){var a=fn[t._bsontype];if(!a)throw new oe("Unrecognized or invalid _bsontype: "+t._bsontype);s=a(s)}return"Code"===n&&s.scope?s=new _e(s.code,un(s.scope,e)):"DBRef"===n&&s.oid&&(s=new Ee(un(s.collection,e),un(s.oid,e),un(s.db,e),un(s.fields,e))),s.toExtendedJSON(e)}throw new re("_bsontype must be a string, but was: "+typeof n)}(t,e):t}var cn,fn={Binary:function(t){return new we(t.value(),t.sub_type)},Code:function(t){return new _e(t.code,t.scope)},DBRef:function(t){return new Ee(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new We(t.bytes)},Double:function(t){return new $e(t.value)},Int32:function(t){return new He(t.value)},Long:function(t){return Re.fromBits(null!=t.low?t.low:t.low_,null!=t.low?t.high:t.high_,null!=t.low?t.unsigned:t.unsigned_)},MaxKey:function(){return new Ve},MinKey:function(){return new Ge},ObjectID:function(t){return new ze(t)},ObjectId:function(t){return new ze(t)},BSONRegExp:function(t){return new Qe(t.pattern,t.options)},Symbol:function(t){return new Xe(t.value)},Timestamp:function(t){return Ze.fromBits(t.low,t.high)}};!function(t){function e(t,e){var n=Object.assign({},{relaxed:!0,legacy:!1},e);return"boolean"==typeof n.relaxed&&(n.strict=!n.relaxed),"boolean"==typeof n.strict&&(n.relaxed=!n.strict),JSON.parse(t,(function(t,e){if(-1!==t.indexOf("\0"))throw new re("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(t)));return sn(e,n)}))}function n(t,e,n,r){null!=n&&"object"==typeof n&&(r=n,n=0),null==e||"object"!=typeof e||Array.isArray(e)||(r=e,e=void 0,n=0);var o=un(t,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,n)}t.parse=e,t.stringify=n,t.serialize=function(t,e){return e=e||{},JSON.parse(n(t,e))},t.deserialize=function(t,n){return n=n||{},e(JSON.stringify(t),n)}}(cn||(cn={}));var ln=se();ln.Map?ln.Map:function(){function t(t){void 0===t&&(t=[]),this._keys=[],this._values={};for(var e=0;e<t.length;e++)if(null!=t[e]){var n=t[e],r=n[0],o=n[1];this._keys.push(r),this._values[r]={v:o,i:this._keys.length-1}}}t.prototype.clear=function(){this._keys=[],this._values={}},t.prototype.delete=function(t){var e=this._values[t];return null!=e&&(delete this._values[t],this._keys.splice(e.i,1),!0)},t.prototype.entries=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?[n,t._values[n].v]:void 0,done:void 0===n}}}},t.prototype.forEach=function(t,e){e=e||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];t.call(e,this._values[r].v,r,e)}},t.prototype.get=function(t){return this._values[t]?this._values[t].v:void 0},t.prototype.has=function(t){return null!=this._values[t]},t.prototype.keys=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},t.prototype.set=function(t,e){return this._values[t]?(this._values[t].v=e,this):(this._keys.push(t),this._values[t]={v:e,i:this._keys.length-1},this)},t.prototype.values=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?t._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0})}(),Re.fromNumber(ve),Re.fromNumber(me),new Set(["$db","$ref","$id","$clusterTime"]);var hn=new Uint8Array(8);new DataView(hn.buffer,hn.byteOffset,hn.byteLength);te.alloc(17825792);var pn=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=new Dn.reqClass(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return t=this,e=void 0,r=function(){var t;return function(t,e){var n,r,o,i,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=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(e){switch(e.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(t=e.sent())&&t.data&&t.data.list?[2,{requestId:t.requestId,data:JSON.parse(t.data.list).map(cn.parse)}]:[2,t]}}))},new((n=void 0)||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}));var t,e,n,r},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map((function(t){var e,n=t.stageKey,r=t.stageValue;return(e={})[n]=JSON.parse(r),e}))},t.prototype._pipe=function(t,e){return this._stages.push({stageKey:"$"+t,stageValue:JSON.stringify(e)}),this},t.prototype.addFields=function(t){return this._pipe("addFields",t)},t.prototype.bucket=function(t){return this._pipe("bucket",t)},t.prototype.bucketAuto=function(t){return this._pipe("bucketAuto",t)},t.prototype.count=function(t){return this._pipe("count",t)},t.prototype.geoNear=function(t){return t.query&&(t.query=kt.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new ot(t.near.longitude,t.near.latitude).toJSON()),this._pipe("geoNear",t)},t.prototype.group=function(t){return this._pipe("group",t)},t.prototype.limit=function(t){return this._pipe("limit",t)},t.prototype.match=function(t){return this._pipe("match",kt.encode(t))},t.prototype.project=function(t){return this._pipe("project",t)},t.prototype.lookup=function(t){return this._pipe("lookup",t)},t.prototype.replaceRoot=function(t){return this._pipe("replaceRoot",t)},t.prototype.sample=function(t){return this._pipe("sample",t)},t.prototype.skip=function(t){return this._pipe("skip",t)},t.prototype.sort=function(t){return this._pipe("sort",t)},t.prototype.sortByCount=function(t){return this._pipe("sortByCount",t)},t.prototype.unwind=function(t){return this._pipe("unwind",t)},t}(),dn=pn,yn=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),gn=function(t){function e(e,n){return t.call(this,e,n)||this}return yn(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new jt(this._db,this._coll,t)},e.prototype.add=function(t,e){return new jt(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new dn(this._db,this._coll)},e}(qt),vn={eq:function(t){return new pt(lt.EQ,[t])},neq:function(t){return new pt(lt.NEQ,[t])},lt:function(t){return new pt(lt.LT,[t])},lte:function(t){return new pt(lt.LTE,[t])},gt:function(t){return new pt(lt.GT,[t])},gte:function(t){return new pt(lt.GTE,[t])},in:function(t){return new pt(lt.IN,t)},nin:function(t){return new pt(lt.NIN,t)},all:function(t){return new pt(lt.ALL,t)},elemMatch:function(t){return new pt(lt.ELEM_MATCH,[t])},exists:function(t){return new pt(lt.EXISTS,[t])},size:function(t){return new pt(lt.SIZE,[t])},mod:function(t){return new pt(lt.MOD,[t])},geoNear:function(t){return new pt(lt.GEO_NEAR,[t])},geoWithin:function(t){return new pt(lt.GEO_WITHIN,[t])},geoIntersects:function(t){return new pt(lt.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=q(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=q(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=q(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=q(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.NOT,n)},set:function(t){return new at(tt.SET,[t])},remove:function(){return new at(tt.REMOVE,[])},inc:function(t){return new at(tt.INC,[t])},mul:function(t){return new at(tt.MUL,[t])},push:function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(M(e[0])&&e[0].hasOwnProperty("each")){var r=e[0];t={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else t=q(e[0])?e[0]:Array.from(e);return new at(tt.PUSH,t)},pull:function(t){return new at(tt.PULL,t)},pullAll:function(t){return new at(tt.PULL_ALL,t)},pop:function(){return new at(tt.POP,[])},shift:function(){return new at(tt.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=q(arguments[0])?arguments[0]:Array.from(arguments);return new at(tt.UNSHIFT,n)},addToSet:function(t){return new at(tt.ADD_TO_SET,t)},rename:function(t){return new at(tt.RENAME,[t])},bit:function(t){return new at(tt.BIT,[t])},max:function(t){return new at(tt.MAX,[t])},min:function(t){return new at(tt.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===k(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new dn},abs:function(t){return new mn("abs",t)},add:function(t){return new mn("add",t)},ceil:function(t){return new mn("ceil",t)},divide:function(t){return new mn("divide",t)},exp:function(t){return new mn("exp",t)},floor:function(t){return new mn("floor",t)},ln:function(t){return new mn("ln",t)},log:function(t){return new mn("log",t)},log10:function(t){return new mn("log10",t)},mod:function(t){return new mn("mod",t)},multiply:function(t){return new mn("multiply",t)},pow:function(t){return new mn("pow",t)},sqrt:function(t){return new mn("sqrt",t)},subtract:function(t){return new mn("subtract",t)},trunc:function(t){return new mn("trunc",t)},arrayElemAt:function(t){return new mn("arrayElemAt",t)},arrayToObject:function(t){return new mn("arrayToObject",t)},concatArrays:function(t){return new mn("concatArrays",t)},filter:function(t){return new mn("filter",t)},in:function(t){return new mn("in",t)},indexOfArray:function(t){return new mn("indexOfArray",t)},isArray:function(t){return new mn("isArray",t)},map:function(t){return new mn("map",t)},range:function(t){return new mn("range",t)},reduce:function(t){return new mn("reduce",t)},reverseArray:function(t){return new mn("reverseArray",t)},size:function(t){return new mn("size",t)},slice:function(t){return new mn("slice",t)},zip:function(t){return new mn("zip",t)},and:function(t){return new mn("and",t)},not:function(t){return new mn("not",t)},or:function(t){return new mn("or",t)},cmp:function(t){return new mn("cmp",t)},eq:function(t){return new mn("eq",t)},gt:function(t){return new mn("gt",t)},gte:function(t){return new mn("gte",t)},lt:function(t){return new mn("lt",t)},lte:function(t){return new mn("lte",t)},neq:function(t){return new mn("ne",t)},cond:function(t){return new mn("cond",t)},ifNull:function(t){return new mn("ifNull",t)},switch:function(t){return new mn("switch",t)},dateFromParts:function(t){return new mn("dateFromParts",t)},dateFromString:function(t){return new mn("dateFromString",t)},dayOfMonth:function(t){return new mn("dayOfMonth",t)},dayOfWeek:function(t){return new mn("dayOfWeek",t)},dayOfYear:function(t){return new mn("dayOfYear",t)},isoDayOfWeek:function(t){return new mn("isoDayOfWeek",t)},isoWeek:function(t){return new mn("isoWeek",t)},isoWeekYear:function(t){return new mn("isoWeekYear",t)},millisecond:function(t){return new mn("millisecond",t)},minute:function(t){return new mn("minute",t)},month:function(t){return new mn("month",t)},second:function(t){return new mn("second",t)},hour:function(t){return new mn("hour",t)},week:function(t){return new mn("week",t)},year:function(t){return new mn("year",t)},literal:function(t){return new mn("literal",t)},mergeObjects:function(t){return new mn("mergeObjects",t)},objectToArray:function(t){return new mn("objectToArray",t)},allElementsTrue:function(t){return new mn("allElementsTrue",t)},anyElementTrue:function(t){return new mn("anyElementTrue",t)},setDifference:function(t){return new mn("setDifference",t)},setEquals:function(t){return new mn("setEquals",t)},setIntersection:function(t){return new mn("setIntersection",t)},setIsSubset:function(t){return new mn("setIsSubset",t)},setUnion:function(t){return new mn("setUnion",t)},concat:function(t){return new mn("concat",t)},dateToString:function(t){return new mn("dateToString",t)},indexOfBytes:function(t){return new mn("indexOfBytes",t)},indexOfCP:function(t){return new mn("indexOfCP",t)},split:function(t){return new mn("split",t)},strLenBytes:function(t){return new mn("strLenBytes",t)},strLenCP:function(t){return new mn("strLenCP",t)},strcasecmp:function(t){return new mn("strcasecmp",t)},substr:function(t){return new mn("substr",t)},substrBytes:function(t){return new mn("substrBytes",t)},substrCP:function(t){return new mn("substrCP",t)},toLower:function(t){return new mn("toLower",t)},toUpper:function(t){return new mn("toUpper",t)},meta:function(t){return new mn("meta",t)},addToSet:function(t){return new mn("addToSet",t)},avg:function(t){return new mn("avg",t)},first:function(t){return new mn("first",t)},last:function(t){return new mn("last",t)},max:function(t){return new mn("max",t)},min:function(t){return new mn("min",t)},push:function(t){return new mn("push",t)},stdDevPop:function(t){return new mn("stdDevPop",t)},stdDevSamp:function(t){return new mn("stdDevSamp",t)},sum:function(t){return new mn("sum",t)},let:function(t){return new mn("let",t)}},project:{slice:function(t){return new wn("slice",t)},elemMatch:function(t){return new wn("elemMatch",t)}}},mn=function(t,e){this["$"+t]=e},wn=function(t,e){this["$"+t]=e},bn=function(){function t(t){var e=t.regexp,n=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regex=e,this.$options=n}return t.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),t}();function _n(t){return new bn(t)}var En={CREATE_WATCH_NET_ERROR:{code:"CREATE_WATCH_NET_ERROR",message:"create watch network error"},CREATE_WACTH_EXCEED_ERROR:{code:"CREATE_WACTH_EXCEED_ERROR",message:"maximum connections exceed"},CREATE_WATCH_SERVER_ERROR:{code:"CREATE_WATCH_SERVER_ERROR",message:"create watch server error"},CONN_ERROR:{code:"CONN_ERROR",message:"connection error"},INVALID_PARAM:{code:"INVALID_PARAM",message:"Invalid request param"},INSERT_DOC_FAIL:{code:"INSERT_DOC_FAIL",message:"insert document failed"},DATABASE_TRANSACTION_CONFLICT:{code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"}},In=function(){return In=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},In.apply(this,arguments)},Sn=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},On=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},An="database.updateDocInTransaction",Tn=function(){function t(t,e,n){this._coll=e,this.id=n,this._transaction=t,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.create=function(t){return Sn(this,void 0,void 0,(function(){var e,n,r,o;return On(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:cn.stringify(Et(t),{relaxed:!1})},this.id&&(e._id=this.id),[4,this._request.send("database.insertDocInTransaction",e)];case 1:if((n=i.sent()).code)throw n;if(r=cn.parse(n.inserted),1==(o=cn.parse(n.ok))&&1==r)return[2,In(In({},n),{ok:o,inserted:r})];throw new Error(En.INSERT_DOC_FAIL.message)}}))}))},t.prototype.get=function(){return Sn(this,void 0,void 0,(function(){var t,e;return On(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,{data:"null"!==e.data?nt.formatField(cn.parse(e.data)):cn.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return Sn(this,void 0,void 0,(function(){var e,n;return On(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:cn.stringify(Et(t),{relaxed:!1}),upsert:!0},[4,this._request.send(An,e)];case 1:if((n=r.sent()).code)throw n;return[2,In(In({},n),{updated:cn.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},t.prototype.update=function(t){return Sn(this,void 0,void 0,(function(){var e,n;return On(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:cn.stringify(Lt.encode(t),{relaxed:!1})},[4,this._request.send(An,e)];case 1:if((n=r.sent()).code)throw n;return[2,In(In({},n),{updated:cn.parse(n.updated)})]}}))}))},t.prototype.delete=function(){return Sn(this,void 0,void 0,(function(){var t,e;return On(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,In(In({},e),{deleted:cn.parse(e.deleted)})]}}))}))},t}(),Nn=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Rn=function(t){function e(e,n){return t.call(this,e,n)||this}return Nn(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new Tn(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new Tn(this._transaction,this._coll,e).create(t)},e}((function(t,e){this._coll=e,this._transaction=t})),Cn=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},xn=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Ln=function(){function t(t){this._db=t,this._request=new Dn.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return Cn(this,void 0,void 0,(function(){var t;return xn(this,(function(e){switch(e.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((t=e.sent()).code)throw t;return this.inited=!0,this._id=t.transactionId,[2]}}))}))},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new Rn(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return Cn(this,void 0,void 0,(function(){var t,e;return xn(this,(function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.commitTransaction",t)];case 1:if((e=n.sent()).code)throw e;return this.commited=!0,[2,e]}}))}))},t.prototype.rollback=function(t){return Cn(this,void 0,void 0,(function(){var e,n;return xn(this,(function(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.abortTransaction",e)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=t,[2,n]}}))}))},t}();function Pn(){return Cn(this,void 0,void 0,(function(){var t;return xn(this,(function(e){switch(e.label){case 0:return[4,(t=new Ln(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function Un(t,e){return void 0===e&&(e=3),Cn(this,void 0,void 0,(function(){var n,r,o,i,s=this;return xn(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new Ln(this)).init()];case 1:return a.sent(),[4,t(n)];case 2:if(r=a.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return a.sent(),[2,r];case 4:if(o=a.sent(),!1===n.inited)throw o;return i=function(t){return Cn(s,void 0,void 0,(function(){return xn(this,(function(e){switch(e.label){case 0:if(n.aborted||n.commited)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.rollback()];case 2:case 3:return e.sent(),[3,4];case 4:throw t;case 5:if(!0===n.aborted)throw n.abortReason;throw t}}))}))},e<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===En.DATABASE_TRANSACTION_CONFLICT.code?[4,Un.bind(this)(t,--e)]:[3,8];case 7:return[2,a.sent()];case 8:return[4,i(o)];case 9:return a.sent(),[3,10];case 10:return[2]}}))}))}var Dn=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=Z,this.command=vn,this.RegExp=_n,this.startTransaction=Pn,this.runTransaction=Un,this.logicCommand=ct,this.updateCommand=at,this.queryCommand=pt}return t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new gn(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return new t.reqClass(this.config).send("database.addCollection",n)},t}(),jn=function(){return jn=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},jn.apply(this,arguments)},kn={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,r=e.runtime;return Dn.reqClass=this.request.constructor,Dn.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},Dn.runtime=r,this.wsClientClass&&(Dn.wsClass=n.wsClass,Dn.wsClientClass=this.wsClientClass),Dn.ws||(Dn.ws=null),new Dn(jn(jn(jn({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(kn)}catch(t){}function Mn(t){try{t.registerComponent(kn)}catch(t){console.warn(t)}}},338:function(t,e,n){"use strict";n.r(e),n.d(e,{registerFunctions:function(){return p}});var r=n(142),o=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},i=r._G.eX,s=r._G.Sg,a=r._G.vM,u=r.P6.Gc,c=r.BM.D,f="functions",l=new(function(){function t(){}return t.prototype.callFunction=function(t,e){return n=this,r=void 0,a=function(){var n,r,o,a,c,l,h,p,d,y,g,v;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(m){switch(m.label){case 0:if(n=t.name,r=t.data,o=t.query,a=t.parse,c=t.search,!n)throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(f,".callFunction] invalid function name")}));try{l=r?JSON.stringify(r):""}catch(t){throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(f,".callFunction] invalid data")}))}h="functions.invokeFunction",p={inQuery:o,parse:a,search:c,function_name:n,request_data:l},d=this.request,m.label=1;case 1:return m.trys.push([1,3,,4]),[4,d.send(h,p)];case 2:if((y=m.sent()).code)return[2,u(e,null,y)];if(g=y.data.response_data,a)return[2,u(e,null,{result:g,requestId:y.requestId})];try{return g=JSON.parse(y.data.response_data),[2,u(e,null,{result:g,requestId:y.requestId})]}catch(t){u(e,new Error("[".concat(i(),"][").concat(s.INVALID_PARAMS,"][").concat(f,".callFunction] response data must be json")))}return[3,4];case 3:return v=m.sent(),u(e,v),[3,4];case 4:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,e){function i(t){try{u(a.next(t))}catch(t){e(t)}}function s(t){try{u(a.throw(t))}catch(t){e(t)}}function u(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(i,s)}u((a=a.apply(n,r||[])).next())}));var n,r,o,a},function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);i>3&&s&&Object.defineProperty(e,n,s)}([c({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(a)]}),o("design:type",Function),o("design:paramtypes",[Object,Function]),o("design:returntype",Promise)],t.prototype,"callFunction",null),t}()),h={name:f,entity:{callFunction:l.callFunction}};try{cloudbase.registerComponent(h)}catch(t){}function p(t){try{t.registerComponent(h)}catch(t){console.warn(t)}}},337:function(t,e,n){"use strict";n.r(e),n.d(e,{registerRealtime:function(){return F}});var r=n(880),o=n.n(r),i=n(373),s=n.n(i),a=n(907),u=n.n(a);function c(t){return void 0===t&&(t=""),"".concat(t?"".concat(t,"_"):"").concat(+new Date,"_").concat(Math.random())}var f,l,h=function(t){this.close=t.close,this.onChange=t.onChange,this.onError=t.onError,t.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return t.virtualClient}})},p=function(t){var e,n,r=t.id,o=t.docChanges,i=t.docs,s=t.msgType,a=t.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return e||(e=JSON.parse(JSON.stringify(o))),e},enumerable:!0},docs:{get:function(){return n||(n=JSON.parse(JSON.stringify(i))),n},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})},d=(f=function(t,e){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},f(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),y=function(t){function e(e){var n=t.call(this,"Watch Error ".concat(JSON.stringify(e.msgData)," (requestid: ").concat(e.requestId,")"))||this;return n.isRealtimeErrorMessageError=!0,n.payload=e,n}return d(e,t),e}(Error),g=function(t){return null==t?void 0:t.isRealtimeErrorMessageError},v=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="timeout",e.payload=null,e.generic=!0,e}return d(e,t),e}(Error),m=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="cancelled",e.payload=null,e.generic=!0,e}return d(e,t),e}(Error),w=function(t){function e(e){var n=t.call(this,e.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: ".concat(this.errCode," ").concat(b[this.errCode]||""," | errMsg: ").concat(this.errMsg)},set:function(t){this.errMsg=t}}}),n.errCode=e.errCode||"UNKNOWN_ERROR",n.errMsg=e.errMsg,n}return d(e,t),Object.defineProperty(e.prototype,"message",{get:function(){return"errCode: ".concat(this.errCode," | errMsg: ").concat(this.errMsg)},set:function(t){this.errMsg=t},enumerable:!1,configurable:!0}),e}(Error),b={UNKNOWN_ERROR:"UNKNOWN_ERROR",SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG:"SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG",SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA:"SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED",SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL",SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR:"SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR"},_=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},E=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},I=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},S=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};!function(t){t.LOGGINGIN="LOGGINGIN",t.INITING="INITING",t.REBUILDING="REBUILDING",t.ACTIVE="ACTIVE",t.ERRORED="ERRORED",t.CLOSING="CLOSING",t.CLOSED="CLOSED",t.PAUSED="PAUSED",t.RESUMING="RESUMING"}(l||(l={}));var O=function(){function t(t){var e=this;this.watchStatus=l.INITING,this.wsLogin=function(t,n){return E(e,void 0,void 0,(function(){var e;return I(this,(function(r){switch(r.label){case 0:return this.watchStatus=l.LOGGINGIN,[4,this.login(t,n)];case 1:return e=r.sent(),this.envId||(this.envId=e.envId),[2,e]}}))}))},this.initWatch=function(t){return E(e,void 0,void 0,(function(){var e,n=this;return I(this,(function(r){switch(r.label){case 0:if(null!==this.initWatchPromise&&void 0!==this.initWatchPromise)return[2,this.initWatchPromise];this.initWatchPromise=new Promise((function(e,r){E(n,void 0,void 0,(function(){var n,o,i,s,a,u,f,h,d,y;return I(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):[4,this.wsLogin(this.envId,t)];case 1:return n=g.sent().envId,this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):(this.watchStatus=l.INITING,o={watchId:this.watchId,requestId:c(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(i=g.sent(),s=i.msgData,a=s.events,u=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:u-1,currentDocs:[]},a.length>0){for(f=0,h=a;f<h.length;f++)h[f].ID=u;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=u,d=new p({id:u,docChanges:[],docs:[],type:"init"}),this.listener.onChange(d),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=l.ACTIVE,this.availableRetries.INIT_WATCH=2,e(),[3,4];case 3:return y=g.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:e,reject:r}),[3,4];case 4:return[2]}}))}))})),e=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return r.sent(),e=!0,[3,4];case 3:return this.initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch ".concat(e?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(t){return E(e,void 0,void 0,(function(){var e,n=this;return I(this,(function(r){switch(r.label){case 0:if(null!==this.rebuildWatchPromise&&void 0!==this.rebuildWatchPromise)return[2,this.rebuildWatchPromise];this.rebuildWatchPromise=new Promise((function(e,r){E(n,void 0,void 0,(function(){var n,o,i,s;return I(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):[4,this.wsLogin(this.envId,t)];case 1:if(n=a.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):(this.watchStatus=l.REBUILDING,o={watchId:this.watchId,requestId:c(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return i=a.sent(),this.handleServerEvents(i),this.watchStatus=l.ACTIVE,this.availableRetries.REBUILD_WATCH=2,e(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:e,reject:r}),[3,4];case 4:return[2]}}))}))})),e=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return r.sent(),e=!0,[3,4];case 3:return this.rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch ".concat(e?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(t,n){return E(e,void 0,void 0,(function(){var e,r,o,i=this;return I(this,(function(s){return e="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new w({errCode:e?b.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:b.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:t})),n.reject(t)},o=function(t){i.useRetryTicket(n.operationName)?e?(i.initWatchPromise=void 0,n.resolve(i.initWatch(t))):(i.rebuildWatchPromise=void 0,n.resolve(i.rebuildWatch(t))):r()},this.handleCommonError(t,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){E(i,void 0,void 0,(function(){var t,e=this;return I(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),t=function(){return E(e,void 0,void 0,(function(){return I(this,(function(t){switch(t.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return t.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,t()];case 1:return r.sent(),[3,7];case 2:return[4,_(100)];case 3:return r.sent(),this.watchStatus!==l.PAUSED?[3,4]:(n.reject(new m("".concat(n.operationName," cancelled due to pause after unknownError"))),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,t()];case 5:return r.sent(),[3,7];case 6:o(!1),r.label=7;case 7:return[3,9];case 8:return r.sent(),o(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return E(e,void 0,void 0,(function(){var t,e,n;return I(this,(function(r){switch(r.label){case 0:if(t=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==l.ACTIVE)return this.watchStatus=l.CLOSED,this.onWatchClose(this,t),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=l.CLOSING,e={watchId:this.watchId,requestId:c(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:e})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=l.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new w({errCode:b.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,t),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){e.clearACKSchedule(),e.ackTimeoutId=setTimeout((function(){e.waitExpectedTimeoutId?e.scheduleSendACK():e.sendACK()}),1e4)},this.clearACKSchedule=function(){e.ackTimeoutId&&clearTimeout(e.ackTimeoutId)},this.sendACK=function(){return E(e,void 0,void 0,(function(){var t,e,n;return I(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==l.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(t={watchId:this.watchId,requestId:c(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:t})]):(console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"),[2]);case 1:return r.sent(),this.scheduleSendACK(),[3,3];case 2:if(e=r.sent(),g(e))switch((n=e.payload).msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return this.rebuildWatch(),[2];case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":return this.closeWithError(new w({errCode:b.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:n.msgData.code})),[2]}return this.availableRetries.CHECK_LAST&&this.availableRetries.CHECK_LAST>0?(this.availableRetries.CHECK_LAST-=1,this.scheduleSendACK()):this.closeWithError(new w({errCode:b.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:e})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(t,e){if(g(t))switch(t.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void e.onSignError(t);default:return void e.onNotRetryableError(t)}else{if(function(t){return"timeout"===t.type}(t))return void e.onTimeoutError(t);if(function(t){return"cancelled"===t.type}(t))return void e.onCancelledError(t)}e.onUnknownError(t)},this.watchId="watchid_".concat(+new Date,"_").concat(Math.random()),this.envId=t.envId,this.collectionName=t.collectionName,this.query=t.query,this.limit=t.limit,this.orderBy=t.orderBy,this.send=t.send,this.login=t.login,this.isWSConnected=t.isWSConnected,this.onceWSConnected=t.onceWSConnected,this.getWaitExpectedTimeoutLength=t.getWaitExpectedTimeoutLength,this.onWatchStart=t.onWatchStart,this.onWatchClose=t.onWatchClose,this.debug=t.debug,this.availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new h({close:function(){e.closeWatch()},onChange:t.onChange,onError:t.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return t.prototype.onMessage=function(t){var e=this;switch(this.watchStatus){case l.PAUSED:if("ERROR"!==t.msgType)return;break;case l.LOGGINGIN:case l.INITING:case l.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while ".concat(this.watchStatus));case l.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case l.ERRORED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has ended with error")}if(this.sessionInfo)switch(this.scheduleSendACK(),t.msgType){case"NEXT_EVENT":console.warn("nextevent ".concat(t.msgData.currEvent," ignored"),t),this.handleServerEvents(t);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<t.msgData.currEvent&&(this.sessionInfo.expectEventId=t.msgData.currEvent,this.clearWaitExpectedEvent(),this.waitExpectedTimeoutId=setTimeout((function(){e.rebuildWatch()}),this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength ".concat(this.getWaitExpectedTimeoutLength())));break;case"ERROR":this.closeWithError(new w({errCode:b.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:"".concat(t.msgData.code," - ").concat(t.msgData.message)}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg ".concat(t.msgType,": "),t)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},t.prototype.closeWithError=function(t){var e;this.watchStatus=l.ERRORED,this.clearACKSchedule(),this.listener.onError(t),this.onWatchClose(this,(null===(e=this.sessionInfo)||void 0===e?void 0:e.queryID)||""),console.log("[realtime] client closed (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},t.prototype.pause=function(){this.watchStatus=l.PAUSED,console.log("[realtime] client paused (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},t.prototype.resume=function(){return E(this,void 0,void 0,(function(){var t;return I(this,(function(e){switch(e.label){case 0:this.watchStatus=l.RESUMING,console.log("[realtime] client resuming with ".concat(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH"," (").concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return e.sent(),console.log("[realtime] client successfully resumed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),[3,4];case 3:return t=e.sent(),console.error("[realtime] client resume failed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")"),t),[3,4];case 4:return[2]}}))}))},t.prototype.useRetryTicket=function(t){return!!(this.availableRetries[t]&&this.availableRetries[t]>0)&&(this.availableRetries[t]-=1,console.log("[realtime] ".concat(t," use a retry ticket, now only ").concat(this.availableRetries[t]," retry left")),!0)},t.prototype.handleServerEvents=function(t){return E(this,void 0,void 0,(function(){var e;return I(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(t)];case 1:return n.sent(),this.postHandleServerEventsValidityCheck(t),[3,3];case 2:throw e=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",e),e;case 3:return[2]}}))}))},t.prototype.handleServerEventsInternel=function(t){return E(this,void 0,void 0,(function(){var e,n,r,i,a,c,f,l,h,d,y,g;return I(this,(function(v){switch(v.label){case 0:if(e=t.requestId,n=t.msgData.events,r=t.msgType,!n.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=n.map(A)}catch(t){return this.closeWithError(new w({errCode:b.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:t})),[2]}c=S([],i.currentDocs,!0),f=!1,l=function(n,l){var d,y,g,v,m,_,E,O,A,T,N,R;return I(this,(function(I){switch(I.label){case 0:return d=a[n],i.currentEventId>=d.id?(!a[n-1]||d.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur ".concat(i.currentEventId," but got ").concat(d.id)):console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId ".concat(e,")")),[2,"continue"]):[3,1];case 1:if(i.currentEventId!==d.id-1)return[3,2];switch(d.dataType){case"update":if(!d.doc)switch(d.queueType){case"update":case"dequeue":if(y=c.find((function(t){return t._id===d.docId})),y){if(g=u()(y),d.updatedFields&&Object.keys(d.updatedFields).forEach((function(t){o()(g,t,d.updatedFields[t])})),d.removedFields)for(v=0,m=d.removedFields;v<m.length;v++)_=m[v],s()(g,_);d.doc=g}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw O=new w({errCode:b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '.concat(t.requestId,")")}),h.closeWithError(O),O}break;case"replace":if(!d.doc)throw O=new w({errCode:b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '.concat(t.requestId,")")}),h.closeWithError(O),O;break;case"remove":(E=c.find((function(t){return t._id===d.docId})))?d.doc=E:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!d.doc)switch(d.queueType){case"dequeue":(E=c.find((function(t){return t._id===d.docId})))?d.doc=E:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw O=new w({errCode:b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '.concat(t.requestId,")")}),h.closeWithError(O),O}}switch(d.queueType){case"init":f?c.push(d.doc):(f=!0,c=[d.doc]);break;case"enqueue":c.push(d.doc);break;case"dequeue":A=c.findIndex((function(t){return t._id===d.docId})),A>-1?c.splice(A,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":A=c.findIndex((function(t){return t._id===d.docId})),A>-1?c[A]=d.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===l-1||a[n+1]&&a[n+1].id!==d.id)&&(T=S([],c,!0),N=a.slice(0,n+1).filter((function(t){return t.id===d.id})),h.sessionInfo.currentEventId=d.id,h.sessionInfo.currentDocs=c,R=new p({id:d.id,docChanges:N,docs:T,msgType:r}),h.listener.onChange(R)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(h.sessionInfo.currentEventId," but got ").concat(d.id)),[4,h.rebuildWatch()];case 3:return I.sent(),[2,{value:void 0}];case 4:return[2]}}))},h=this,d=0,y=a.length,v.label=1;case 1:return d<y?[5,l(d,y)]:[3,4];case 2:if("object"==typeof(g=v.sent()))return[2,g.value];v.label=3;case 3:return d++,[3,1];case 4:return[2]}}))}))},t.prototype.postHandleServerEventsValidityCheck=function(t){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<t.msgData.currEvent&&console.warn("[realtime listener] internal non-fatal error: client eventId does not match with server event id after server event handling")):console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur")},t.prototype.clearWaitExpectedEvent=function(){this.waitExpectedTimeoutId&&(clearTimeout(this.waitExpectedTimeoutId),this.waitExpectedTimeoutId=void 0)},t}();function A(t){var e={id:t.ID,dataType:t.DataType,queueType:t.QueueType,docId:t.DocID,doc:t.Doc&&"{}"!==t.Doc?JSON.parse(t.Doc):void 0};return"update"===t.DataType&&(t.UpdatedFields&&(e.updatedFields=JSON.parse(t.UpdatedFields)),(t.removedFields||t.RemovedFields)&&(e.removedFields=JSON.parse(t.removedFields))),e}var T,N={1e3:{code:1e3,name:"Normal Closure",description:"Normal closure; the connection successfully completed whatever purpose for which it was created."},1001:{code:1001,name:"Going Away",description:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{code:1002,name:"Protocol Error",description:"The endpoint is terminating the connection due to a protocol error."},1003:{code:1003,name:"Unsupported Data",description:"The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)."},1005:{code:1005,name:"No Status Received",description:"Indicates that no status code was provided even though one was expected."},1006:{code:1006,name:"Abnormal Closure",description:"Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{code:1007,name:"Invalid frame payload data",description:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{code:1008,name:"Policy Violation",description:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{code:1009,name:"Message too big",description:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{code:1010,name:"Missing Extension",description:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{code:1011,name:"Internal Error",description:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{code:1012,name:"Service Restart",description:"The server is terminating the connection because it is restarting."},1013:{code:1013,name:"Try Again Later",description:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{code:1014,name:"Bad Gateway",description:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{code:1015,name:"TLS Handshake",description:"Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},3e3:{code:3e3,name:"Reconnect WebSocket",description:"The client is terminating the connection because it wants to reconnect"},3001:{code:3001,name:"No Realtime Listeners",description:"The client is terminating the connection because no more realtime listeners exist"},3002:{code:3002,name:"Heartbeat Ping Error",description:"The client is terminating the connection due to its failure in sending heartbeat messages"},3003:{code:3003,name:"Heartbeat Pong Timeout Error",description:"The client is terminating the connection because no heartbeat response is received from the server"},3050:{code:3050,name:"Server Close",description:"The client is terminating the connection because no heartbeat response is received from the server"}};!function(t){t[t.NormalClosure=1e3]="NormalClosure",t[t.GoingAway=1001]="GoingAway",t[t.ProtocolError=1002]="ProtocolError",t[t.UnsupportedData=1003]="UnsupportedData",t[t.NoStatusReceived=1005]="NoStatusReceived",t[t.AbnormalClosure=1006]="AbnormalClosure",t[t.InvalidFramePayloadData=1007]="InvalidFramePayloadData",t[t.PolicyViolation=1008]="PolicyViolation",t[t.MessageTooBig=1009]="MessageTooBig",t[t.MissingExtension=1010]="MissingExtension",t[t.InternalError=1011]="InternalError",t[t.ServiceRestart=1012]="ServiceRestart",t[t.TryAgainLater=1013]="TryAgainLater",t[t.BadGateway=1014]="BadGateway",t[t.TLSHandshake=1015]="TLSHandshake",t[t.ReconnectWebSocket=3e3]="ReconnectWebSocket",t[t.NoRealtimeListeners=3001]="NoRealtimeListeners",t[t.HeartbeatPingError=3002]="HeartbeatPingError",t[t.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",t[t.NoAuthentication=3050]="NoAuthentication"}(T||(T={}));var R=function(t,e){var n=N[t],r=n?"".concat(n.name,", code ").concat(t,", reason ").concat(e||n.description):"code ".concat(t);return new w({errCode:b.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},C=null,x="web";function L(){return C}function P(){return x}function U(t){x=t}var D=function(){return D=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},D.apply(this,arguments)},j=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},k=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},M=function(){function t(t){var e=this;this.virtualWSClient=new Set,this.queryIdClientMap=new Map,this.watchIdClientMap=new Map,this.pingFailed=0,this.pongMissed=0,this.logins=new Map,this.wsReadySubsribers=[],this.wsResponseWait=new Map,this.rttObserved=[],this.send=function(t){return j(e,void 0,void 0,(function(){var e=this;return k(this,(function(n){return[2,new Promise((function(n,r){j(e,void 0,void 0,(function(){var e,o,i,s,a,u,c,f,l=this;return k(this,(function(h){switch(h.label){case 0:o=!1,i=!1,s=function(t){o=!0,e&&clearTimeout(e),n(t)},a=function(t){i=!0,e&&clearTimeout(e),r(t)},t.timeout&&(e=setTimeout((function(){j(l,void 0,void 0,(function(){return k(this,(function(t){switch(t.label){case 0:return o&&i?[3,2]:[4,_(0)];case 1:t.sent(),o&&i||a(new v("wsclient.send timedout")),t.label=2;case 2:return[2]}}))}))}),t.timeout)),h.label=1;case 1:return h.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:h.sent(),h.label=3;case 3:if(!this.ws)return a(new Error("invalid state: ws connection not exists, can not send message")),[2];if(1!==this.ws.readyState)return a(new Error("ws readyState invalid: ".concat(this.ws.readyState,", can not send message"))),[2];t.waitResponse&&(u={resolve:s,reject:a,skipOnMessage:t.skipOnMessage},this.wsResponseWait.set(t.msg.requestId,u)),h.label=4;case 4:return h.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(t.msg))];case 5:return h.sent(),t.waitResponse||s(void 0),[3,7];case 6:return(c=h.sent())&&(a(c),t.waitResponse&&this.wsResponseWait.delete(t.msg.requestId)),[3,7];case 7:return[3,9];case 8:return f=h.sent(),a(f),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(t){e.virtualWSClient.forEach((function(e){e.closeWithError(t)}))},this.pauseClients=function(t){(t||e.virtualWSClient).forEach((function(t){t.pause()}))},this.resumeClients=function(t){(t||e.virtualWSClient).forEach((function(t){t.resume()}))},this.initWebSocketConnection=function(t,n){return void 0===n&&(n=e.maxReconnect),j(e,void 0,void 0,(function(){var e=this;return k(this,(function(r){switch(r.label){case 0:if(t&&this.reconnectState)return[2];if(t&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];t&&this.pauseClients(),this.close(T.ReconnectWebSocket),this.wsInitPromise=new Promise((function(r,o){j(e,void 0,void 0,(function(){var e,i,s=this;return k(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return e=a.sent(),[4,new Promise((function(t){var n=e.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=L();s.ws=r?new r(n):new WebSocket(n),t(void 0)}))];case 2:return a.sent(),this.ws.connect?[4,this.ws.connect()]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return a.sent(),r(),t&&(this.resumeClients(),this.reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),n>0?(this.wsInitPromise=void 0,[4,_(this.reconnectInterval)]):[3,9];case 7:a.sent(),t&&(this.reconnectState=!1),a.label=8;case 8:return r(this.initWebSocketConnection(t,n-1)),[3,10];case 9:o(i),t&&this.closeAllClients(new w({errCode:b.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:i})),a.label=10;case 10:return[3,11];case 11:return[2]}}))}))})),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this.wsInitPromise];case 2:return r.sent(),this.wsReadySubsribers.forEach((function(t){return(0,t.resolve)()})),[3,5];case 3:return r.sent(),this.wsReadySubsribers.forEach((function(t){return(0,t.reject)()})),[3,5];case 4:return this.wsInitPromise=void 0,this.wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(t,n){if(!e.ws)throw new Error("can not initWebSocketEvent, ws not exists");var r=!1;e.ws.onopen=function(e){console.warn("[realtime] ws event: open",e),r=!0,t()},e.ws.onerror=function(t){e.logins=new Map,r?(console.error("[realtime] ws event: error",t),e.clearHeartbeat(),e.virtualWSClient.forEach((function(e){return e.closeWithError(new w({errCode:b.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:t}))}))):(console.error("[realtime] ws open failed with ws event: error",t),n(t))},e.ws.onclose=function(t){switch(console.warn("[realtime] ws event: close",t),e.logins=new Map,e.clearHeartbeat(),t.code){case T.ReconnectWebSocket:case T.NoRealtimeListeners:break;case T.HeartbeatPingError:case T.HeartbeatPongTimeoutError:case T.NormalClosure:case T.AbnormalClosure:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients(R(t.code));break;case T.NoAuthentication:e.closeAllClients(R(t.code,t.reason));break;default:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients(R(t.code))}},e.ws.onmessage=function(t){var n,r=t.data;e.heartbeat();try{n=JSON.parse(r)}catch(t){throw new Error("[realtime] onMessage parse res.data error: ".concat(t))}if("ERROR"===n.msgType){var o=null;e.virtualWSClient.forEach((function(t){t.watchId===n.watchId&&(o=t)})),o&&o.listener.onError(n)}var i=e.wsResponseWait.get(n.requestId);if(i){try{"ERROR"===n.msgType?i.reject(new y(n)):i.resolve(n)}catch(t){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",t)}finally{e.wsResponseWait.delete(n.requestId)}if(i.skipOnMessage)return}if("PONG"!==n.msgType){var s=n.watchId&&e.watchIdClientMap.get(n.watchId);if(s)s.onMessage(n);else switch(console.error("[realtime] no realtime listener found responsible for watchId ".concat(n.watchId,": "),n),n.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(s=e.queryIdClientMap.get(n.msgData.queryID))&&s.onMessage(n);break;default:for(var a=0,u=Array.from(e.watchIdClientMap.entries());a<u.length;a++){u[a][1].onMessage(n);break}}}else if(e.lastPingSendTS){var c=Date.now()-e.lastPingSendTS;if(c>1e4)return void console.warn("[realtime] untrusted rtt observed: ".concat(c));e.rttObserved.length>=3&&e.rttObserved.splice(0,e.rttObserved.length-3+1),e.rttObserved.push(c)}},e.heartbeat()}))},this.isWSConnected=function(){return Boolean(e.ws&&1===e.ws.readyState)},this.onceWSConnected=function(){return j(e,void 0,void 0,(function(){var t=this;return k(this,(function(e){return this.isWSConnected()?[2]:null!==this.wsInitPromise&&void 0!==this.wsInitPromise?[2,this.wsInitPromise]:[2,new Promise((function(e,n){t.wsReadySubsribers.push({resolve:e,reject:n})}))]}))}))},this.webLogin=function(t,n){return j(e,void 0,void 0,(function(){var e,r,o,i,s,a,u,f,l=this;return k(this,(function(h){switch(h.label){case 0:if(!n)if(t){if(e=this.logins.get(t)){if(e.loggedIn&&e.loginResult)return[2,e.loginResult];if(null!==e.loggingInPromise&&void 0!==e.loggingInPromise)return[2,e.loggingInPromise]}}else if(null!==(null==(r=this.logins.get(""))?void 0:r.loggingInPromise)&&void 0!==(null==r?void 0:r.loggingInPromise))return[2,r.loggingInPromise];o=new Promise((function(t,e){j(l,void 0,void 0,(function(){var n,r,o,i,s;return k(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return n=a.sent(),r={envId:n.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:c(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:P(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(i=a.sent()).msgData.code?e(new Error("".concat(i.msgData.code," ").concat(i.msgData.message))):t({envId:n.envId}),[3,4];case 3:return s=a.sent(),e(s),[3,4];case 4:return[2]}}))}))})),i=t&&this.logins.get(t),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this.logins.set(t||"",i)),h.label=1;case 1:return h.trys.push([1,3,,4]),[4,o];case 2:if(a=h.sent(),(u=t&&this.logins.get(t))&&u===i&&u.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(u){if(u.loggedIn&&u.loginResult)return[2,u.loginResult];if(null!==u.loggingInPromise&&void 0!==u.loggingInPromise)return[2,u.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw f=h.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,f;case 4:return[2]}}))}))},this.getWsSign=function(){return j(e,void 0,void 0,(function(){var t,e,n,r,o,i,s;return k(this,(function(a){switch(a.label){case 0:return this.wsSign&&this.wsSign.expiredTs>Date.now()?[2,this.wsSign]:(t=Date.now()+6e4,[4,this.context.appConfig.request.send("auth.wsWebSign",{runtime:P()})]);case 1:if((e=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: ".concat(e.code));if(e.data)return n=e.data,r=n.signStr,o=n.wsUrl,i=n.secretVersion,s=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:i,envId:s,expiredTs:t}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return e.rttObserved.length?e.rttObserved.reduce((function(t,e){return t+e}))/e.rttObserved.length*1.5:5e3},this.ping=function(){return j(e,void 0,void 0,(function(){var t;return k(this,(function(e){switch(e.label){case 0:return t={watchId:void 0,requestId:c(),msgType:"PING",msgData:null},[4,this.send({msg:t})];case 1:return e.sent(),[2]}}))}))},this.onWatchStart=function(t,n){e.queryIdClientMap.set(n,t)},this.onWatchClose=function(t,n){n&&e.queryIdClientMap.delete(n),e.watchIdClientMap.delete(t.watchId),e.virtualWSClient.delete(t),e.virtualWSClient.size||e.close(T.NoRealtimeListeners)},this.maxReconnect=t.maxReconnect||5,this.reconnectInterval=t.reconnectInterval||1e4,this.context=t.context}return t.prototype.clearHeartbeat=function(){this.pingTimeoutId&&clearTimeout(this.pingTimeoutId),this.pongTimeoutId&&clearTimeout(this.pongTimeoutId)},t.prototype.close=function(t){this.clearHeartbeat(),this.ws&&(this.ws.close(t,N[t].name),this.ws=void 0)},t.prototype.watch=function(t){this.ws||void 0!==this.wsInitPromise&&null!==this.wsInitPromise||this.initWebSocketConnection(!1);var e=new O(D(D({},t),{send:this.send,login:this.webLogin,isWSConnected:this.isWSConnected,onceWSConnected:this.onceWSConnected,getWaitExpectedTimeoutLength:this.getWaitExpectedTimeoutLength,onWatchStart:this.onWatchStart,onWatchClose:this.onWatchClose,debug:!0}));return this.virtualWSClient.add(e),this.watchIdClientMap.set(e.watchId,e),e.listener},t.prototype.heartbeat=function(t){var e=this;this.clearHeartbeat(),this.pingTimeoutId=setTimeout((function(){j(e,void 0,void 0,(function(){var t=this;return k(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),this.ws&&1===this.ws.readyState?(this.lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return e.sent(),this.pingFailed=0,this.pongTimeoutId=setTimeout((function(){console.error("pong timed out"),t.pongMissed<2?(t.pongMissed+=1,t.heartbeat(!0)):t.initWebSocketConnection(!0)}),this.context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return e.sent(),this.pingFailed<2?(this.pingFailed+=1,this.heartbeat()):this.close(T.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),t?0:this.context.appConfig.realtimePingInterval)},t}(),B={target:"database",entity:function(){var t,e=this.platform,n=e.adapter,r=e.runtime;t=n.wsClass,C=t,U(r)}},q={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=M}};try{cloudbase.registerComponent(q),cloudbase.registerHook(B)}catch(t){}function F(t){try{t.registerComponent(q),t.registerHook(B)}catch(t){console.warn(t)}}},766:function(t,e,n){"use strict";n.r(e),n.d(e,{registerStorage:function(){return _}});var r,o=n(142),i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},a=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},u=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},c=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};!function(t){t.put="put",t.post="post"}(r||(r={}));var f=o._G.eX,l=o._G.Sg,h=o._G.vM,p=o.P6.kJ,d=o.P6.HD,y=o.P6.JV,g=o.P6.Gc,v=o.BM.D,m="storage",w=new(function(){function t(){}return t.prototype.uploadFile=function(t,e){return u(this,void 0,void 0,(function(){var n,o,s,a,u,h,p,y,v,w,b,_,E,I,S,O,A,T,N,R,C,x,L,P,U;return c(this,(function(c){switch(c.label){case 0:if(n=t.cloudPath,o=t.filePath,s=t.onUploadProgress,a=t.method,u=void 0===a?"put":a,h=t.headers,p=void 0===h?{}:h,!d(n)||!o)throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[".concat(m,".uploadFile] invalid params")}));return y={put:r.put,post:r.post}[u.toLocaleLowerCase()]||r.put,v=this.request,w={path:n,method:y},y===r.put&&(w.headers=p),[4,v.send("storage.getUploadMetadata",w)];case 1:return b=c.sent(),_=b.data,E=_.url,I=_.authorization,S=_.token,O=_.fileId,A=_.cosFileId,T=_.download_url,N=b.requestId,C=i(i({},R={url:E,file:o,name:n,onUploadProgress:s}),{method:r.put,headers:i(i({},p),{authorization:I,"x-cos-meta-fileid":A,"x-cos-security-token":S})}),x=i(i({},R),{method:r.post,data:{key:n,signature:I,"x-cos-meta-fileid":A,success_action_status:"201","x-cos-security-token":S}}),(U={})[r.put]={params:C,isSuccess:function(t){return t>=200&&t<300}},U[r.post]={params:x,isSuccess:function(t){return 201===t}},L=U,[4,v.upload(L[y].params)];case 2:return P=c.sent(),L[y].isSuccess(P.statusCode)?[2,g(e,null,{fileID:O,download_url:T,requestId:N})]:[2,g(e,new Error("[".concat(f(),"][").concat(l.OPERATION_FAIL,"][").concat(m,"]:").concat(P.data)))]}}))}))},t.prototype.getUploadMetadata=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s;return c(this,(function(a){switch(a.label){case 0:if(n=t.cloudPath,!d(n))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[".concat(m,".getUploadMetadata] invalid cloudPath")}));r=this.request,o="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.send(o,{path:n})];case 2:return i=a.sent(),[2,g(e,null,i)];case 3:return s=a.sent(),[2,g(e,s)];case 4:return[2]}}))}))},t.prototype.deleteFile=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(!(n=t.fileList)||!p(n)||0===n.length)throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[".concat(m,".deleteFile] fileList must not be empty")}));for(r=0,o=n;r<o.length;r++)if(!(i=o[r])||!d(i))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[".concat(m,".deleteFile] fileID must be string")}));return[4,this.request.send("storage.batchDeleteFile",{fileid_list:n})];case 1:return(s=u.sent()).code?[2,g(e,null,s)]:(a={fileList:s.data.delete_list,requestId:s.requestId},[2,g(e,null,a)])}}))}))},t.prototype.getTempFileURL=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(!(n=t.fileList)||!p(n)||0===n.length)throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[".concat(m,".getTempFileURL] fileList must not be empty")}));for(r=[],o=0,i=n;o<i.length;o++)if(s=i[o],y(s)){if(!Object.prototype.hasOwnProperty.call(s,"fileID")||!Object.prototype.hasOwnProperty.call(s,"maxAge"))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[".concat(m,".getTempFileURL] file info must include fileID and maxAge")}));r.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!d(s))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[".concat(m,".getTempFileURL] invalid fileList")}));r.push({fileid:s})}return[4,this.request.send("storage.batchGetDownloadUrl",{file_list:r})];case 1:return(a=u.sent()).code?[2,g(e,null,a)]:[2,g(e,null,{fileList:a.data.download_list,requestId:a.requestId})]}}))}))},t.prototype.downloadFile=function(t,e){return u(this,void 0,void 0,(function(){var n,r,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(n=t.fileID,!d(n))throw new Error(JSON.stringify({code:l.INVALID_PARAMS,msg:"[".concat(m,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}]})];case 1:return r=u.sent(),"SUCCESS"!==(o=r.fileList[0]).code?[2,g(e,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return a=u.sent(),[2,g(e,null,a)]}}))}))},s([v({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"uploadFile",null),s([v({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"getUploadMetadata",null),s([v({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"deleteFile",null),s([v({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"getTempFileURL",null),s([v({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"downloadFile",null),t}()),b={name:m,entity:{uploadFile:w.uploadFile,deleteFile:w.deleteFile,getTempFileURL:w.getTempFileURL,downloadFile:w.downloadFile,getUploadMetadata:w.getUploadMetadata}};try{cloudbase.registerComponent(b)}catch(t){}function _(t){try{t.registerComponent(b)}catch(t){console.warn(t)}}},142:function(t,e,n){"use strict";n.d(e,{j$:function(){return i},Fs:function(){return s},_G:function(){return r},U3:function(){return a},BM:function(){return u},P6:function(){return o}});var r={};n.r(r),n.d(r,{vM:function(){return y},Sg:function(){return g},Fk:function(){return d},eX:function(){return l},pM:function(){return p},tC:function(){return f}});var o={};n.r(o),n.d(o,{Gc:function(){return A},CN:function(){return S},Jc:function(){return I},kJ:function(){return m},hp:function(){return E},V9:function(){return _},JV:function(){return b},HD:function(){return w},Jz:function(){return R},xe:function(){return T},_y:function(){return N},UK:function(){return O}});var i={};n.r(i),n.d(i,{Fk:function(){return D},xY:function(){return j}});var s={};n.r(s),n.d(s,{q:function(){return F}});var a={};n.r(a),n.d(a,{yE:function(){return V}});var u={};n.r(u),n.d(u,{D:function(){return Q}});var c="@cloudbase/js-sdk";function f(t){c=t}function l(){return c}var h="https:";function p(t){h=t}var d=!1,y="https://support.qq.com/products/148793",g={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"},v=n(829);function m(t){return"[object Array]"===Object.prototype.toString.call(t)}function w(t){return"string"==typeof t}function b(t){return"[object Object]"===Object.prototype.toString.call(t)}function _(t,e){return t instanceof e}function E(t){return"[object FormData]"===Object.prototype.toString.call(t)}function I(){return Math.random().toString(16).slice(2)}function S(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";return Object.keys(n).forEach((function(t){""===o?!r&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(n[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)}function O(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(n){e.push("".concat(n,"=").concat(encodeURIComponent(t[n])))})),e.join("&")}function A(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n}function T(t,e){console.warn("[".concat(l(),"][").concat(t,"]:").concat(e))}function N(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat(l(),"][").concat(t,"]:").concat(e)}))}function R(t){var e=t.title,n=t.subtitle,r=void 0===n?"":n,o=t.content,i=void 0===o?[]:o,s=t.printTrace,a=void 0!==s&&s,u=t.collapsed;void 0!==u&&u?console.groupCollapsed(e,r):console.group(e,r);for(var c=0,f=i;c<f.length;c++){var l=f[c],h=l.type,p=l.body;switch(h){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}a&&console.trace("stack trace:"),console.groupEnd()}n(61),n(139),n(307);var C,x,L=(C=function(t,e){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},C(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}C(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),P=function(){return P=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},P.apply(this,arguments)},U=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return L(e,t),e.prototype.get=function(t){return this.request(P(P({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(P(P({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(P(P({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,o=t.method,i=t.headers,s=void 0===i?{}:i,a={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===a?(Object.keys(e).forEach((function(t){u.append(t,e[t])})),u.append("key",r),u.append("file",n),this.request(P(P({},t),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request(P(P({},t),{method:"put",headers:s,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return e=this,n=void 0,o=function(){var e,n,r,o;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(P(P({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))},new((r=void 0)||(r=Promise))((function(t,i){function s(t){try{u(o.next(t))}catch(t){i(t)}}function a(t){try{u(o.throw(t))}catch(t){i(t)}}function u(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(s,a)}u((o=o.apply(e,n||[])).next())}));var e,n,r,o},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,u=t.headers,c=void 0===u?{}:u,f=t.data,l=t.responseType,p=t.withCredentials,d=t.body,y=t.onUploadProgress,g=S(h,a,"get"===r?f:{}),v=new XMLHttpRequest;v.open(r,g),l&&(v.responseType=l),Object.keys(c).forEach((function(t){v.setRequestHeader(t,c[t])})),y&&v.upload.addEventListener("progress",y),v.onreadystatechange=function(){var t={};if(4===v.readyState){var e=v.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o})),t.header=n,t.statusCode=v.status;try{t.data="blob"===l?v.response:JSON.parse(v.responseText)}catch(e){t.data="blob"===l?v.response:v.responseText}clearTimeout(i),o(t)}},e&&n.timeout&&(i=setTimeout((function(){console.warn(n.timeoutMsg),v.abort()}),n.timeout)),s=E(f)?f:"application/x-www-form-urlencoded"===c["content-type"]?O(f):d||(f?JSON.stringify(f):void 0),p&&(v.withCredentials=!0),v.send(s)}))},e}(v.jJ);function D(t){for(var e=0,n=m(t)?t:[t];e<n.length;e++){var r=n[e],o=r.isMatch,i=r.genAdapter,s=r.runtime;if(o())return{adapter:i(),runtime:s}}}function j(){return{adapter:{root:window,reqClass:U,wsClass:WebSocket,localStorage:localStorage},runtime:x.WEB}}!function(t){t.WEB="web",t.WX_MP="wx_mp"}(x||(x={}));var k=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),M=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},B=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},q=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return k(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(v.x_),F=function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,o=t.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:(T(g.INVALID_PARAMS,"localStorage is not supported on current platform"),new q(e.root));case"none":return new q(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:g.OPERATION_FAIL,msg:"[".concat(l(),"][").concat(g.OPERATION_FAIL,"]setStore failed"),info:t}))}}else T(g.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return M(this,void 0,void 0,(function(){var r;return B(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){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(t){return""}e=e||"localCachev1";var r=this.storage.getItem(t);return r&&r.indexOf(e)>=0?JSON.parse(r).content:""}T(g.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return M(this,void 0,void 0,(function(){var r;return B(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(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(r=o.sent())&&r.indexOf(e)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):T(g.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return M(this,void 0,void 0,(function(){return B(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}(),W=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),$=function(t,e){this.data=e||null,this.name=t},H=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return W(e,t),e}($),V=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(_(t,H))return console.error(t.error),this;var n=w(t)?new $(t,e||{}):t,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,i=this.listeners[r]?function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}([],this.listeners[r],!0):[];o<i.length;o++)i[o].call(this,n)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new V;var G=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},J=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){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=(o=s.trys).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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},K=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(K=-1!==navigator.userAgent.indexOf("Firefox"));var Y=K?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,z=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function Q(t){var e=t.mode,n=void 0===e?"async":e,r=t.customInfo,o=void 0===r?{}:r,i=t.title,s=t.messages,a=void 0===s?[]:s;return function(t,e,r){if(d){var s=o.className||t.constructor.name,u=o.methodName||e,c=r.value,f=function(t){var e="",n=(new Error).stack.split("\n"),r=n.findIndex((function(t){return Y.test(t)}));if(-1!==r){var o=z.exec(n[r+1]||"");e=o?o[0]:""}return e}();r.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=X({err:new Error,className:s,methodName:u,sourceLink:f});try{return c.apply(this,t)}catch(t){var r=t,o=t.message,l=t.error,h=t.error_description,p={title:i||"".concat(s,".").concat(u," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var d=JSON.parse(o);p.subtitle=o,d.code&&(n?(n.code=d.code,n.msg=d.msg):(t.code=d.code,t.message=d.msg),r=n||t,p.content=a.map((function(t){return{type:"info",body:t}})))}throw l&&h&&(p.subtitle=h,n?(n.code=l,n.msg=h):(t.code=l,t.message=h),r=n||t,p.content=a.map((function(t){return{type:"info",body:t}}))),R(p),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return G(this,void 0,void 0,(function(){var e,n,r,o,l,h,p,d;return J(this,(function(y){switch(y.label){case 0:e=X({err:new Error,className:s,methodName:u,sourceLink:f}),y.label=1;case 1:return y.trys.push([1,3,,4]),[4,c.apply(this,t)];case 2:return[2,y.sent()];case 3:throw n=y.sent(),r=n,o=n.message,l=n.error,h=n.error_description,p={title:i||"".concat(s,".").concat(u," failed"),content:[{type:"error",body:n}]},o&&/^\{.*\}$/.test(o)&&(d=JSON.parse(o),p.subtitle=d,d.code&&(e?(e.code=d.code,e.message=d.msg):(n.code=d.code,n.message=d.msg),r=e||n,p.content=a.map((function(t){return{type:"info",body:t}})))),l&&h&&(p.subtitle=h,e?(e.code=l,e.msg=h):(n.code=l,n.message=h),r=e||n,p.content=a.map((function(t){return{type:"info",body:t}}))),R(p),r;case 4:return[2]}}))}))}}}}function X(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),a=K?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),u=K?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),c=s.findIndex((function(t){return a.test(t)}));if(-1!==c){var f=s.filter((function(t,e){return e>c}));f.unshift(s[c].replace(u,"".concat(n,".").concat(r)).replace(z,o)),(i=new Error).stack="".concat(K?"@debugger":"Error","\n").concat(f.join("\n"))}return i}function Z(t){this.message=t}function tt(t){this.message=t}Z.prototype=new Error,Z.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),tt.prototype=new Error,tt.prototype.name="InvalidTokenError"},359:function(t,e,n){var r;t.exports=(r=r||function(t,e){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(r=globalThis.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==n.g&&n.g.crypto&&(r=n.g.crypto),!r)try{r=n(633)}catch(t){}var o=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}}(),s={},a=s.lib={},u=a.Base={extend:function(t){var e=i(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},c=a.WordArray=u.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||l).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;e[r+i>>>2]|=s<<24-(r+i)%4*8}else for(var a=0;a<o;a+=4)e[r+a>>>2]=n[a>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=u.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],n=0;n<t;n+=4)e.push(o());return new c.init(e,t)}}),f=s.enc={},l=f.Hex={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new c.init(n,e/2)}},h=f.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r++)n[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new c.init(n,e)}},p=f.Utf8={stringify:function(t){try{return decodeURIComponent(escape(h.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return h.parse(unescape(encodeURIComponent(t)))}},d=a.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=p.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n,r=this._data,o=r.words,i=r.sigBytes,s=this.blockSize,a=i/(4*s),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*s,f=t.min(4*u,i);if(u){for(var l=0;l<u;l+=s)this._doProcessBlock(o,l);n=o.splice(0,u),r.sigBytes-=f}return new c.init(n,f)},clone:function(){var t=u.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),y=(a.Hasher=d.extend({cfg:u.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,n){return new t.init(n).finalize(e)}},_createHmacHelper:function(t){return function(e,n){return new y.HMAC.init(t,n).finalize(e)}}}),s.algo={});return s}(Math),r)},139:function(t,e,n){var r,o,i;t.exports=(r=n(359),i=(o=r).lib.WordArray,o.enc.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp();for(var o=[],i=0;i<n;i+=3)for(var s=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a<n;a++)o.push(r.charAt(s>>>6*(3-a)&63));var u=r.charAt(64);if(u)for(;o.length%4;)o.push(u);return o.join("")},parse:function(t){var e=t.length,n=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var o=0;o<n.length;o++)r[n.charCodeAt(o)]=o}var s=n.charAt(64);if(s){var a=t.indexOf(s);-1!==a&&(e=a)}return function(t,e,n){for(var r=[],o=0,s=0;s<e;s++)if(s%4){var a=n[t.charCodeAt(s-1)]<<s%4*2|n[t.charCodeAt(s)]>>>6-s%4*2;r[o>>>2]|=a<<24-o%4*8,o++}return i.create(r,o)}(t,e,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},r.enc.Base64)},307:function(t,e,n){t.exports=n(359).enc.Utf8},61:function(t,e,n){var r;t.exports=(r=n(359),n(93),n(423),r.HmacSHA256)},423:function(t,e,n){var r,o,i;t.exports=(o=(r=n(359)).lib.Base,i=r.enc.Utf8,void(r.algo.HMAC=o.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=i.parse(e));var n=t.blockSize,r=4*n;e.sigBytes>r&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),s=this._iKey=e.clone(),a=o.words,u=s.words,c=0;c<n;c++)a[c]^=1549556828,u[c]^=909522486;o.sigBytes=s.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,n=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(n))}})))},93:function(t,e,n){var r;t.exports=(r=n(359),function(t){var e=r,n=e.lib,o=n.WordArray,i=n.Hasher,s=e.algo,a=[],u=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)e(r)&&(o<8&&(a[o]=n(t.pow(r,.5))),u[o]=n(t.pow(r,1/3)),o++),r++}();var c=[],f=s.SHA256=i.extend({_doReset:function(){this._hash=new o.init(a.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],a=n[4],f=n[5],l=n[6],h=n[7],p=0;p<64;p++){if(p<16)c[p]=0|t[e+p];else{var d=c[p-15],y=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=c[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;c[p]=y+c[p-7]+v+c[p-16]}var m=r&o^r&i^o&i,w=(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)+u[p]+c[p];h=l,l=f,f=a,a=s+b|0,s=i,i=o,o=r,r=b+(w+m)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+f|0,n[6]=n[6]+l|0,n[7]=n[7]+h|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,o=8*e.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=t.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=i._createHelper(f),e.HmacSHA256=i._createHmacHelper(f)}(Math),r.SHA256)},907:function(t,e,n){t=n.nmd(t);var r="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",s="[object Boolean]",a="[object Date]",u="[object Function]",c="[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]",w="[object ArrayBuffer]",b="[object DataView]",_="[object Float32Array]",E="[object Float64Array]",I="[object Int8Array]",S="[object Int16Array]",O="[object Int32Array]",A="[object Uint8Array]",T="[object Uint8ClampedArray]",N="[object Uint16Array]",R="[object Uint32Array]",C=/\w*$/,x=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,P={};P[i]=P["[object Array]"]=P[w]=P[b]=P[s]=P[a]=P[_]=P[E]=P[I]=P[S]=P[O]=P[f]=P[l]=P[h]=P[d]=P[y]=P[g]=P[v]=P[A]=P[T]=P[N]=P[R]=!0,P["[object Error]"]=P[u]=P[m]=!1;var U="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,D="object"==typeof self&&self&&self.Object===Object&&self,j=U||D||Function("return this")(),k=e&&!e.nodeType&&e,M=k&&t&&!t.nodeType&&t,B=M&&M.exports===k;function q(t,e){return t.set(e[0],e[1]),t}function F(t,e){return t.add(e),t}function W(t,e,n,r){var o=-1,i=t?t.length:0;for(r&&i&&(n=t[++o]);++o<i;)n=e(n,t[o],o,t);return n}function $(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function H(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function V(t,e){return function(n){return t(e(n))}}function G(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}var J,K=Array.prototype,Y=Function.prototype,z=Object.prototype,Q=j["__core-js_shared__"],X=(J=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+J:"",Z=Y.toString,tt=z.hasOwnProperty,et=z.toString,nt=RegExp("^"+Z.call(tt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=B?j.Buffer:void 0,ot=j.Symbol,it=j.Uint8Array,st=V(Object.getPrototypeOf,Object),at=Object.create,ut=z.propertyIsEnumerable,ct=K.splice,ft=Object.getOwnPropertySymbols,lt=rt?rt.isBuffer:void 0,ht=V(Object.keys,Object),pt=jt(j,"DataView"),dt=jt(j,"Map"),yt=jt(j,"Promise"),gt=jt(j,"Set"),vt=jt(j,"WeakMap"),mt=jt(Object,"create"),wt=Ft(pt),bt=Ft(dt),_t=Ft(yt),Et=Ft(gt),It=Ft(vt),St=ot?ot.prototype:void 0,Ot=St?St.valueOf:void 0;function At(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Tt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Nt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Rt(t){this.__data__=new Tt(t)}function Ct(t,e,n){var r=t[e];tt.call(t,e)&&Wt(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function xt(t,e){for(var n=t.length;n--;)if(Wt(t[n][0],e))return n;return-1}function Lt(t,e,n,r,o,p,m){var x;if(r&&(x=p?r(t,o,p,m):r(t)),void 0!==x)return x;if(!Jt(t))return t;var L=$t(t);if(L){if(x=function(t){var e=t.length,n=t.constructor(e);return e&&"string"==typeof t[0]&&tt.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!e)return function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(t,x)}else{var U=Mt(t),D=U==u||U==c;if(Vt(t))return function(t,e){if(e)return t.slice();var n=new t.constructor(t.length);return t.copy(n),n}(t,e);if(U==h||U==i||D&&!p){if($(t))return p?t:{};if(x=function(t){return"function"!=typeof t.constructor||qt(t)?{}:Jt(e=st(t))?at(e):{};var e}(D?{}:t),!e)return function(t,e){return Ut(t,kt(t),e)}(t,function(t,e){return t&&Ut(e,Kt(e),t)}(x,t))}else{if(!P[U])return p?t:{};x=function(t,e,n,r){var o,i=t.constructor;switch(e){case w:return Pt(t);case s:case a:return new i(+t);case b:return function(t,e){var n=e?Pt(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,r);case _:case E:case I:case S:case O:case A:case T:case N:case R:return function(t,e){var n=e?Pt(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}(t,r);case f:return function(t,e,n){return W(e?n(H(t),!0):H(t),q,new t.constructor)}(t,r,n);case l:case g:return new i(t);case d:return function(t){var e=new t.constructor(t.source,C.exec(t));return e.lastIndex=t.lastIndex,e}(t);case y:return function(t,e,n){return W(e?n(G(t),!0):G(t),F,new t.constructor)}(t,r,n);case v:return o=t,Ot?Object(Ot.call(o)):{}}}(t,U,Lt,e)}}m||(m=new Rt);var j=m.get(t);if(j)return j;if(m.set(t,x),!L)var k=n?function(t){return function(t,e,n){var r=e(t);return $t(t)?r:function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}(r,n(t))}(t,Kt,kt)}(t):Kt(t);return function(t,e){for(var n=-1,r=t?t.length:0;++n<r&&!1!==e(t[n],n););}(k||t,(function(o,i){k&&(o=t[i=o]),Ct(x,i,Lt(o,e,n,r,i,t,m))})),x}function Pt(t){var e=new t.constructor(t.byteLength);return new it(e).set(new it(t)),e}function Ut(t,e,n,r){n||(n={});for(var o=-1,i=e.length;++o<i;){var s=e[o],a=r?r(n[s],t[s],s,n,t):void 0;Ct(n,s,void 0===a?t[s]:a)}return n}function Dt(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function jt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!Jt(t)||(e=t,X&&X in e))&&(Gt(t)||$(t)?nt:x).test(Ft(t));var e}(n)?n:void 0}At.prototype.clear=function(){this.__data__=mt?mt(null):{}},At.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},At.prototype.get=function(t){var e=this.__data__;if(mt){var n=e[t];return n===r?void 0:n}return tt.call(e,t)?e[t]:void 0},At.prototype.has=function(t){var e=this.__data__;return mt?void 0!==e[t]:tt.call(e,t)},At.prototype.set=function(t,e){return this.__data__[t]=mt&&void 0===e?r:e,this},Tt.prototype.clear=function(){this.__data__=[]},Tt.prototype.delete=function(t){var e=this.__data__,n=xt(e,t);return!(n<0||(n==e.length-1?e.pop():ct.call(e,n,1),0))},Tt.prototype.get=function(t){var e=this.__data__,n=xt(e,t);return n<0?void 0:e[n][1]},Tt.prototype.has=function(t){return xt(this.__data__,t)>-1},Tt.prototype.set=function(t,e){var n=this.__data__,r=xt(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},Nt.prototype.clear=function(){this.__data__={hash:new At,map:new(dt||Tt),string:new At}},Nt.prototype.delete=function(t){return Dt(this,t).delete(t)},Nt.prototype.get=function(t){return Dt(this,t).get(t)},Nt.prototype.has=function(t){return Dt(this,t).has(t)},Nt.prototype.set=function(t,e){return Dt(this,t).set(t,e),this},Rt.prototype.clear=function(){this.__data__=new Tt},Rt.prototype.delete=function(t){return this.__data__.delete(t)},Rt.prototype.get=function(t){return this.__data__.get(t)},Rt.prototype.has=function(t){return this.__data__.has(t)},Rt.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Tt){var r=n.__data__;if(!dt||r.length<199)return r.push([t,e]),this;n=this.__data__=new Nt(r)}return n.set(t,e),this};var kt=ft?V(ft,Object):function(){return[]},Mt=function(t){return et.call(t)};function Bt(t,e){return!!(e=null==e?o:e)&&("number"==typeof t||L.test(t))&&t>-1&&t%1==0&&t<e}function qt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||z)}function Ft(t){if(null!=t){try{return Z.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Wt(t,e){return t===e||t!=t&&e!=e}(pt&&Mt(new pt(new ArrayBuffer(1)))!=b||dt&&Mt(new dt)!=f||yt&&Mt(yt.resolve())!=p||gt&&Mt(new gt)!=y||vt&&Mt(new vt)!=m)&&(Mt=function(t){var e=et.call(t),n=e==h?t.constructor:void 0,r=n?Ft(n):void 0;if(r)switch(r){case wt:return b;case bt:return f;case _t:return p;case Et:return y;case It:return m}return e});var $t=Array.isArray;function Ht(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}(t.length)&&!Gt(t)}var Vt=lt||function(){return!1};function Gt(t){var e=Jt(t)?et.call(t):"";return e==u||e==c}function Jt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Kt(t){return Ht(t)?function(t,e){var n=$t(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Ht(t)}(t)&&tt.call(t,"callee")&&(!ut.call(t,"callee")||et.call(t)==i)}(t)?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],r=n.length,o=!!r;for(var s in t)!e&&!tt.call(t,s)||o&&("length"==s||Bt(s,r))||n.push(s);return n}(t):function(t){if(!qt(t))return ht(t);var e=[];for(var n in Object(t))tt.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}t.exports=function(t){return Lt(t,!0,!0)}},880:function(t,e,n){var r,o="Expected a function",i="__lodash_hash_undefined__",s=1/0,a=9007199254740991,u="[object Function]",c="[object GeneratorFunction]",f="[object Symbol]",l=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,h=/^\w*$/,p=/^\./,d=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,y=/\\(\\)?/g,g=/^\[object .+?Constructor\]$/,v=/^(?:0|[1-9]\d*)$/,m="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,w="object"==typeof self&&self&&self.Object===Object&&self,b=m||w||Function("return this")(),_=Array.prototype,E=Function.prototype,I=Object.prototype,S=b["__core-js_shared__"],O=(r=/[^.]+$/.exec(S&&S.keys&&S.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",A=E.toString,T=I.hasOwnProperty,N=I.toString,R=RegExp("^"+A.call(T).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),C=b.Symbol,x=_.splice,L=W(b,"Map"),P=W(Object,"create"),U=C?C.prototype:void 0,D=U?U.toString:void 0;function j(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function k(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function M(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function B(t,e,n){var r=t[e];T.call(t,e)&&J(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function q(t,e){for(var n=t.length;n--;)if(J(t[n][0],e))return n;return-1}function F(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function W(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){if(!Y(t)||O&&O in t)return!1;var e=function(t){var e=Y(t)?N.call(t):"";return e==u||e==c}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?R:g;return e.test(function(t){if(null!=t){try{return A.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}(n)?n:void 0}function $(t,e){return!!(e=null==e?a:e)&&("number"==typeof t||v.test(t))&&t>-1&&t%1==0&&t<e}j.prototype.clear=function(){this.__data__=P?P(null):{}},j.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},j.prototype.get=function(t){var e=this.__data__;if(P){var n=e[t];return n===i?void 0:n}return T.call(e,t)?e[t]:void 0},j.prototype.has=function(t){var e=this.__data__;return P?void 0!==e[t]:T.call(e,t)},j.prototype.set=function(t,e){return this.__data__[t]=P&&void 0===e?i:e,this},k.prototype.clear=function(){this.__data__=[]},k.prototype.delete=function(t){var e=this.__data__,n=q(e,t);return!(n<0||(n==e.length-1?e.pop():x.call(e,n,1),0))},k.prototype.get=function(t){var e=this.__data__,n=q(e,t);return n<0?void 0:e[n][1]},k.prototype.has=function(t){return q(this.__data__,t)>-1},k.prototype.set=function(t,e){var n=this.__data__,r=q(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},M.prototype.clear=function(){this.__data__={hash:new j,map:new(L||k),string:new j}},M.prototype.delete=function(t){return F(this,t).delete(t)},M.prototype.get=function(t){return F(this,t).get(t)},M.prototype.has=function(t){return F(this,t).has(t)},M.prototype.set=function(t,e){return F(this,t).set(t,e),this};var H=G((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(z(t))return D?D.call(t):"";var e=t+"";return"0"==e&&1/t==-s?"-0":e}(e);var n=[];return p.test(t)&&n.push(""),t.replace(d,(function(t,e,r,o){n.push(r?o.replace(y,"$1"):e||t)})),n}));function V(t){if("string"==typeof t||z(t))return t;var e=t+"";return"0"==e&&1/t==-s?"-0":e}function G(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(o);var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(G.Cache||M),n}function J(t,e){return t===e||t!=t&&e!=e}G.Cache=M;var K=Array.isArray;function Y(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function z(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&N.call(t)==f}t.exports=function(t,e,n){return null==t?t:function(t,e,n,r){if(!Y(t))return t;e=function(t,e){if(K(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!z(t))||h.test(t)||!l.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:function(t){return K(t)?t:H(t)}(e);for(var o=-1,i=e.length,s=i-1,a=t;null!=a&&++o<i;){var u=V(e[o]),c=n;if(o!=s){var f=a[u];void 0===(c=r?r(f,u,a):void 0)&&(c=Y(f)?f:$(e[o+1])?[]:{})}B(a,u,c),a=a[u]}return t}(t,e,n)}},373:function(t,e,n){var r,o="Expected a function",i="__lodash_hash_undefined__",s=1/0,a="[object Function]",u="[object GeneratorFunction]",c="[object Symbol]",f=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,l=/^\w*$/,h=/^\./,p=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,d=/\\(\\)?/g,y=/^\[object .+?Constructor\]$/,g="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,v="object"==typeof self&&self&&self.Object===Object&&self,m=g||v||Function("return this")(),w=Array.prototype,b=Function.prototype,_=Object.prototype,E=m["__core-js_shared__"],I=(r=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",S=b.toString,O=_.hasOwnProperty,A=_.toString,T=RegExp("^"+S.call(O).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),N=m.Symbol,R=w.splice,C=q(m,"Map"),x=q(Object,"create"),L=N?N.prototype:void 0,P=L?L.toString:void 0;function U(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function D(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function j(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function k(t,e){for(var n,r,o=t.length;o--;)if((n=t[o][0])===(r=e)||n!=n&&r!=r)return o;return-1}function M(t){return V(t)?t:W(t)}function B(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function q(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){if(!G(t)||I&&I in t)return!1;var e=function(t){var e=G(t)?A.call(t):"";return e==a||e==u}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?T:y;return e.test(function(t){if(null!=t){try{return S.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}(n)?n:void 0}function F(t,e){if(V(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!J(t))||l.test(t)||!f.test(t)||null!=e&&t in Object(e)}U.prototype.clear=function(){this.__data__=x?x(null):{}},U.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},U.prototype.get=function(t){var e=this.__data__;if(x){var n=e[t];return n===i?void 0:n}return O.call(e,t)?e[t]:void 0},U.prototype.has=function(t){var e=this.__data__;return x?void 0!==e[t]:O.call(e,t)},U.prototype.set=function(t,e){return this.__data__[t]=x&&void 0===e?i:e,this},D.prototype.clear=function(){this.__data__=[]},D.prototype.delete=function(t){var e=this.__data__,n=k(e,t);return!(n<0||(n==e.length-1?e.pop():R.call(e,n,1),0))},D.prototype.get=function(t){var e=this.__data__,n=k(e,t);return n<0?void 0:e[n][1]},D.prototype.has=function(t){return k(this.__data__,t)>-1},D.prototype.set=function(t,e){var n=this.__data__,r=k(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},j.prototype.clear=function(){this.__data__={hash:new U,map:new(C||D),string:new U}},j.prototype.delete=function(t){return B(this,t).delete(t)},j.prototype.get=function(t){return B(this,t).get(t)},j.prototype.has=function(t){return B(this,t).has(t)},j.prototype.set=function(t,e){return B(this,t).set(t,e),this};var W=H((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(J(t))return P?P.call(t):"";var e=t+"";return"0"==e&&1/t==-s?"-0":e}(e);var n=[];return h.test(t)&&n.push(""),t.replace(p,(function(t,e,r,o){n.push(r?o.replace(d,"$1"):e||t)})),n}));function $(t){if("string"==typeof t||J(t))return t;var e=t+"";return"0"==e&&1/t==-s?"-0":e}function H(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(o);var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(H.Cache||j),n}H.Cache=j;var V=Array.isArray;function G(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function J(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&A.call(t)==c}t.exports=function(t,e){return null==t||function(t,e){t=function(t,e){return 1==e.length?t:function(t,e){for(var n=0,r=(e=F(e,t)?[e]:M(e)).length;null!=t&&n<r;)t=t[$(e[n++])];return n&&n==r?t:void 0}(t,function(t,e,n){var r=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var i=Array(o);++r<o;)i[r]=t[r+e];return i}(e,0,-1))}(t,e=F(e,t)?[e]:M(e));var n,r,o=$((r=(n=e)?n.length:0)?n[r-1]:void 0);return!(null!=t&&O.call(t,o))||delete t[o]}(t,e)}},47:function(t){var e=function(t){"use strict";var e,n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function f(t,e,n,r){var i=e&&e.prototype instanceof v?e:v,s=Object.create(i.prototype),a=new C(r||[]);return o(s,"_invoke",{value:A(t,n,a)}),s}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function v(){}function m(){}function w(){}var b={};c(b,s,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(x([])));E&&E!==n&&r.call(E,s)&&(b=E);var I=w.prototype=v.prototype=Object.create(b);function S(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function n(o,i,s,a){var u=l(t[o],t,i);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,s,a)}),(function(t){n("throw",t,s,a)})):e.resolve(f).then((function(t){c.value=t,s(c)}),(function(t){return n("throw",t,s,a)}))}a(u.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function A(t,e,n){var r=h;return function(o,i){if(r===d)throw new Error("Generator is already running");if(r===y){if("throw"===o)throw i;return L()}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var a=T(s,n);if(a){if(a===g)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===h)throw r=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=d;var u=l(t,e,n);if("normal"===u.type){if(r=n.done?y:p,u.arg===g)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=y,n.method="throw",n.arg=u.arg)}}}function T(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,T(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var i=l(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,g;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function N(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function R(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function x(t){if(t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}return{next:L}}function L(){return{value:e,done:!0}}return m.prototype=w,o(I,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:m,configurable:!0}),m.displayName=c(w,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(I),t},t.awrap=function(t){return{__await:t}},S(O.prototype),c(O.prototype,a,(function(){return this})),t.AsyncIterator=O,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new O(f(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},S(I),c(I,u,"Generator"),c(I,s,(function(){return this})),c(I,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=x,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(R),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return a.type="throw",a.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return o("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),c=r.call(s,"finallyLoc");if(u&&c){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),R(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;R(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:x(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}},633:function(){},536:function(t){"use strict";t.exports=JSON.parse('{"version":"2.5.23-beta.0"}')}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}return n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nmd=function(t){return t.paths=[],t.children||(t.children=[]),t},n(47),n(195)}()}));