twikoo-component
Version:
A simple comment system.
1 lines • 752 kB
JavaScript
!function(e,i){"object"==typeof exports&&"object"==typeof module?module.exports=i():"function"==typeof define&&define.amd?define([],i):"object"==typeof exports?exports["twikoo.react"]=i():e["twikoo.react"]=i()}(this,function(){return function(){var e={2063:function(e,i,r){"use strict";r.r(i),r.d(i,{formatUrl:function(){return c},AbstractStorage:function(){return l},StorageType:function(){return s},AbstractSDKRequest:function(){return a}}),(o=s||(s={})).local="local",o.none="none",o.session="session";var o,s,a=function(){},l=function(){};function c(e,i,r){void 0===r&&(r={});var o=/\?/.test(i),s="";for(var a in r)""===s?o||(i+="?"):s+="&",s+=a+"="+encodeURIComponent(r[a]);return(i+=s,/^http(s)?\:\/\//.test(i))?i:""+e+i}},5303:function(e,i,r){"use strict";r.r(i),r.d(i,{default:function(){return ec}});var o,s,a,l=r("3539"),c=r("2063");var u=(o=function(e,i){return(o=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])})(e,i)},function(e,i){function r(){this.constructor=e}o(e,i),e.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}),d=function(){return(d=Object.assign||function(e){for(var i,r=1,o=arguments.length;r<o;r++)for(var s in i=arguments[r],i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s]);return e}).apply(this,arguments)},p=function(e,i){var r,o,s,a,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(r)throw TypeError("Generator is already executing.");for(;l;)try{if(r=1,o&&(s=2&a[0]?o.return:a[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,a[1])).done)return s;switch(o=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,o=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(s=(s=l.trys).length>0&&s[s.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){l.label=a[1];break}if(6===a[0]&&l.label<s[1]){l.label=s[1],s=a;break}if(s&&l.label<s[2]){l.label=s[2],l.ops.push(a);break}s[2]&&l.ops.pop(),l.trys.pop();continue}a=i.call(e,l)}catch(e){a=[6,e],o=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},f=function(e){function i(i){void 0===i&&(i={});var r=e.call(this)||this,o=i.timeout,s=i.timeoutMsg,a=i.restrictedMethods;return r._timeout=o||0,r._timeoutMsg=s||"请求超时",r._restrictedMethods=a||["get","post","upload","download"],r}return u(i,e),i.prototype.post=function(e){var i=this;return new Promise(function(r,o){var s=e.url,a=e.data,l=e.headers,u=wx.request({url:(0,c.formatUrl)("https:",s),data:a,timeout:i._timeout,method:"POST",header:l,success:function(e){r(e)},fail:function(e){o(e)},complete:function(e){if(!!e&&!!e.errMsg&&!!i._timeout&&-1!==i._restrictedMethods.indexOf("post")){if("request:fail timeout"===e.errMsg){console.warn(i._timeoutMsg);try{u.abort()}catch(e){}}}}})})},i.prototype.upload=function(e){var i=this,r=this;return new Promise(function(o){var s,a,l,c;return s=i,a=void 0,l=void 0,c=function(){var i,s,a,l,c,u;return p(this,function(p){return i=e.url,s=e.file,a=e.data,l=e.headers,c=e.onUploadProgress,u=wx.uploadFile({url:i,filePath:s,name:"file",formData:d({},a),header:l,timeout:this._timeout,success:function(e){var i={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&a.success_action_status&&(i.statusCode=parseInt(a.success_action_status,10)),o(i)},fail:function(e){o(e)},complete:function(e){if(!!e&&!!e.errMsg&&!!r._timeout&&-1!==r._restrictedMethods.indexOf("upload")){if("request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{u.abort()}catch(e){}}}}}),c&&u.onProgressUpdate(function(e){c(e)}),[2]})},new(l||(l=Promise))(function(e,i){function r(e){try{u(c.next(e))}catch(e){i(e)}}function o(e){try{u(c.throw(e))}catch(e){i(e)}}function u(i){var s;i.done?e(i.value):((s=i.value)instanceof l?s:new l(function(e){e(s)})).then(r,o)}u((c=c.apply(s,a||[])).next())})})},i.prototype.download=function(e){var i=this,r=this;return new Promise(function(o,s){var a=e.url,l=e.headers,u=wx.downloadFile({url:(0,c.formatUrl)("https:",a),header:l,timeout:i._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?o({statusCode:200,tempFilePath:e.tempFilePath}):o(e)},fail:function(e){s(e)},complete:function(e){if(!!e&&!!e.errMsg&&!!r._timeout&&-1!==r._restrictedMethods.indexOf("download")){if("request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{u.abort()}catch(e){}}}}})})},i}(c.AbstractSDKRequest),h={setItem:function(e,i){wx.setStorageSync(e,i)},getItem:function(e){return wx.getStorageSync(e)},removeItem:function(e){wx.removeStorageSync(e)},clear:function(){wx.clearStorageSync()}},A=function(e,i){void 0===i&&(i={});var r=wx.connectSocket(d({url:e},i));return{set onopen(cb){r.onOpen(cb)},set onmessage(cb){r.onMessage(cb)},set onclose(cb){r.onClose(cb)},set onerror(cb){r.onError(cb)},send:function(e){return r.send({data:e})},close:function(e,i){return r.close({code:e,reason:i})},get readyState(){return r.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}},m=function(){for(var e=0,i=0,r=arguments.length;i<r;i++)e+=arguments[i].length;for(var o=Array(e),s=0,i=0;i<r;i++)for(var a=arguments[i],l=0,c=a.length;l<c;l++,s++)o[s]=a[l];return o},g=l.constants.ERRORS,_={},v={},b=function(){return(b=Object.assign||function(e){for(var i,r=1,o=arguments.length;r<o;r++)for(var s in i=arguments[r],i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s]);return e}).apply(this,arguments)},y=l.cache.CloudbaseCache,C={},k={};function E(e){var i=e.env,r=e.persistence,o=e.platformInfo,s={accessTokenKey:"access_token_"+i,accessTokenExpireKey:"access_token_expire_"+i,refreshTokenKey:"refresh_token_"+i,anonymousUuidKey:"anonymous_uuid_"+i,loginTypeKey:"login_type_"+i,userInfoKey:"user_info_"+i};C[i]?C[i].updatePersistence(r):C[i]=new y(b(b({},e),{keys:s,platformInfo:o,alwaysLocalKeys:["anonymousUuidKey"]})),k[i]=k[i]||new y(b(b({},e),{keys:s,platformInfo:o,persistence:"local"}))}function w(e){return C[e]}function x(e){return k[e]}var I=l.constants.setSdkName,O=l.constants.setProtocol,S="",T="@cloudbase/js-sdk",M="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",N="//tcb-api.tencentcloudapi.com/web";function P(e,i){N=e,i&&(M=i,O(i))}(s=a||(a={})).ANONYMOUS="ANONYMOUS",s.WECHAT="WECHAT",s.CUSTOM="CUSTOM",s.NULL="NULL";var L={LOGIN_STATE_EXPIRED:"loginStateExpire",ACCESS_TOKEN_REFRESHD:"refreshAccessToken"},D=function(){return(D=Object.assign||function(e){for(var i,r=1,o=arguments.length;r<o;r++)for(var s in i=arguments[r],i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s]);return e}).apply(this,arguments)},R=function(e,i,r,o){return new(r||(r=Promise))(function(s,a){function l(e){try{u(o.next(e))}catch(e){a(e)}}function c(e){try{u(o.throw(e))}catch(e){a(e)}}function u(e){var i;e.done?s(e.value):((i=e.value)instanceof r?i:new r(function(e){e(i)})).then(l,c)}u((o=o.apply(e,i||[])).next())})},$=function(e,i){var r,o,s,a,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(r)throw TypeError("Generator is already executing.");for(;l;)try{if(r=1,o&&(s=2&a[0]?o.return:a[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,a[1])).done)return s;switch(o=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,o=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(s=(s=l.trys).length>0&&s[s.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){l.label=a[1];break}if(6===a[0]&&l.label<s[1]){l.label=s[1],s=a;break}if(s&&l.label<s[2]){l.label=s[2],l.ops.push(a);break}s[2]&&l.ops.pop(),l.trys.pop();continue}a=i.call(e,l)}catch(e){a=[6,e],o=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},B=l.constants.ERRORS,F=l.utils.genSeqId,U=l.utils.isFormData,j=l.utils.formatUrl,G=l.utils.createSign,z=l.adapters.RUNTIME,H=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function q(e,i,r){var o=e[i];e[i]=function(i){var s={},a={};r.forEach(function(r){var o=r.call(e,i),l=o.data,c=o.headers;Object.assign(s,l),Object.assign(a,c)});var l=i.data;return l&&function(){if(U(l)){for(var e in s)l.append(e,s[e]);return}i.data=D(D({},l),s)}(),i.headers=D(D({},i.headers||{}),a),o.call(e,i)}}function V(){var e=F();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+S,"x-seqid":e}}}var W=function(){function e(e){this._throwWhenRequestFail=!1,this.config=e,this._reqClass=new v.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post"]}),this._throwWhenRequestFail=e.throw||!1,this._cache=C[this.config.env],this._localCache=k[this.config.env],q(this._reqClass,"post",[V]),q(this._reqClass,"upload",[V]),q(this._reqClass,"download",[V])}return e.prototype.post=function(e){return R(this,void 0,void 0,function(){return $(this,function(i){switch(i.label){case 0:return[4,this._reqClass.post(e)];case 1:return[2,i.sent()]}})})},e.prototype.upload=function(e){return R(this,void 0,void 0,function(){return $(this,function(i){switch(i.label){case 0:return[4,this._reqClass.upload(e)];case 1:return[2,i.sent()]}})})},e.prototype.download=function(e){return R(this,void 0,void 0,function(){return $(this,function(i){switch(i.label){case 0:return[4,this._reqClass.download(e)];case 1:return[2,i.sent()]}})})},e.prototype.refreshAccessToken=function(){return R(this,void 0,void 0,function(){var e,i;return $(this,function(r){switch(r.label){case 0:!this._refreshAccessTokenPromise&&(this._refreshAccessTokenPromise=this._refreshAccessToken()),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._refreshAccessTokenPromise];case 2:return e=r.sent(),[3,4];case 3:return i=r.sent(),[3,4];case 4:if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,i)throw i;return[2,e]}})})},e.prototype.getAccessToken=function(){return R(this,void 0,void 0,function(){var e,i,r,o,s,a,l,c,u;return $(this,function(d){switch(d.label){case 0:return i=(e=this._cache.keys).accessTokenKey,r=e.accessTokenExpireKey,o=e.refreshTokenKey,[4,this._cache.getStoreAsync(o)];case 1:if(!d.sent())throw Error(JSON.stringify({code:B.OPERATION_FAIL,msg:"refresh token is not exist, your local data might be messed up, please retry after clear localStorage or sessionStorage"}));return[4,this._cache.getStoreAsync(i)];case 2:return s=d.sent(),l=Number,[4,this._cache.getStoreAsync(r)];case 3:if(a=l.apply(void 0,[d.sent()]),c=!0,!(u=this._shouldRefreshAccessTokenHook))return[3,5];return[4,this._shouldRefreshAccessTokenHook(s,a)];case 4:u=!d.sent(),d.label=5;case 5:if(u&&(c=!1),!((!s||!a||a<Date.now())&&c))return[3,7];return[4,this.refreshAccessToken()];case 6:return[2,d.sent()];case 7:return[2,{accessToken:s,accessTokenExpire:a}]}})})},e.prototype.request=function(e,i,r){return R(this,void 0,void 0,function(){var o,s,a,l,c,u,d,p,f,h,A,m,g,_,b,y,C,k,E,w,x,I,O,S,T;return $(this,function(P){switch(P.label){case 0:if(o="x-tcb-trace_"+this.config.env,s="application/x-www-form-urlencoded",a=D({action:e,dataVersion:"2020-01-10",env:this.config.env},i),-1!==H.indexOf(e))return[3,3];return l=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(l)];case 1:if(!P.sent())return[3,3];return c=a,[4,this.getAccessToken()];case 2:c.access_token=P.sent().accessToken,P.label=3;case 3:if("storage.uploadFile"===e){for(d in u=new FormData)u.hasOwnProperty(d)&&void 0!==u[d]&&u.append(d,a[d]);s="multipart/form-data"}else for(d in s="application/json;charset=UTF-8",u={},a)void 0!==a[d]&&(u[d]=a[d]);return p={headers:{"content-type":s}},(null==r?void 0:r.onUploadProgress)&&(p.onUploadProgress=r.onUploadProgress),this.config.region&&(p.headers["X-TCB-Region"]=this.config.region),(f=this._localCache.getStore(o))&&(p.headers["X-TCB-Trace"]=f),v.runtime!==z.WEB&&(A=(h=this.config).appSign,m=h.appSecret,g=Date.now(),_=m.appAccessKey,y=G({data:{},timestamp:g,appAccessKeyId:b=m.appAccessKeyId,appSign:A},_),p.headers["X-TCB-App-Source"]="timestamp="+g+";appAccessKeyId="+b+";appSign="+A+";sign="+y),C=i.parse,k=i.inQuery,E=i.search,w={env:this.config.env},C&&(w.parse=!0),k&&(w=D(D({},k),w)),I=(x={BASE_URL:N,PROTOCOL:M}).BASE_URL,O=j(x.PROTOCOL,I,w),E&&(O+=E),[4,this.post(D({url:O,data:u},p))];case 4:if((T=(S=P.sent()).header&&S.header["x-tcb-trace"])&&this._localCache.setStore(o,T),200!==Number(S.status)&&200!==Number(S.statusCode)||!S.data)throw Error("network request error");return[2,S]}})})},e.prototype.send=function(e,i){return void 0===i&&(i={}),R(this,void 0,void 0,function(){var r;return $(this,function(o){switch(o.label){case 0:return[4,this.request(e,i,{onUploadProgress:i.onUploadProgress})];case 1:if(!("ACCESS_TOKEN_EXPIRED"===(r=o.sent()).data.code&&-1===H.indexOf(e)))return[3,4];return[4,this.refreshAccessToken()];case 2:return o.sent(),[4,this.request(e,i,{onUploadProgress:i.onUploadProgress})];case 3:r=o.sent(),o.label=4;case 4:if(r.data.code&&this._throwWhenRequestFail)throw Error(JSON.stringify({code:B.OPERATION_FAIL,msg:"["+r.data.code+"] "+r.data.message}));return[2,r.data]}})})},e.prototype._refreshAccessToken=function(e){return void 0===e&&(e=1),R(this,void 0,void 0,function(){var i,r,o,s,l,c,u,d,p,f,h,A,m;return $(this,function(g){switch(g.label){case 0:return r=(i=this._cache.keys).accessTokenKey,o=i.accessTokenExpireKey,s=i.refreshTokenKey,l=i.loginTypeKey,c=i.anonymousUuidKey,[4,this._cache.removeStoreAsync(r)];case 1:return g.sent(),[4,this._cache.removeStoreAsync(o)];case 2:return g.sent(),[4,this._cache.getStoreAsync(s)];case 3:if(!(u=g.sent()))throw Error(JSON.stringify({code:B.INVALID_OPERATION,msg:"not login"}));return d={refresh_token:u},[4,this.request("auth.fetchAccessTokenWithRefreshToken",d)];case 4:if(!(p=g.sent()).data.code)return[3,12];if(!("SIGN_PARAM_INVALID"===(f=p.data.code)||"REFRESH_TOKEN_EXPIRED"===f||"INVALID_REFRESH_TOKEN"===f))return[3,11];return[4,this._cache.getStoreAsync(l)];case 5:if(!(g.sent()===a.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===f))return[3,9];return[4,this._cache.getStoreAsync(c)];case 6:return h=g.sent(),[4,this._cache.getStoreAsync(s)];case 7:return A=g.sent(),[4,this.send("auth.signInAnonymously",{anonymous_uuid:h,refresh_token:A})];case 8:if(m=g.sent(),this._setRefreshToken(m.refresh_token),e>=1)return[2,this._refreshAccessToken(--e)];throw Error(JSON.stringify({code:B.OPERATION_FAIL,message:"重试获取 refresh token 失败"}));case 9:return el.fire(L.LOGIN_STATE_EXPIRED),[4,this._cache.removeStoreAsync(s)];case 10:g.sent(),g.label=11;case 11:throw Error(JSON.stringify({code:B.NETWORK_ERROR,msg:"refresh access_token failed:"+p.data.code}));case 12:if(!p.data.access_token)return[3,15];return el.fire(L.ACCESS_TOKEN_REFRESHD),[4,this._cache.setStoreAsync(r,p.data.access_token)];case 13:return g.sent(),[4,this._cache.setStoreAsync(o,p.data.access_token_expire+Date.now())];case 14:return g.sent(),[2,{accessToken:p.data.access_token,accessTokenExpire:p.data.access_token_expire}];case 15:if(!p.data.refresh_token)return[3,19];return[4,this._cache.removeStoreAsync(s)];case 16:return g.sent(),[4,this._cache.setStoreAsync(s,p.data.refresh_token)];case 17:return g.sent(),[4,this._refreshAccessToken()];case 18:g.sent(),g.label=19;case 19:return[2]}})})},e.prototype._setRefreshToken=function(e){return R(this,void 0,void 0,function(){var i,r,o,s;return $(this,function(a){switch(a.label){case 0:return r=(i=this._cache.keys).accessTokenKey,o=i.accessTokenExpireKey,s=i.refreshTokenKey,[4,this._cache.removeStoreAsync(r)];case 1:return a.sent(),[4,this._cache.removeStoreAsync(o)];case 2:return a.sent(),[4,this._cache.setStoreAsync(s,e)];case 3:return a.sent(),[2]}})})},e}(),K={},X=function(){return(X=Object.assign||function(e){for(var i,r=1,o=arguments.length;r<o;r++)for(var s in i=arguments[r],i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s]);return e}).apply(this,arguments)},Q=function(e,i,r,o){var s,a=arguments.length,l=a<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,i,r,o);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(l=(a<3?s(l):a>3?s(i,r,l):s(i,r))||l);return a>3&&l&&Object.defineProperty(i,r,l),l},Y=function(e,i){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,i)},J=function(e,i){var r,o,s,a,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(r)throw TypeError("Generator is already executing.");for(;l;)try{if(r=1,o&&(s=2&a[0]?o.return:a[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,a[1])).done)return s;switch(o=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,o=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(s=(s=l.trys).length>0&&s[s.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){l.label=a[1];break}if(6===a[0]&&l.label<s[1]){l.label=s[1],s=a;break}if(s&&l.label<s[2]){l.label=s[2],l.ops.push(a);break}s[2]&&l.ops.pop(),l.trys.pop();continue}a=i.call(e,l)}catch(e){a=[6,e],o=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Z=l.adapters.useAdapters,ee=l.adapters.useDefaultAdapter,et=l.adapters.RUNTIME,en=l.constants.ERRORS,ei=l.constants.COMMUNITY_SITE_URL,er=l.utils.printWarn,eo=l.helpers.catchErrorsDecorator,es={timeout:15e3,persistence:"local"},ea={},el=new(function(){function e(e){this._config=e||this._config,this.authInstance=null}return Object.defineProperty(e.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return v},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return C[this._config.env]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return k[this._config.env]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return K[this._config.env]},enumerable:!1,configurable:!0}),e.prototype.init=function(i){if(!i.env)throw Error(JSON.stringify({code:en.INVALID_PARAMS,msg:"env must not be specified"}));if(!v.adapter&&this._useDefaultAdapter(),this.requestClient=new v.adapter.reqClass({timeout:i.timeout||5e3,timeoutMsg:"["+T+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+i.timeout/1e3+"s"}),v.runtime!==et.WEB){if(!i.appSecret)throw Error(JSON.stringify({code:en.INVALID_PARAMS,msg:"invalid appSecret"}));var r,o,s,a,l=v.adapter.getAppSign?v.adapter.getAppSign():"";if(i.appSign&&l&&i.appSign!==l)throw Error(JSON.stringify({code:en.INVALID_PARAMS,msg:"invalid appSign"}));if(l&&(i.appSign=l),!i.appSign)throw Error(JSON.stringify({code:en.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=X(X({},es),i),this._config.timeout=this._formatTimeout(this._config.timeout);var c=this._config,u=c.env,d=c.persistence,p=c.debug,f=c.timeout,h=c.appSecret,A=c.appSign;if(E({env:u,persistence:d,debug:p,platformInfo:this.platform}),K[(r={env:u,region:i.region||"",timeout:f,appSecret:h,appSign:A}).env]=new W(D(D({},r),{throw:!0})),i.region){;o=u,P((s=i.region||"")?"//"+o+"."+s+".tcb-api.tencentcloudapi.com/web":"//"+o+".ap-shanghai.tcb-api.tencentcloudapi.com/web",void 0)}var m=new e(this._config);return m.requestClient=this.requestClient,m},e.prototype.updateConfig=function(e){var i=e.persistence,r=e.debug;this._config.persistence=i,this._config.debug=r,E({env:this._config.env,persistence:i,debug:r,platformInfo:this.platform})},e.prototype.registerExtension=function(e){ea[e.name]=e},e.prototype.invokeExtension=function(e,i){var r,o,s,a;return r=this,o=void 0,s=void 0,a=function(){var r;return J(this,function(o){switch(o.label){case 0:if(!(r=ea[e]))throw Error(JSON.stringify({code:en.INVALID_PARAMS,msg:"extension:"+e+" must be registered before invoke"}));return[4,r.invoke(i,this)];case 1:return[2,o.sent()]}})},new(s||(s=Promise))(function(e,i){function l(e){try{u(a.next(e))}catch(e){i(e)}}function c(e){try{u(a.throw(e))}catch(e){i(e)}}function u(i){var r;i.done?e(i.value):((r=i.value)instanceof s?r:new s(function(e){e(r)})).then(l,c)}u((a=a.apply(r,o||[])).next())})},e.prototype.useAdapters=function(e){var i=Z(e)||{},r=i.adapter,o=i.runtime;r&&(v.adapter=r),o&&(v.runtime=o)},e.prototype.registerHook=function(i){!function(e,i){var r=i.entity,o=i.target;if(!e.prototype.hasOwnProperty(o))throw Error(JSON.stringify({code:g.INVALID_OPERATION,msg:"target:"+o+" is not exist"}));var s=e.prototype[o];if("function"!=typeof s)throw Error(JSON.stringify({code:g.INVALID_OPERATION,msg:"target:"+o+" is not a function which is the only type supports hook"}));e.prototype[o]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return r.call.apply(r,m([this],e)),s.call.apply(s,m([this],e))}}(e,i)},e.prototype.registerComponent=function(i){!function(e,i){var r=i.name,o=i.namespace,s=i.entity,a=i.injectEvents,l=i.IIFE;if(_[r]||o&&e[o])throw Error(JSON.stringify({code:g.INVALID_OPERATION,msg:"Duplicate component "+r}));if(void 0!==l&&l){if(!s||"function"!=typeof s)throw Error(JSON.stringify({code:g.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));s.call(e)}if(_[r]=i,o?e.prototype[o]=s:function e(i,r){if(!(r instanceof Object))return r;switch(r.constructor){case Date:return new Date(r.getTime());case Object:void 0===i&&(i={});break;case Array:i=[];break;default:return r}for(var o in r){if(!!r.hasOwnProperty(o))i[o]=e(i[o],r[o])}return i}(e.prototype,s),a){var c=a.bus,u=a.events;if(!c||!u||0===u.length)return;var d=e.prototype.fire||function(){};!e.prototype.events&&(e.prototype.events={}),(e.prototype.events||{})[r]?e.prototype.events[r].events=m(e.prototype.events[r].events,u):e.prototype.events[r]={bus:c,events:u},e.prototype.fire=function(e,i){for(var r in d(e,i),this.events){var o=this.events[r],s=o.bus;if(o.events.includes(e)){s.fire(e,i);break}}}}}(e,i)},e.prototype.registerVersion=function(e){S=e},e.prototype.registerSdkName=function(e){var i;T=i=e,I(i)},e.prototype.registerEndPoint=function(e,i){P(e,i)},e.prototype._useDefaultAdapter=function(){var e=ee(),i=e.adapter,r=e.runtime;v.adapter=i,v.runtime=r},e.prototype._formatTimeout=function(e){switch(!0){case e>6e5:return er(en.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),6e5;case e<100:return er(en.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},Q([eo({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+ei]}),Y("design:type",Function),Y("design:paramtypes",[Object]),Y("design:returntype",e)],e.prototype,"init",null),Q([eo({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+ei]}),Y("design:type",Function),Y("design:paramtypes",[String,Object]),Y("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}());el.useAdapters({genAdapter:function(){return{root:{},reqClass:f,wsClass:A,localStorage:h,primaryStorage:c.StorageType.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx||"undefined"==typeof Page||!wx.getSystemInfoSync||!wx.getStorageSync||!wx.setStorageSync||!wx.connectSocket||!wx.request)return!1;try{if(!wx.getSystemInfoSync()||"qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(e){return!1}return!0},runtime:"wx_mp"});el.registerVersion("1.7.2");try{window.cloudbase=el}catch(e){}var ec=el},9149:function(e,i,r){"use strict";r.r(i),r.d(i,{registerAuth:function(){return eJ},registerProvider:function(){return eZ}});var o,s,a,l,c,u,d,p,f=r("3539"),h=function(e,i,r,o){return new(r||(r=Promise))(function(s,a){function l(e){try{u(o.next(e))}catch(e){a(e)}}function c(e){try{u(o.throw(e))}catch(e){a(e)}}function u(e){var i;e.done?s(e.value):((i=e.value)instanceof r?i:new r(function(e){e(i)})).then(l,c)}u((o=o.apply(e,i||[])).next())})},A=function(e,i){var r,o,s,a,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(r)throw TypeError("Generator is already executing.");for(;l;)try{if(r=1,o&&(s=2&a[0]?o.return:a[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,a[1])).done)return s;switch(o=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,o=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(s=(s=l.trys).length>0&&s[s.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){l.label=a[1];break}if(6===a[0]&&l.label<s[1]){l.label=s[1],s=a;break}if(s&&l.label<s[2]){l.label=s[2],l.ops.push(a);break}s[2]&&l.ops.pop(),l.trys.pop();continue}a=i.call(e,l)}catch(e){a=[6,e],o=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},m=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request}return e.prototype.checkLocalLoginState=function(){return h(this,void 0,void 0,function(){var e,i,r,o,s,a;return A(this,function(l){switch(l.label){case 0:return i=(e=this._cache.keys).accessTokenKey,r=e.accessTokenExpireKey,[4,this._cache.getStoreAsync(i)];case 1:return o=l.sent(),[4,this._cache.getStoreAsync(r)];case 2:if(s=l.sent(),!o)return[3,7];if(!(s&&s>Date.now()))return[3,4];return[4,(a=new eK({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 3:return l.sent(),[2,a];case 4:return[4,this._cache.removeStoreAsync(i)];case 5:return l.sent(),[4,this._cache.removeStoreAsync(r)];case 6:l.sent(),l.label=7;case 7:return[2]}})})},e.prototype.setRefreshToken=function(e){return h(this,void 0,void 0,function(){var i,r,o,s;return A(this,function(a){switch(a.label){case 0:return r=(i=this._cache.keys).accessTokenKey,o=i.accessTokenExpireKey,s=i.refreshTokenKey,[4,this._cache.removeStoreAsync(r)];case 1:return a.sent(),[4,this._cache.removeStoreAsync(o)];case 2:return a.sent(),[4,this._cache.setStoreAsync(s,e)];case 3:return a.sent(),[2]}})})},e.prototype.setAccessToken=function(e,i){return h(this,void 0,void 0,function(){var r,o,s;return A(this,function(a){switch(a.label){case 0:return o=(r=this._cache.keys).accessTokenKey,s=r.accessTokenExpireKey,[4,this._cache.setStoreAsync(o,e)];case 1:return a.sent(),[4,this._cache.setStoreAsync(s,i)];case 2:return a.sent(),[2]}})})},e.prototype.refreshUserInfo=function(){return h(this,void 0,void 0,function(){var e,i;return A(this,function(r){switch(r.label){case 0:return e="auth.getUserInfo",[4,this._request.send(e,{})];case 1:return i=r.sent().data,[4,this.setLocalUserInfo(i)];case 2:return r.sent(),[2,i]}})})},e.prototype.setLocalUserInfo=function(e){return h(this,void 0,void 0,function(){var i;return A(this,function(r){switch(r.label){case 0:return i=this._cache.keys.userInfoKey,[4,this._cache.setStoreAsync(i,e)];case 1:return r.sent(),[2]}})})},e}();(o=p||(p={})).ANONYMOUS="ANONYMOUS",o.WECHAT="WECHAT",o.WECHAT_PUBLIC="WECHAT-PUBLIC",o.WECHAT_OPEN="WECHAT-OPEN",o.CUSTOM="CUSTOM",o.EMAIL="EMAIL",o.USERNAME="USERNAME",o.NULL="NULL",o.PHONE="PHONE";var g=(s=function(e,i){return(s=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])})(e,i)},function(e,i){function r(){this.constructor=e}s(e,i),e.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}),_=function(e,i,r,o){var s,a=arguments.length,l=a<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,i,r,o);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(l=(a<3?s(l):a>3?s(i,r,l):s(i,r))||l);return a>3&&l&&Object.defineProperty(i,r,l),l},v=function(e,i){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,i)},b=function(e,i,r,o){return new(r||(r=Promise))(function(s,a){function l(e){try{u(o.next(e))}catch(e){a(e)}}function c(e){try{u(o.throw(e))}catch(e){a(e)}}function u(e){var i;e.done?s(e.value):((i=e.value)instanceof r?i:new r(function(e){e(i)})).then(l,c)}u((o=o.apply(e,i||[])).next())})},y=function(e,i){var r,o,s,a,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(r)throw TypeError("Generator is already executing.");for(;l;)try{if(r=1,o&&(s=2&a[0]?o.return:a[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,a[1])).done)return s;switch(o=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,o=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(s=(s=l.trys).length>0&&s[s.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){l.label=a[1];break}if(6===a[0]&&l.label<s[1]){l.label=s[1],s=a;break}if(s&&l.label<s[2]){l.label=s[2],l.ops.push(a);break}s[2]&&l.ops.pop(),l.trys.pop();continue}a=i.call(e,l)}catch(e){a=[6,e],o=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},C=f.constants.getSdkName,k=f.constants.ERRORS,E=f.constants.COMMUNITY_SITE_URL,w=f.adapters.RUNTIME,x=f.utils.getQuery,I=f.utils.getHash,O=f.utils.removeParam,S=f.utils.printWarn,T=f.helpers.catchErrorsDecorator,M=function(e){function i(i,r,o,s){var a=e.call(this,i)||this;return a._runtime=i.runtime,a._appid=r,a._scope=o,a._state=s||"weixin",a}return g(i,e),i.prototype.signIn=function(){return b(this,void 0,void 0,function(){return y(this,function(e){return[2,S(k.OPERATION_FAIL,"API signIn has been deprecated, please use signInWithRedirect insteed")]})})},i.prototype.signInWithRedirect=function(){return b(this,void 0,void 0,function(){return y(this,function(e){return[2,this._redirect()]})})},i.prototype.getRedirectResult=function(e){return b(this,void 0,void 0,function(){var i;return y(this,function(r){return(i=N())?[2,this._signInWithCode(i,e)]:[2,null]})})},i.prototype.getLinkRedirectResult=function(e){return void 0===e&&(e={}),b(this,void 0,void 0,function(){var i,r,o,s,a,l;return y(this,function(c){return(r=void 0!==(i=e.withUnionId)&&i,o=N())?(s=this._appid,a=function(e){if("snsapi_login"===e)return"WECHAT-OPEN";return"WECHAT-PUBLIC"}(this._scope),l=this._runtime===w.WX_MP?"1":"0",[2,this._request.send("auth.linkWithWeixinCode",{payload:{appid:s,loginType:a,code:o,hybridMiniapp:l,withUnionId:r}})]):[2,null]})})},i.prototype._redirect=function(){var e=O("code",location.href);e=encodeURIComponent(e=O("state",e));var i="//open.weixin.qq.com/connect/oauth2/authorize";"snsapi_login"===this._scope&&(i="//open.weixin.qq.com/connect/qrconnect");try{location.href=i+"?appid="+this._appid+"&redirect_uri="+e+"&response_type=code&scope="+this._scope+"&state="+this._state+"#wechat_redirect"}catch(e){throw Error("["+C()+"]["+k.UNKOWN_ERROR+"]"+e)}},i.prototype._signInWithCode=function(e,i){return b(this,void 0,void 0,function(){var r,o,s,a,l,c,u,d;return y(this,function(f){switch(f.label){case 0:return o=(r=this._cache.keys).accessTokenKey,s=r.accessTokenExpireKey,a=r.refreshTokenKey,l=function(e){if("snsapi_login"===e)return"WECHAT-OPEN";return"WECHAT-PUBLIC"}(this._scope),[4,this._getRefreshTokenByWXCode(this._appid,l,e,i)];case 1:return u=(c=f.sent()).refreshToken,[4,this._cache.setStoreAsync(a,u)];case 2:if(f.sent(),!c.accessToken)return[3,4];return[4,this._cache.setStoreAsync(o,c.accessToken)];case 3:f.sent(),f.label=4;case 4:if(!c.accessTokenExpire)return[3,6];return[4,this._cache.setStoreAsync(s,String(c.accessTokenExpire+Date.now()))];case 5:f.sent(),f.label=6;case 6:return eV.fire(eQ.LOGIN_STATE_CHANGED),eV.fire(eQ.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:p.WECHAT,persistence:this._config.persistence}),[4,this.refreshUserInfo()];case 7:return f.sent(),[4,(d=new eK({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return f.sent(),[2,d]}})})},i.prototype._getRefreshTokenByWXCode=function(e,i,r,o){return void 0===o&&(o={}),b(this,void 0,void 0,function(){var s,a,l,c,u,d,p;return y(this,function(f){return a=void 0!==(s=o.withUnionId)&&s,c=void 0===(l=o.createUser)||l,u="snsapi_base"!==this._scope&&(o.syncUserInfo||!1),d="auth.signIn",p=this._runtime===w.WX_MP?"1":"0",[2,this._request.send(d,{appid:e,loginType:i,hybridMiniapp:p,syncUserInfo:u,loginCredential:r,withUnionId:a,createUser:c}).then(function(e){if(e.code)throw Error("["+C()+"]["+k.OPERATION_FAIL+"] failed login via wechat: "+e.code);if(e.refresh_token)return{refreshToken:e.refresh_token,accessToken:e.access_token,accessTokenExpire:e.access_token_expire};throw Error("["+C()+"]["+k.OPERATION_FAIL+"] action:getJwt not return refreshToken")})]})})},_([T({title:"跳转微信公众号授权失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().signInWithRedirect() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+E]}),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Promise)],i.prototype,"signInWithRedirect",null),_([T({title:"微信公众号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+E]}),v("design:type",Function),v("design:paramtypes",[Object]),v("design:returntype",Promise)],i.prototype,"getRedirectResult",null),_([T({title:"获取微信重定向绑定结果",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getLinkRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+E]}),v("design:type",Function),v("design:paramtypes",[Object]),v("design:returntype",Promise)],i.prototype,"getLinkRedirectResult",null),i}(m);function N(){return x("code")||I("code")}var P=(a=function(e,i){return(a=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])})(e,i)},function(e,i){function r(){this.constructor=e}a(e,i),e.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}),L=function(e,i,r,o){var s,a=arguments.length,l=a<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,i,r,o);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(l=(a<3?s(l):a>3?s(i,r,l):s(i,r))||l);return a>3&&l&&Object.defineProperty(i,r,l),l},D=function(e,i){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,i)},R=function(e,i,r,o){return new(r||(r=Promise))(function(s,a){function l(e){try{u(o.next(e))}catch(e){a(e)}}function c(e){try{u(o.throw(e))}catch(e){a(e)}}function u(e){var i;e.done?s(e.value):((i=e.value)instanceof r?i:new r(function(e){e(i)})).then(l,c)}u((o=o.apply(e,i||[])).next())})},$=function(e,i){var r,o,s,a,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(r)throw TypeError("Generator is already executing.");for(;l;)try{if(r=1,o&&(s=2&a[0]?o.return:a[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,a[1])).done)return s;switch(o=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,o=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(s=(s=l.trys).length>0&&s[s.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){l.label=a[1];break}if(6===a[0]&&l.label<s[1]){l.label=s[1],s=a;break}if(s&&l.label<s[2]){l.label=s[2],l.ops.push(a);break}s[2]&&l.ops.pop(),l.trys.pop();continue}a=i.call(e,l)}catch(e){a=[6,e],o=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},B=f.constants.ERRORS,F=f.constants.COMMUNITY_SITE_URL,U=f.utils.throwError,j=f.utils.isString,G=f.events.addEventListener,z=f.helpers.catchErrorsDecorator,H=function(e){function i(i){var r=e.call(this,i)||this;return r._onConverted=r._onConverted.bind(r),G(eQ.ANONYMOUS_CONVERTED,r._onConverted),r}return P(i,e),i.prototype.signIn=function(){return R(this,void 0,void 0,function(){var e,i,r,o,s,a,l;return $(this,function(c){switch(c.label){case 0:return[4,this._cache.updatePersistenceAsync("local")];case 1:return c.sent(),i=(e=this._cache.keys).anonymousUuidKey,r=e.refreshTokenKey,[4,this._cache.getStoreAsync(i)];case 2:return o=c.sent(),[4,this._cache.getStoreAsync(r)];case 3:return s=c.sent(),[4,this._request.send("auth.signInAnonymously",{anonymous_uuid:o,refresh_token:s})];case 4:if(!((a=c.sent()).uuid&&a.refresh_token))return[3,10];return[4,this._setAnonymousUUID(a.uuid)];case 5:return c.sent(),[4,this.setRefreshToken(a.refresh_token)];case 6:return c.sent(),[4,this._request.refreshAccessToken()];case 7:return c.sent(),eV.fire(eQ.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:p.ANONYMOUS,persistence:"local"}),eV.fire(eQ.LOGIN_STATE_CHANGED),[4,(l=new eK({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return c.sent(),[4,l.user.refresh()];case 9:return c.sent(),[2,l];case 10:throw Error(JSON.stringify({code:B.OPERATION_FAIL,msg:JSON.stringify(a)||"anonymous signIn failed"}))}})})},i.prototype.linkAndRetrieveDataWithTicket=function(e){return R(this,void 0,void 0,function(){var i,r,o,s,a,l,c;return $(this,function(u){switch(u.label){case 0:return!j(e)&&U(B.INVALID_PARAMS,"ticket must be a string"),r=(i=this._cache.keys).anonymousUuidKey,o=i.refreshTokenKey,[4,this._cache.getStoreAsync(r)];case 1:return s=u.sent(),[4,this._cache.getStoreAsync(o)];case 2:return a=u.sent(),[4,this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:a,ticket:e})];case 3:if(!(l=u.sent()).refresh_token)return[3,8];return[4,this._clearAnonymousUUID()];case 4:return u.sent(),[4,this.setRefreshToken(l.refresh_token)];case 5:return u.sent(),[4,this._request.refreshAccessToken()];case 6:return u.sent(),eV.fire(eQ.ANONYMOUS_CONVERTED,{env:this._config.env}),eV.fire(eQ.LOGIN_TYPE_CHANGED,{loginType:p.CUSTOM,persistence:"local"}),[4,(c=new eK({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 7:return u.sent(),[2,c];case 8:U(B.OPERATION_FAIL,JSON.stringify(l)||"linkAndRetrieveDataWithTicket failed"),u.label=9;case 9:return[2]}})})},i.prototype._setAnonymousUUID=function(e){return R(this,void 0,void 0,function(){var i,r,o;return $(this,function(s){switch(s.label){case 0:return r=(i=this._cache.keys).anonymousUuidKey,o=i.loginTypeKey,[4,this._cache.removeStoreAsync(r)];case 1:return s.sent(),[4,this._cache.setStoreAsync(r,e)];case 2:return s.sent(),[4,this._cache.setStoreAsync(o,p.ANONYMOUS)];case 3:return s.sent(),[2]}})})},i.prototype._clearAnonymousUUID=function(){return R(this,void 0,void 0,function(){return $(this,function(e){switch(e.label){case 0:return[4,this._cache.removeStoreAsync(this._cache.keys.anonymousUuidKey)];case 1:return e.sent(),[2]}})})},i.prototype._onConverted=function(e){return R(this,void 0,void 0,function(){return $(this,function(i){switch(i.label){case 0:if(e.data.env!==this._config.env)return[2];return[4,this._cache.updatePersistenceAsync(this._config.persistence)];case 1:return i.sent(),[2]}})})},L([z({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().anonymouseProvider().signIn() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+F]}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",Promise)],i.prototype,"signIn",null),i}(m);var q=(l=function(e,i){return(l=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])})(e,i)},function(e,i){function r(){this.constructor=e}l(e,i),e.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}),V=function(e,i,r,o){var s,a=arguments.length,l=a<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,i,r,o);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(l=(a<3?s(l):a>3?s(i,r,l):s(i,r))||l);return a>3&&l&&Object.defineProperty(i,r,l),l},W=function(e,i){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,i)},K=function(e,i){var r,o,s,a,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(r)throw TypeError("Generator is already executing.");for(;l;)try{if(r=1,o&&(s=2&a[0]?o.return:a[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,a[1])).done)return s;switch(o=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,o=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(s=(s=l.trys).length>0&&s[s.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){l.label=a[1];break}if(6===a[0]&&l.label<s[1]){l.label=s[1],s=a;break}if(s&&l.label<s[2]){l.label=s[2],l.ops.push(a);break}s[2]&&l.ops.pop(),l.trys.pop();continue}a=i.call(e,l)}catch(e){a=[6,e],o=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},X=f.constants.ERRORS,Q=f.constants.COMMUNITY_SITE_URL,Y=f.utils.isString,J=f.helpers.catchErrorsDecorator,Z=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return q(i,e),i.prototype.signIn=function(e){var i,r,o,s;return i=this,r=void 0,o=void 0,s=function(){var i,r,o,s,a,l,c;return K(this,function(u){switch(u.label){case 0:if(!Y(e))throw Error(JSON.stringify({code:X.INVALID_PARAMS,msg:"ticket must be a string"}));return i=this._cache.keys.refreshTokenKey,s=(o=this._request).send,a=["auth.signInWithTicket"],l={ticket:e},[4,this._cache.getStoreAsync(i)];case 1:return[4,s.apply(o,a.concat([(l.refresh_token=u.sent()||"",l)]))];case 2:if(!(r=u.sent()).refresh_token)return[3,7];return[4,this.setRefreshToken(r.refresh_token)];case 3:return u.sent(),[4,this._request.refreshAccessToken()];case 4:return u.sent(),eV.fire(eQ.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:p.CUSTOM,persistence:this._config.persistence}),eV.fire(eQ.LOGIN_STATE_CHANGED),[4,this.refreshUserInfo()];case 5:return u.sent(),[4,(c=new eK({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 6:return u.sent(),[2,c];case 7:throw Error(JSON.stringify({code:X.OPERATION_FAIL,msg:"custom signIn failed"}))}})},new(o||(o=Promise))(function(e,a){function l(e){try{u(s.next(e))}catch(e){a(e)}}function c(e){try{u(s.throw(e))}catch(e){a(e)}}function u(i){var r;i.done?e(i.value):((r=i.value)instanceof o?r:new o(function(e){e(r)})).then(l,c)}u((s=s.apply(i,r||[])).next())})},V([J({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().customAuthProvider().signIn() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Q]}),W("design:type",Function),W("design:paramtypes",[String]),W("design:returntype",Promise)],i.prototype,"signIn",null),i}(m);var ee=(c=function(e,i){return(c=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])})(e,i)},function(e,i){function r(){this.constructor=e}c(e,i),e.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}),et=function(e,i,r,o){var s,a=arguments.length,l=a<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,i,r,o);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(l=(a<3?s(l):a>3?s(i,r,l):s(i,r))||l);return a>3&&l&&Object.defineProperty(i,r,l),l},en=function(e,i){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,i)},ei=function(e,i,r,o){return new(r||(r=Promise))(function(s,a){function l(e){try{u(o.next(e))}catch(e){a(e)}}function c(e){try{u(o.throw(e))}catch(e){a(e)}}function u(e){var i;e.done?s(e.value):((i=e.value)instanceof r?i:new r(function(e){e(i)})).then(l,c)}u((o=o.apply(e,i||[])).next())})},er=function(e,i){var r,o,s,a,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(r)throw TypeError("Generator is already executing.");for(;l;)try{if(r=1,o&&(s=2&a[0]?o.return:a[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,a[1])).done)return s;switch(o=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,o=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(s=(s=l.trys).length>0&&s[s.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){l.label=a[1];break}if(6===a[0]&&l.label<s[1]){l.label=s[1],s=a;break}if(s&&l.label<s[2]){l.label=s[2],l.ops.push(a);break}s[2]&&l.ops.pop(),l.trys.pop();continue}a=i.call(e,l)}catch(e){a=[6,e],o=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},eo=f.utils.throwError,es=f.utils.isString,ea=f.constants.ERRORS,el=f.constants.COMMUNITY_SITE_URL,ec=f.helpers.catchErrorsDecorator,eu=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return ee(i,e),i.prototype.signIn=function(e,i){return ei(this,void 0,void 0,function(){var r,o,s,a,l;return er(this,function(c){switch(c.label){case 0:return!es(e)&&eo(ea.INVALID_PARAMS,"email must be a string"),r=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:i,refresh_token:this._cache.getStore(r)||""})];case 1:if(s=(o=c.sent()).refresh_token,a=o.access_token,l=o.access_token_expire,!s)return[3,8];return[4,this.setRefreshToken(s)];case 2:if(c.sent(),!(a&&l))return[3,4];return[4,this.setAccessToken(a,l)];case 3:return c.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:c.sent(),c.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return c.sent(),eV.fire(eQ.LOGIN_STATE_CHANGED),eV.fire(eQ.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:p.EMAIL,persistence:this._config.persistence}),[2,new eK({envId:this._config.env,cache:this._cache,request:this._request})];case 8:o.code?eo(ea.OPERATION_FAIL,"Email login fail["+o.code+"] "+o.message):eo(ea.OPERATION_FAIL,"Email login fail"),c.label=9;case 9:return[2]}})})},i.prototype.signUp=function(e,i){return ei(this,void 0,void 0,function(){return er(this,function(r){return[2,this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:i})]})})},i.prototype.resetPassword=function(e){return ei(this,void 0,void 0,function(){return er(this,function(i){return[2,this._request.send("auth.sendPasswordResetEmail",{email:e})]})})},i.prototype.resetPasswordWithToken=function(e,i){return ei(this,void 0,void 0,function(){return er(this,function(r){return[2,this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:i})]})})},i.prototype.activate=function(e){return ei(this,void 0,void 0,function(){return er(this,function(i){return[2,this._request.send("auth.activateEndUserMail",{token:e})]})})},et([ec({title:"邮箱密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().emailAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 邮箱地址与密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+el]}),en("design:type",Function),en("design:paramtypes",[String,String]),en("design:returntype",Promise)],i.prototype,"signIn",null),et([ec({title:"邮箱注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithEmailAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+el]}),en("design:type",Function),en("design:paramtypes",[String,String]),en("design:returntype",Promise)],i.prototype,"signUp",null),et([ec({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用 auth().sendPasswordResetEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经与当前用户绑定"," 4 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+el]}),en("design:type",Function),en("design:paramtypes",[String]),en("design:returntype",Promise)],i.prototype,"resetPassword",null),et([ec({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+el]}),en("design:type",Function),en("design:paramtypes",[String,Strin