@cloudbase/js-sdk 2.2.0 → 2.4.0-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 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_auth",[],e):"object"==typeof exports?exports.cloudbase_auth=e():t.cloudbase_auth=e()}("undefined"!=typeof window?window:this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.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 i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));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=10)}([function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.jwt=e.helpers=e.utils=e.events=e.cache=e.adapters=e.constants=void 0;var a=o(n(3));e.constants=a;var u=o(n(13));e.adapters=u;var c=o(n(20));e.cache=c;var l=o(n(22));e.events=l;var h=o(n(1));e.utils=h;var f=o(n(23));e.helpers=f;var d={decode:s(n(25)).default};e.jwt=d},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.createSign=e.formatUrl=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var i=r(n(15)),o=r(n(18)),s=r(n(19)),a=n(3);function u(t){var e=o.default.stringify(t);return e=(e=(e=e.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.formatUrl=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),i="";for(var o in n)""===i?!r&&(e+="?"):i+="&",i+=o+"="+encodeURIComponent(n[o]);return/^http(s)?\:\/\//.test(e+=i)?e:""+t+e},e.createSign=function(t,e){var n=u(s.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+u(s.default.parse(JSON.stringify(t)));return n+"."+u(i.default(n,e))},e.toQueryString=function(t){void 0===t&&(t={});var e=[];for(var n in t)e.push(n+"="+encodeURIComponent(t[n]));return e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var n=e||window.location.search,r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),i=n.substr(n.indexOf("?")+1).match(r);return null!=i?i[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]"+t+"=([^&#]*)"));return e?e[1]:""},e.removeParam=function(t,e){var n=e.split("?")[0],r=[],i=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==i){for(var o=(r=i.split("&")).length-1;o>=0;o-=1)r[o].split("=")[0]===t&&r.splice(o,1);n=n+"?"+r.join("&")}return n},e.createPromiseCallback=function(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t},e.execCallback=function(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n},e.printWarn=function(t,e){console.warn("["+a.getSdkName()+"]["+t+"]:"+e)},e.printError=function(t,e){console.error({code:t,msg:"["+a.getSdkName()+"]["+t+"]:"+e})},e.printInfo=function(t,e){console.log("["+a.getSdkName()+"]["+t+"]:"+e)},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"["+a.getSdkName()+"]["+t+"]:"+e}))},e.printGroupLog=function(t){var e=t.title,n=t.subtitle,r=void 0===n?"":n,i=t.content,o=void 0===i?[]:i,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,l=o;c<l.length;c++){var h=l[c],f=h.type,d=h.body;switch(f){case"info":console.log(d);break;case"warn":console.warn(d);break;case"error":console.error(d)}}a&&console.trace("stack trace:"),console.groupEnd()},e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86"+t}},function(t,e,n){var r;t.exports=(r=r||function(t,e){var n=Object.create||function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}}(),r={},i=r.lib={},o=i.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=i.WordArray=o.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,i=t.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var s=n[o>>>2]>>>24-o%4*8&255;e[r+o>>>2]|=s<<24-(r+o)%4*8}else for(o=0;o<i;o+=4)e[r+o>>>2]=n[o>>>2];return this.sigBytes+=i,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=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n,r=[],i=function(e){e=e;var n=987654321,r=4294967295;return function(){var i=((n=36969*(65535&n)+(n>>16)&r)<<16)+(e=18e3*(65535&e)+(e>>16)&r)&r;return i/=4294967296,(i+=.5)*(t.random()>.5?1:-1)}},o=0;o<e;o+=4){var a=i(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=[],i=0;i<n;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).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=[],i=0;i<n;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}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)}},l=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)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=l.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,c=t.min(4*u,i);if(u){for(var l=0;l<u;l+=o)this._doProcessBlock(r,l);var h=r.splice(0,u);n.sigBytes-=c}return new s.init(h,c)},clone:function(){var t=o.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),f=(i.Hasher=h.extend({cfg:o.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){h.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 f.HMAC.init(t,n).finalize(e)}}}),r.algo={});return r}(Math),r)},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,i(n(5),e),i(n(12),e),e.OATUH_LOGINTYPE="constants"},function(t,e,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.OAuth2Client=e.LocalCredentials=e.defaultStorage=e.generateRequestId=e.toResponseError=e.defaultRequest=void 0;var s=n(6),a=n(26),u=n(27);function c(){return a.uuidv4()}e.defaultRequest=function(t,e){return i(void 0,void 0,void 0,(function(){var n,r,i,a,u;return o(this,(function(o){switch(o.label){case 0:n=null,r=null,o.label=1;case 1:return o.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,o.sent().json()];case 3:return(null==(a=o.sent())?void 0:a.error)?(r=a).error_uri=new URL(t).pathname:n=a,[3,5];case 4:return u=o.sent(),r={error:s.ErrorType.UNREACHABLE,error_description:u.message,error_uri:new URL(t).pathname},[3,5];case 5:if(r)throw r;return[2,n]}}))}))},e.toResponseError=function(t,e){var n,r=e||{};if(t instanceof Error)n={error:r.error||s.ErrorType.LOCAL,error_description:r.error_description||t.message,error_uri:r.error_uri,details:r.details||t.stack};else{var i=t||{};n={error:r.error||i.error||s.ErrorType.LOCAL,error_description:r.error_description||i.error_description,error_uri:r.error_uri||i.error_uri,details:r.details||i.details}}return n},e.generateRequestId=c;var l=function(){function t(){}return t.prototype.getItem=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,window.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return window.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return i(this,void 0,void 0,(function(){return o(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 h(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}e.defaultStorage=new l;var f=function(){function t(t){this._credentials=null,this._singlePromise=new u.SinglePromise,this._tokenSectionName=t.tokenSectionName,this._storage=t.storage}return t.prototype.setCredentials=function(t){return i(this,void 0,void 0,(function(){var e;return o(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 i(this,void 0,void 0,(function(){var t=this;return o(this,(function(e){return[2,this._singlePromise.run("getCredentials",(function(){return i(t,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return h(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 i(this,void 0,void 0,(function(){var t=this;return o(this,(function(e){return[2,this._singlePromise.run("_getStorageCredentials",(function(){return i(t,void 0,void 0,(function(){var t,e;return o(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.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}();e.LocalCredentials=f;var d=function(){function t(n){this._singlePromise=new u.SinglePromise,this._apiOrigin=n.apiOrigin,this._clientId=n.clientId,this._retry=this._formatRetry(n.retry,t._defaultRetry),null!=n.baseRequest?this._baseRequest=n.baseRequest:this._baseRequest=e.defaultRequest,this._tokenInURL=n.tokenInURL,this._headers=n.headers,this._storage=n.storage||e.defaultStorage,this._localCredentials=new f({tokenSectionName:"credentials_"+n.clientId,storage:this._storage}),this._clientSecret=n.clientSecret,this._refreshTokenFunc=n.refreshTokenFunc||this._defaultRefreshTokenFunc}return t.prototype.setCredentials=function(t){return this._localCredentials.setCredentials(t)},t.prototype.getAccessToken=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return[4,this._getCredentials()];case 1:return(null==(t=e.sent())?void 0:t.access_token)?[2,Promise.resolve(t.access_token)]:[2,Promise.reject({error:s.ErrorType.UNAUTHENTICATED})]}}))}))},t.prototype.request=function(e,n){return i(this,void 0,void 0,(function(){var i,a,u,l,h,f,d;return o(this,(function(o){switch(o.label){case 0:return n||(n={}),i=this._formatRetry(n.retry,this._retry),n.headers=n.headers||{},this._headers&&(n.headers=r(r({},this._headers),n.headers)),n.headers["x-request-id"]||(n.headers["x-request-id"]=c()),n.headers["x-device-id"]?[3,2]:[4,this._getDeviceId()];case 1:a=o.sent(),n.headers["x-device-id"]=a,o.label=2;case 2:return(null==n?void 0:n.withCredentials)?[4,this._getCredentials()]:[3,4];case 3:return(u=o.sent())&&(this._tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token="+u.access_token):n.headers.Authorization=u.token_type+" "+u.access_token),[3,5];case 4:this._clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id="+this._clientId),o.label=5;case 5:e.startsWith("/")&&(e=this._apiOrigin+e),l=null,h=i+1,f=0,o.label=6;case 6:if(!(f<h))return[3,15];o.label=7;case 7:return o.trys.push([7,9,,12]),[4,this._baseRequest(e,n)];case 8:return l=o.sent(),[3,15];case 9:return d=o.sent(),n.withCredentials&&d&&d.error===s.ErrorType.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,11];case 10:return o.sent(),[2,Promise.reject(d)];case 11:return f!==i&&d&&"unreachable"===d.error?[3,12]:[2,Promise.reject(d)];case 12:return[4,this._sleep(t._retryInterval)];case 13:o.sent(),o.label=14;case 14:return f++,[3,6];case 15:return[2,l]}}))}))},t.prototype._checkRetry=function(e){var n=null;if(("number"!=typeof e||e<t._minRetry||e>t._maxRetry)&&(n={error:s.ErrorType.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 i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,new Promise((function(e){setTimeout((function(){e()}),t)}))]}))}))},t.prototype._refreshToken=function(t){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(n){return[2,this._singlePromise.run("_refreshToken",(function(){return i(e,void 0,void 0,(function(){var e,n;return o(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!==s.ErrorType.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 i(this,void 0,void 0,(function(){var e=this;return o(this,(function(n){return[2,this._singlePromise.run("_anonymous",(function(){return i(e,void 0,void 0,(function(){var e,n;return o(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!==s.ErrorType.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._getCredentials=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return[4,this._localCredentials.getCredentials()];case 1:return h(t=e.sent())?t&&"anonymous"===t.scope?[4,this._anonymousSignIn(t)]:[3,3]:[3,5];case 2:return t=e.sent(),[3,5];case 3:return[4,this._refreshToken(t)];case 4:t=e.sent(),e.label=5;case 5:return[2,t]}}))}))},t.prototype.getCredentialsSync=function(){return this._localCredentials._getStorageCredentialsSync()},t.prototype.getCredentialsAsync=function(){return this._localCredentials.getCredentials()},t.prototype.getScope=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return[4,this._localCredentials.getCredentials()];case 1:return null==(t=e.sent())?[2,this._unAuthenticatedError("credentials not found")]:[2,t.scope]}}))}))},t.prototype._getDeviceId=function(){return i(this,void 0,void 0,(function(){var t;return o(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=a.uuidv4(),[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){return Promise.reject({error:s.ErrorType.UNAUTHENTICATED,error_description:t})},t._defaultRetry=2,t._minRetry=0,t._maxRetry=5,t._retryInterval=1e3,t}();e.OAuth2Client=d},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var i="https:";e.setProtocol=function(t){i=t},e.getProtocol=function(){return i},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ErrorType=e.Syntax=void 0,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"}(e.Syntax||(e.Syntax={})),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"}(e.ErrorType||(e.ErrorType={}))},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(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=this&&this.__generator||function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.Auth=void 0;var o=n(29),s=n(4),a=n(30),u=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.OAuth2Client(r)}if(!e){var i=n.request.bind(n),o=new a.Captcha({clientId:t.clientId,request:i,storage:t.storage});e=o.request.bind(o)}this._config={apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:n,storage:t.storage||s.defaultStorage}}return t.prototype.signIn=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this._config.request(o.ApiUrls.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(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this._config.request(o.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:{}})];case 1:return t=e.sent(),[4,this._config.credentialsClient.setCredentials(t)];case 2:return e.sent(),[2,Promise.resolve(t)]}}))}))},t.prototype.signUp=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this._config.request(o.ApiUrls.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 r(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this._config.credentialsClient.getAccessToken()];case 1:return t=n.sent(),[4,this._config.request(o.ApiUrls.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 r(this,void 0,void 0,(function(){var e;return i(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(o.ApiUrls.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:!0,withCredentials:e})]}}))}))},t.prototype.verify=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.VERIFY_URL,{method:"POST",body:t})]}))}))},t.prototype.genProviderRedirectUri=function(t){return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){return e=o.ApiUrls.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 r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.PROVIDER_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.patchProviderToken=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]}))}))},t.prototype.signInWithProvider=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this._config.request(o.ApiUrls.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 r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.getUserProfile=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.getUserInfo()]}))}))},t.prototype.getUserInfo=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this._config.request(o.ApiUrls.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 r(this,void 0,void 0,(function(){var n;return i(this,(function(r){return n=o.ApiUrls.USER_ME_URL+"?"+t.parseParamsToSearch(e),[2,this._config.request(n,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.hasLoginState=function(){return r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._config.credentialsClient.getCredentialsAsync()]}))}))},t.prototype.transByProvider=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.grantToken=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.AUTH_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.getProviders=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._config.request(o.ApiUrls.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},t.prototype.unbindProvider=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.PROVIDER_UNBIND_URL+"/"+t.provider_id,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.checkPassword=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(""+o.ApiUrls.CHECK_PWD_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.bindPhone=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(""+o.ApiUrls.BIND_CONTACT_URL,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.bindEmail=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(""+o.ApiUrls.BIND_CONTACT_URL,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.setPassword=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(""+o.ApiUrls.AUTH_SET_PASSWORD,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.updatePasswordByOld=function(t){return r(this,void 0,void 0,(function(){var e;return i(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 r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(""+o.ApiUrls.SUDO_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.getCurUserVerification=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return t.target="CUR_USER",[2,this._config.request(o.ApiUrls.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]}))}))},t.prototype.changeBindedProvider=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.PROVIDER_LIST+"/"+t.provider_id+"/trans",{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})]}))}))},t.prototype.setUserProfile=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.queryUserProfile=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){return e=new URLSearchParams(t),[2,this._config.request(o.ApiUrls.USER_QUERY_URL+"?"+e.toString(),{method:"GET",withCredentials:!0})]}))}))},t.prototype.setCustomSignFunc=function(t){this._getCustomSignTicketFn=t},t.prototype.signInWithCustomTicket=function(){return r(this,void 0,void 0,(function(){var t;return i(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 r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.AUTH_RESET_PASSWORD,{method:"POST",body:t})]}))}))},t.prototype.deviceAuthorize=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.checkUsername=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]}))}))},t.prototype.checkIfUserExist=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){return e=new URLSearchParams(t),[2,this._config.request(o.ApiUrls.CHECK_IF_USER_EXIST+"?"+e.toString(),{method:"GET"})]}))}))},t.prototype.loginScope=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._config.credentialsClient.getScope()]}))}))},t.parseParamsToSearch=function(t){for(var e in t)t[e]||delete t[e];return new URLSearchParams(t).toString()},t}();e.Auth=u},function(t,e,n){"use strict";var r;n.r(e),n.d(e,"StorageType",(function(){return r})),n.d(e,"AbstractSDKRequest",(function(){return i})),n.d(e,"AbstractStorage",(function(){return o})),n.d(e,"formatUrl",(function(){return s})),function(t){t.local="local",t.none="none",t.session="session"}(r||(r={}));var i=function(){},o=function(){};function s(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),i="";for(var o in n)""===i?!r&&(e+="?"):i+="&",i+=o+"="+encodeURIComponent(n[o]);return/^http(s)?\:\/\//.test(e+=i)?e:""+t+e}},function(t,e,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&i(e,t,n);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseOAuth=e.authModels=void 0;var a=n(6);Object.defineProperty(e,"Syntax",{enumerable:!0,get:function(){return a.Syntax}}),Object.defineProperty(e,"ErrorType",{enumerable:!0,get:function(){return a.ErrorType}});var u=n(4),c=n(4);Object.defineProperty(e,"defaultStorage",{enumerable:!0,get:function(){return c.defaultStorage}}),Object.defineProperty(e,"defaultRequest",{enumerable:!0,get:function(){return c.defaultRequest}}),Object.defineProperty(e,"toResponseError",{enumerable:!0,get:function(){return c.toResponseError}}),Object.defineProperty(e,"generateRequestId",{enumerable:!0,get:function(){return c.generateRequestId}}),Object.defineProperty(e,"OAuth2Client",{enumerable:!0,get:function(){return c.OAuth2Client}});var l=n(28);Object.defineProperty(e,"AuthClient",{enumerable:!0,get:function(){return l.AuthClient}});var h=n(7),f=n(7);Object.defineProperty(e,"Auth",{enumerable:!0,get:function(){return f.Auth}});var d=s(n(31));e.authModels=d;var p=function(t){var e=t.apiOrigin,n=t.clientId;this.oauth2client=new u.OAuth2Client({apiOrigin:e,clientId:n}),this.authApi=new h.Auth(r({credentialsClient:this.oauth2client},t))};e.CloudbaseOAuth=p},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.registerAuth=void 0;var r=n(11);e.registerAuth=r.registerAuth},function(t,e,n){"use strict";n.r(e),n.d(e,"LoginState",(function(){return m})),n.d(e,"Auth",(function(){return b})),n.d(e,"registerAuth",(function(){return w}));var r=n(0),i=n(9),o=function(){return(o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},s=function(t,e,n,r){var i,o=arguments.length,s=o<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--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,n,s):i(e,n))||s);return o>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(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(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,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},l=r.utils.printWarn,h=r.utils.throwError,f=r.constants.ERRORS,d=r.constants.COMMUNITY_SITE_URL,p=r.helpers.catchErrorsDecorator,_=r.events.CloudbaseEventEmitter,v="loginStateChanged",y=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 u(this,void 0,void 0,(function(){return c(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.email_verified=this._getLocalUserInfo("email_verified"),this.phone_number=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.created_from=this._getLocalUserInfo("created_from"),this.providers=this._getLocalUserInfo("providers"),[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return u(this,void 0,void 0,(function(){var t,e,n,r;return c(this,(function(i){switch(i.label){case 0:return t=this,[4,this._getLocalUserInfoAsync("uid")];case 1:return t.uid=i.sent(),e=this,[4,this._getLocalUserInfoAsync("gender")];case 2:return e.gender=i.sent(),this.picture=this._getLocalUserInfo("picture"),n=this,[4,this._getLocalUserInfoAsync("email")];case 3:return n.email=i.sent(),this.email_verified=this._getLocalUserInfo("email_verified"),this.phone_number=this._getLocalUserInfo("phone_number"),r=this,[4,this._getLocalUserInfoAsync("username")];case 4:return r.username=i.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.created_from=this._getLocalUserInfo("created_from"),this.providers=this._getLocalUserInfo("providers"),[2]}}))}))},t.prototype.update=function(t){return u(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return[4,this._oauthInstance.authApi.setUserProfile(o({},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&&h(f.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(){return u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e;return c(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()},s([p({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],t.prototype,"update",null),s([p({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[String,String]),a("design:returntype",void 0)],t.prototype,"updatePassword",null),s([p({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype",void 0)],t.prototype,"updateUsername",null),s([p({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],t.prototype,"refresh",null),t}(),m=function(){function t(t){var e=t.envId,n=t.cache,r=t.oauthInstance;e||h(f.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 u(this,void 0,void 0,(function(){return c(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}(),b=function(){function t(t){this._config=t,this._cache=t.cache,this._oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._oauthInstance.authApi.bindPhone(t)]}))}))},t.prototype.unbindProvider=function(t){return u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t){return u(this,void 0,void 0,(function(){return c(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}l(f.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return u(this,void 0,void 0,(function(){var t;return c(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(){return u(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this._oauthInstance.authApi.signInAnonymously()];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setCustomSignFunc=function(t){this._oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(){return u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&h(f.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 u(this,void 0,void 0,(function(){var t;return c(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(),y.fire(v),[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 m({envId:this._config.env,cache:this._cache,oauthInstance:this._oauthInstance}):null;l(f.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this._oauthInstance.authApi.getLoginState()];case 1:return t.sent()?[2,new m({envId:this._config.env,cache:this._cache,oauthInstance:this._oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._oauthInstance.authApi.getUserInfo()]}))}))},t.prototype.bindWithProvider=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._oauthInstance.authApi.loginScope()]}))}))},t.prototype.onLoginStateChanged=function(t){return u(this,void 0,void 0,(function(){var e,n=this;return c(this,(function(r){switch(r.label){case 0:return y.on(v,(function(){return u(n,void 0,void 0,(function(){var e;return c(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 u(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return[4,(t=new m({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(),y.fire(v),[2,t]}}))}))},s([p({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),s([p({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],t.prototype,"unbindProvider",null),s([p({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],t.prototype,"bindEmail",null),s([p({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],t.prototype,"verify",null),s([p({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],t.prototype,"getVerification",null),s([p({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],t.prototype,"getCurrentUser",null),s([p({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],t.prototype,"signInAnonymously",null),s([p({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),s([p({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],t.prototype,"signUp",null),s([p({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),s([p({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],t.prototype,"signOut",null),s([p({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],t.prototype,"getLoginState",null),s([p({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],t.prototype,"getUserInfo",null),s([p({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+d]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",Promise)],t.prototype,"bindWithProvider",null),t}(),I={name:"auth",namespace:"auth",entity:function(t){if(void 0===t&&(t={region:"",persistence:"local"}),this.authInstance)return l(f.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 s=this.config,a=s.env,u=s.persistence,c=s.debug,h=s.clientId,d=new i.CloudbaseOAuth({clientId:h,apiOrigin:this.request.getBaseEndPoint()});return this.oauthInstance=d,this.authInstance=new b({env:a,region:t.region,persistence:u,debug:c,cache:this.cache,runtime:r,_fromApp:this,oauthInstance:d}),this.authInstance}};try{cloudbase.registerComponent(I)}catch(t){}function w(t){try{t.registerComponent(I)}catch(t){console.warn(t)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var s,a=o(n(14)),u=n(1);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(s=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t){for(var e=0,n=u.isArray(t)?t:[t];e<n.length;e++){var r=n[e],i=r.isMatch,o=r.genAdapter,s=r.runtime;if(i())return{adapter:o(),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:a.genAdapter(),runtime:s.WEB}}},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),o=this&&this.__assign||function(){return(o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=n(8),c=n(1),l=n(5),h=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,i=e.timeoutMsg,o=e.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=i||"请求超时",n._restrictedMethods=o||["get","post","upload","download"],n}return i(e,t),e.prototype.get=function(t){return this._request(o(o({},t),{method:"get"}),this._restrictedMethods.includes("get"))},e.prototype.post=function(t){return this._request(o(o({},t),{method:"post"}),this._restrictedMethods.includes("post"))},e.prototype.put=function(t){return this._request(o(o({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,i=new FormData;for(var s in e)i.append(s,e[s]);return i.append("key",r),i.append("file",n),this._request(o(o({},t),{data:i,method:"post"}),this._restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,n,r,i;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(o(o({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(i=document.createElement("a")).href=n,i.setAttribute("download",r),i.style.display="none",document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(n),document.body.removeChild(i),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype._request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(i){var o,s,a=t.url,u=t.headers,h=void 0===u?{}:u,f=t.data,d=t.responseType,p=t.withCredentials,_=t.body,v=t.onUploadProgress,y=c.formatUrl(l.getProtocol(),a,"get"===r?f:{}),g=new XMLHttpRequest;for(var m in g.open(r,y),d&&(g.responseType=d),h)g.setRequestHeader(m,h[m]);v&&g.upload.addEventListener("progress",v),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),i=e.join(": ");n[r]=i})),t.header=n,t.statusCode=g.status;try{t.data="blob"===d?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===d?g.response:g.responseText}clearTimeout(o),i(t)}},e&&n._timeout&&(o=setTimeout((function(){console.warn(n._timeoutMsg),g.abort()}),n._timeout)),s=c.isFormData(f)?f:"application/x-www-form-urlencoded"===h["content-type"]?c.toQueryString(f):_||(f?JSON.stringify(f):void 0),p&&(g.withCredentials=!0),g.send(s)}))},e}(u.AbstractSDKRequest);e.WebRequest=h,e.genAdapter=function(){return{root:window,reqClass:h,wsClass:WebSocket,localStorage:localStorage}}},function(t,e,n){var r;t.exports=(r=n(2),n(16),n(17),r.HmacSHA256)},function(t,e,n){var r;t.exports=(r=n(2),function(t){var e=r,n=e.lib,i=n.WordArray,o=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,i=0;i<64;)e(r)&&(i<8&&(a[i]=n(t.pow(r,.5))),u[i]=n(t.pow(r,1/3)),i++),r++}();var c=[],l=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],l=n[5],h=n[6],f=n[7],d=0;d<64;d++){if(d<16)c[d]=0|t[e+d];else{var p=c[d-15],_=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,v=c[d-2],y=(v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10;c[d]=_+c[d-7]+y+c[d-16]}var g=r&i^r&o^i&o,m=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=f+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&h)+u[d]+c[d];f=h,h=l,l=a,a=s+b|0,s=o,o=i,i=r,r=b+(m+g)|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+l|0,n[6]=n[6]+h|0,n[7]=n[7]+f|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=t.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=o._createHelper(l),e.HmacSHA256=o._createHmacHelper(l)}(Math),r.SHA256)},function(t,e,n){var r,i,o,s;t.exports=(r=n(2),o=(i=r).lib.Base,s=i.enc.Utf8,void(i.algo.HMAC=o.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 i=this._oKey=e.clone(),o=this._iKey=e.clone(),a=i.words,u=o.words,c=0;c<n;c++)a[c]^=1549556828,u[c]^=909522486;i.sigBytes=o.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,n=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(n))}})))},function(t,e,n){var r,i,o;t.exports=(o=n(2),i=(r=o).lib.WordArray,r.enc.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp();for(var i=[],o=0;o<n;o+=3)for(var s=(e[o>>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a<n;a++)i.push(r.charAt(s>>>6*(3-a)&63));var u=r.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.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,u=n[t.charCodeAt(s)]>>>6-s%4*2;r[o>>>2]|=(a|u)<<24-o%4*8,o++}return i.create(r,o)}(t,e,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},o.enc.Base64)},function(t,e,n){var r;t.exports=(r=n(2),r.enc.Utf8)},function(t,e,n){"use strict";(function(t){var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=n(8),u=n(1),c=n(3),l=function(t){function e(e){var n=t.call(this)||this;return n._root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return i(e,t),e.prototype.setItem=function(t,e){this._root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this._root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this._root.tcbCacheObject[t]},e.prototype.clear=function(){delete this._root.tcbCacheObject},e}(a.AbstractStorage);var h=function(){function e(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,i=t.keys,o=void 0===i?{}:i;this._platformInfo=r,this._storage||(this._persistence=this._platformInfo.adapter.primaryStorage||e,this._storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:(u.printWarn(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(e.root));case"none":return new l(e.root);default:return e.localStorage?e.localStorage:(u.printWarn(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(e.root))}}(this._persistence,this._platformInfo.adapter),this.keys=o)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this._storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this._persistence},enumerable:!1,configurable:!0}),e.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this._storage)try{var r={version:n||"localCachev1",content:e};this._storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"["+c.getSdkName()+"]["+c.ERRORS.OPERATION_FAIL+"]setStore failed",info:t}))}}else u.printWarn(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(t,e,n){return o(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:if(!this._storage)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),r={version:n||"localCachev1",content:e},[4,this._storage.setItem(t,JSON.stringify(r))];case 2:return i.sent(),[3,4];case 3:return i.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 i=this._storage.getItem(e);return i&&i.indexOf(n)>=0?JSON.parse(i).content:""}u.printWarn(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,n){var r;return o(this,void 0,void 0,(function(){var i;return s(this,(function(o){switch(o.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(i=o.sent())&&i.indexOf(n)>=0?[2,JSON.parse(i).content]:[2,""]}}))}))},e.prototype.removeStore=function(t){"async"!==this.mode?this._storage.removeItem(t):u.printWarn(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(t){return o(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},e}();e.CloudbaseCache=h}).call(this,n(21))},function(t,e){var n,r,i=t.exports={};function o(){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===o||!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:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(t){r=s}}();var u,c=[],l=!1,h=-1;function f(){l&&u&&(l=!1,u.length?c=u.concat(c):h=-1,c.length&&d())}function d(){if(!l){var t=a(f);l=!0;for(var e=c.length;e;){for(u=c,c=[];++h<e;)u&&u[h].run();h=-1,e=c.length}u=null,l=!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 p(t,e){this.fun=t,this.array=e}function _(){}i.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 p(t,e)),1!==c.length||l||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=_,i.addListener=_,i.once=_,i.off=_,i.removeListener=_,i.removeAllListeners=_,i.emit=_,i.prependListener=_,i.prependOnceListener=_,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),o=this&&this.__spreadArrays||function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=n(1);var a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var u=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return i(e,t),e}(a);e.IErrorEvent=u;var c=function(){function t(){this._listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this._listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this._listeners),this},t.prototype.fire=function(t,e){if(s.isInstanceOf(t,u))return console.error(t.error),this;var n=s.isString(t)?new a(t,e||{}):t,r=n.name;if(this._listens(r)){n.target=this;for(var i=0,c=this._listeners[r]?o(this._listeners[r]):[];i<c.length;i++){c[i].call(this,n)}}return this},t.prototype._listens=function(t){return this._listeners[t]&&this._listeners[t].length>0},t}();e.CloudbaseEventEmitter=c;var l=new c;e.addEventListener=function(t,e){l.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),l.fire(t,e)},e.removeEventListener=function(t,e){l.off(t,e)}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(24),e)},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(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=this&&this.__generator||function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var o=n(1),s=n(3),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function l(t){var e=t.err,n=t.className,r=t.methodName,i=t.sourceLink;if(!i)return null;var o,s=e.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]\\s*\\(.*\\)$"),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]"),h=s.findIndex((function(t){return u.test(t)}));if(-1!==h){var f=s.filter((function(t,e){return e>h}));f.unshift(s[h].replace(l,n+"."+r).replace(c,i)),(o=new Error).stack=(a?"@debugger":"Error")+"\n"+f.join("\n")}return o}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,a=t.customInfo,h=void 0===a?{}:a,f=t.title,d=t.messages,p=void 0===d?[]:d;return function(t,e,a){if(s.IS_DEBUG_MODE){var d=h.className||t.constructor.name,_=h.methodName||e,v=a.value,y=function(t){var e="",n=t.stack.split("\n"),r=n.findIndex((function(t){return u.test(t)}));if(-1!==r){var i=c.exec(n[r+1]||"");e=i?i[0]:""}return e}(new Error);a.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=l({err:new Error,className:d,methodName:_,sourceLink:y});try{return v.apply(this,t)}catch(t){var r=t,i=t.message,s=t.error,a=t.error_description,u={title:f||d+"."+_+" failed",content:[{type:"error",body:t}]};if(i&&/^\{.*\}$/.test(i)){var c=JSON.parse(i);u.subtitle=i,c.code&&(n?(n.code=c.code,n.msg=c.msg):(t.code=c.code,t.message=c.msg),r=n||t,u.content=p.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(u.subtitle=a,n?(n.code=s,n.msg=a):(t.code=s,t.message=a),r=n||t,u.content=p.map((function(t){return{type:"info",body:t}}))),o.printGroupLog(u),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r(this,void 0,void 0,(function(){var e,n,r,s,a,u,c,h;return i(this,(function(i){switch(i.label){case 0:e=l({err:new Error,className:d,methodName:_,sourceLink:y}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,v.apply(this,t)];case 2:return[2,i.sent()];case 3:throw n=i.sent(),r=n,s=n.message,a=n.error,u=n.error_description,c={title:f||d+"."+_+" failed",content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(h=JSON.parse(s),c.subtitle=h,h.code&&(e?(e.code=h.code,e.message=h.msg):(n.code=h.code,n.message=h.msg),r=e||n,c.content=p.map((function(t){return{type:"info",body:t}})))),a&&u&&(c.subtitle=u,e?(e.code=a,e.msg=u):(n.code=a,n.message=u),r=e||n,c.content=p.map((function(t){return{type:"info",body:t}}))),o.printGroupLog(c),r;case 4:return[2]}}))}))}}}}},function(t,e,n){"use strict";function r(t){this.message=t}n.r(e),n.d(e,"InvalidTokenError",(function(){return s})),r.prototype=new Error,r.prototype.name="InvalidCharacterError";var i="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,o=0,s=0,a="";i=e.charAt(s++);~i&&(n=o%4?64*n+i:i,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return a};function o(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(i(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return i(e)}}function s(t){this.message=t}s.prototype=new Error,s.prototype.name="InvalidTokenError",e.default=function(t,e){if("string"!=typeof t)throw new s("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(o(t.split(".")[n]))}catch(t){throw new s("Invalid token specified: "+t.message)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.uuidv4=void 0,e.uuidv4=function(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))}},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(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=this&&this.__generator||function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.SinglePromise=void 0;var o=function(){function t(){this._fnPromiseMap=new Map}return t.prototype.run=function(t,e){return r(this,void 0,void 0,(function(){var n,o=this;return i(this,(function(s){return(n=this._fnPromiseMap.get(t))||(n=new Promise((function(n,s){return r(o,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,4,5]),[4,this._runIdlePromise()];case 1:return i.sent(),r=e(),o=n,[4,r];case 2:return o.apply(void 0,[i.sent()]),[3,5];case 3:return a=i.sent(),s(a),[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}();e.SinglePromise=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AuthClient=void 0;var r=function(){};e.AuthClient=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ErrorType=e.VerificationUsages=e.ApiUrls=void 0,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"}(e.ApiUrls||(e.ApiUrls={})),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"}(e.VerificationUsages||(e.VerificationUsages={})),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.ErrorType||(e.ErrorType={}))},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(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=this&&this.__generator||function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.Captcha=void 0;var o=n(4),s=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this._getDefaultOpenURIWithCallback()),t.storage||(t.storage=o.defaultStorage),this._config=t,this._tokenSectionName="captcha_"+t.clientId}return t.prototype.request=function(t,e){return r(this,void 0,void 0,(function(){var n,r,o,s;return i(this,(function(i){switch(i.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=i.sent(),i.label=2;case 2:return i.trys.push([2,4,,8]),[4,this._config.request(r,e)];case 3:return o=i.sent(),[3,8];case 4:return"captcha_required"!==(s=i.sent()).error&&"captcha_invalid"!==s.error?[3,6]:[4,this._appendCaptchaTokenToURL(t,n,"captcha_invalid"===s.error)];case 5:return t=i.sent(),[2,this._config.request(t,e)];case 6:return[2,Promise.reject(s)];case 7:return[3,8];case 8: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 r(this,void 0,void 0,(function(){var e,n;return i(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 i=window.location,o=n.contentWindow.location;if(o.host+o.pathname===i.host+i.pathname){e.style.display="none";var s=new URLSearchParams(o.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 r(this,void 0,void 0,(function(){var n,r,o,s,a;return i(this,(function(i){switch(i.label){case 0:return t?[3,2]:[4,this._findCaptchaToken()];case 1:if(n=i.sent())return[2,n];i.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=i.sent()).captcha_token?(s={captcha_token:o.captcha_token,expires_in:o.expires_in},this._saveCaptchaToken(s),[2,o.captcha_token]):[4,this._config.openURIWithCallback(o.url)];case 4:return a=i.sent(),this._saveCaptchaToken(a),[2,a.captcha_token]}}))}))},t.prototype._appendCaptchaTokenToURL=function(t,e,n){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return[4,this._getCaptchaToken(n,e)];case 1:return r=i.sent(),t.indexOf("?")>0?t+="&captcha_token="+r:t+="?captcha_token="+r,[2,t]}}))}))},t.prototype._saveCaptchaToken=function(t){return r(this,void 0,void 0,(function(){var e;return i(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 r(this,void 0,void 0,(function(){var t,e;return i(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}();e.Captcha=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}])}));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_auth",[],e):"object"==typeof exports?exports.cloudbase_auth=e():t.cloudbase_auth=e()}("undefined"!=typeof window?window:this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.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 i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));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=7)}([function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return i(e,t),e},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.jwt=e.helpers=e.utils=e.events=e.cache=e.adapters=e.constants=void 0;var a=o(n(3));e.constants=a;var u=o(n(9));e.adapters=u;var c=o(n(16));e.cache=c;var h=o(n(18));e.events=h;var l=o(n(1));e.utils=l;var f=o(n(19));e.helpers=f;var d={decode:s(n(21)).default};e.jwt=d},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.createSign=e.formatUrl=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var i=r(n(11)),o=r(n(14)),s=r(n(15)),a=n(3);function u(t){var e=o.default.stringify(t);return e=(e=(e=e.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.formatUrl=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),i="";for(var o in n)""===i?!r&&(e+="?"):i+="&",i+=o+"="+encodeURIComponent(n[o]);return/^http(s)?\:\/\//.test(e+=i)?e:""+t+e},e.createSign=function(t,e){var n=u(s.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+u(s.default.parse(JSON.stringify(t)));return n+"."+u(i.default(n,e))},e.toQueryString=function(t){void 0===t&&(t={});var e=[];for(var n in t)e.push(n+"="+encodeURIComponent(t[n]));return e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var n=e||window.location.search,r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),i=n.substr(n.indexOf("?")+1).match(r);return null!=i?i[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]"+t+"=([^&#]*)"));return e?e[1]:""},e.removeParam=function(t,e){var n=e.split("?")[0],r=[],i=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==i){for(var o=(r=i.split("&")).length-1;o>=0;o-=1)r[o].split("=")[0]===t&&r.splice(o,1);n=n+"?"+r.join("&")}return n},e.createPromiseCallback=function(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t},e.execCallback=function(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n},e.printWarn=function(t,e){console.warn("["+a.getSdkName()+"]["+t+"]:"+e)},e.printError=function(t,e){console.error({code:t,msg:"["+a.getSdkName()+"]["+t+"]:"+e})},e.printInfo=function(t,e){console.log("["+a.getSdkName()+"]["+t+"]:"+e)},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"["+a.getSdkName()+"]["+t+"]:"+e}))},e.printGroupLog=function(t){var e=t.title,n=t.subtitle,r=void 0===n?"":n,i=t.content,o=void 0===i?[]:i,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,h=o;c<h.length;c++){var l=h[c],f=l.type,d=l.body;switch(f){case"info":console.log(d);break;case"warn":console.warn(d);break;case"error":console.error(d)}}a&&console.trace("stack trace:"),console.groupEnd()},e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86"+t}},function(t,e,n){var r;t.exports=(r=r||function(t,e){var n=Object.create||function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}}(),r={},i=r.lib={},o=i.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=i.WordArray=o.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,i=t.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var s=n[o>>>2]>>>24-o%4*8&255;e[r+o>>>2]|=s<<24-(r+o)%4*8}else for(o=0;o<i;o+=4)e[r+o>>>2]=n[o>>>2];return this.sigBytes+=i,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=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n,r=[],i=function(e){e=e;var n=987654321,r=4294967295;return function(){var i=((n=36969*(65535&n)+(n>>16)&r)<<16)+(e=18e3*(65535&e)+(e>>16)&r)&r;return i/=4294967296,(i+=.5)*(t.random()>.5?1:-1)}},o=0;o<e;o+=4){var a=i(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=[],i=0;i<n;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).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=[],i=0;i<n;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}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)}},h=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=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,c=t.min(4*u,i);if(u){for(var h=0;h<u;h+=o)this._doProcessBlock(r,h);var l=r.splice(0,u);n.sigBytes-=c}return new s.init(l,c)},clone:function(){var t=o.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),f=(i.Hasher=l.extend({cfg:o.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 f.HMAC.init(t,n).finalize(e)}}}),r.algo={});return r}(Math),r)},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,i(n(4),e),i(n(8),e),e.OATUH_LOGINTYPE="constants"},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var i="https:";e.setProtocol=function(t){i=t},e.getProtocol=function(){return i},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},function(t,e){},function(t,e,n){"use strict";var r;n.r(e),n.d(e,"StorageType",(function(){return r})),n.d(e,"AbstractSDKRequest",(function(){return i})),n.d(e,"AbstractStorage",(function(){return o})),n.d(e,"formatUrl",(function(){return s})),function(t){t.local="local",t.none="none",t.session="session"}(r||(r={}));var i=function(){},o=function(){};function s(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),i="";for(var o in n)""===i?!r&&(e+="?"):i+="&",i+=o+"="+encodeURIComponent(n[o]);return/^http(s)?\:\/\//.test(e+=i)?e:""+t+e}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.registerAuth=void 0;var r=n(22);e.registerAuth=r.registerAuth},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var s,a=o(n(10)),u=n(1);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(s=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t){for(var e=0,n=u.isArray(t)?t:[t];e<n.length;e++){var r=n[e],i=r.isMatch,o=r.genAdapter,s=r.runtime;if(i())return{adapter:o(),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:a.genAdapter(),runtime:s.WEB}}},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),o=this&&this.__assign||function(){return(o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=n(6),c=n(1),h=n(4),l=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,i=e.timeoutMsg,o=e.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=i||"请求超时",n._restrictedMethods=o||["get","post","upload","download"],n}return i(e,t),e.prototype.get=function(t){return this._request(o(o({},t),{method:"get"}),this._restrictedMethods.includes("get"))},e.prototype.post=function(t){return this._request(o(o({},t),{method:"post"}),this._restrictedMethods.includes("post"))},e.prototype.put=function(t){return this._request(o(o({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,i=new FormData;for(var s in e)i.append(s,e[s]);return i.append("key",r),i.append("file",n),this._request(o(o({},t),{data:i,method:"post"}),this._restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,n,r,i;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(o(o({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(i=document.createElement("a")).href=n,i.setAttribute("download",r),i.style.display="none",document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(n),document.body.removeChild(i),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype._request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(i){var o,s,a=t.url,u=t.headers,l=void 0===u?{}:u,f=t.data,d=t.responseType,p=t.withCredentials,_=t.body,v=t.onUploadProgress,g=c.formatUrl(h.getProtocol(),a,"get"===r?f:{}),y=new XMLHttpRequest;for(var m in y.open(r,g),d&&(y.responseType=d),l)y.setRequestHeader(m,l[m]);v&&y.upload.addEventListener("progress",v),y.onreadystatechange=function(){var t={};if(4===y.readyState){var e=y.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),i=e.join(": ");n[r]=i})),t.header=n,t.statusCode=y.status;try{t.data="blob"===d?y.response:JSON.parse(y.responseText)}catch(e){t.data="blob"===d?y.response:y.responseText}clearTimeout(o),i(t)}},e&&n._timeout&&(o=setTimeout((function(){console.warn(n._timeoutMsg),y.abort()}),n._timeout)),s=c.isFormData(f)?f:"application/x-www-form-urlencoded"===l["content-type"]?c.toQueryString(f):_||(f?JSON.stringify(f):void 0),p&&(y.withCredentials=!0),y.send(s)}))},e}(u.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},function(t,e,n){var r;t.exports=(r=n(2),n(12),n(13),r.HmacSHA256)},function(t,e,n){var r;t.exports=(r=n(2),function(t){var e=r,n=e.lib,i=n.WordArray,o=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,i=0;i<64;)e(r)&&(i<8&&(a[i]=n(t.pow(r,.5))),u[i]=n(t.pow(r,1/3)),i++),r++}();var c=[],h=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],h=n[5],l=n[6],f=n[7],d=0;d<64;d++){if(d<16)c[d]=0|t[e+d];else{var p=c[d-15],_=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,v=c[d-2],g=(v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10;c[d]=_+c[d-7]+g+c[d-16]}var y=r&i^r&o^i&o,m=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=f+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&h^~a&l)+u[d]+c[d];f=l,l=h,h=a,a=s+b|0,s=o,o=i,i=r,r=b+(m+y)|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+h|0,n[6]=n[6]+l|0,n[7]=n[7]+f|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=t.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=o._createHelper(h),e.HmacSHA256=o._createHmacHelper(h)}(Math),r.SHA256)},function(t,e,n){var r,i,o,s;t.exports=(r=n(2),o=(i=r).lib.Base,s=i.enc.Utf8,void(i.algo.HMAC=o.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 i=this._oKey=e.clone(),o=this._iKey=e.clone(),a=i.words,u=o.words,c=0;c<n;c++)a[c]^=1549556828,u[c]^=909522486;i.sigBytes=o.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,n=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(n))}})))},function(t,e,n){var r,i,o;t.exports=(o=n(2),i=(r=o).lib.WordArray,r.enc.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp();for(var i=[],o=0;o<n;o+=3)for(var s=(e[o>>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a<n;a++)i.push(r.charAt(s>>>6*(3-a)&63));var u=r.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.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,u=n[t.charCodeAt(s)]>>>6-s%4*2;r[o>>>2]|=(a|u)<<24-o%4*8,o++}return i.create(r,o)}(t,e,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},o.enc.Base64)},function(t,e,n){var r;t.exports=(r=n(2),r.enc.Utf8)},function(t,e,n){"use strict";(function(t){var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=n(6),u=n(1),c=n(3),h=function(t){function e(e){var n=t.call(this)||this;return n._root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return i(e,t),e.prototype.setItem=function(t,e){this._root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this._root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this._root.tcbCacheObject[t]},e.prototype.clear=function(){delete this._root.tcbCacheObject},e}(a.AbstractStorage);var l=function(){function e(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,i=t.keys,o=void 0===i?{}:i;this._platformInfo=r,this._storage||(this._persistence=this._platformInfo.adapter.primaryStorage||e,this._storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:(u.printWarn(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(e.root));case"none":return new h(e.root);default:return e.localStorage?e.localStorage:(u.printWarn(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(e.root))}}(this._persistence,this._platformInfo.adapter),this.keys=o)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this._storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this._persistence},enumerable:!1,configurable:!0}),e.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this._storage)try{var r={version:n||"localCachev1",content:e};this._storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"["+c.getSdkName()+"]["+c.ERRORS.OPERATION_FAIL+"]setStore failed",info:t}))}}else u.printWarn(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(t,e,n){return o(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:if(!this._storage)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),r={version:n||"localCachev1",content:e},[4,this._storage.setItem(t,JSON.stringify(r))];case 2:return i.sent(),[3,4];case 3:return i.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 i=this._storage.getItem(e);return i&&i.indexOf(n)>=0?JSON.parse(i).content:""}u.printWarn(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,n){var r;return o(this,void 0,void 0,(function(){var i;return s(this,(function(o){switch(o.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(i=o.sent())&&i.indexOf(n)>=0?[2,JSON.parse(i).content]:[2,""]}}))}))},e.prototype.removeStore=function(t){"async"!==this.mode?this._storage.removeItem(t):u.printWarn(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(t){return o(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},e}();e.CloudbaseCache=l}).call(this,n(17))},function(t,e){var n,r,i=t.exports={};function o(){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===o||!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:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(t){r=s}}();var u,c=[],h=!1,l=-1;function f(){h&&u&&(h=!1,u.length?c=u.concat(c):l=-1,c.length&&d())}function d(){if(!h){var t=a(f);h=!0;for(var e=c.length;e;){for(u=c,c=[];++l<e;)u&&u[l].run();l=-1,e=c.length}u=null,h=!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 p(t,e){this.fun=t,this.array=e}function _(){}i.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 p(t,e)),1!==c.length||h||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=_,i.addListener=_,i.once=_,i.off=_,i.removeListener=_,i.removeAllListeners=_,i.emit=_,i.prependListener=_,i.prependOnceListener=_,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),o=this&&this.__spreadArrays||function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=n(1);var a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var u=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return i(e,t),e}(a);e.IErrorEvent=u;var c=function(){function t(){this._listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this._listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this._listeners),this},t.prototype.fire=function(t,e){if(s.isInstanceOf(t,u))return console.error(t.error),this;var n=s.isString(t)?new a(t,e||{}):t,r=n.name;if(this._listens(r)){n.target=this;for(var i=0,c=this._listeners[r]?o(this._listeners[r]):[];i<c.length;i++){c[i].call(this,n)}}return this},t.prototype._listens=function(t){return this._listeners[t]&&this._listeners[t].length>0},t}();e.CloudbaseEventEmitter=c;var h=new c;e.addEventListener=function(t,e){h.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),h.fire(t,e)},e.removeEventListener=function(t,e){h.off(t,e)}},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(20),e)},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(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=this&&this.__generator||function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var o=n(1),s=n(3),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function h(t){var e=t.err,n=t.className,r=t.methodName,i=t.sourceLink;if(!i)return null;var o,s=e.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]\\s*\\(.*\\)$"),h=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]"),l=s.findIndex((function(t){return u.test(t)}));if(-1!==l){var f=s.filter((function(t,e){return e>l}));f.unshift(s[l].replace(h,n+"."+r).replace(c,i)),(o=new Error).stack=(a?"@debugger":"Error")+"\n"+f.join("\n")}return o}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,a=t.customInfo,l=void 0===a?{}:a,f=t.title,d=t.messages,p=void 0===d?[]:d;return function(t,e,a){if(s.IS_DEBUG_MODE){var d=l.className||t.constructor.name,_=l.methodName||e,v=a.value,g=function(t){var e="",n=t.stack.split("\n"),r=n.findIndex((function(t){return u.test(t)}));if(-1!==r){var i=c.exec(n[r+1]||"");e=i?i[0]:""}return e}(new Error);a.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=h({err:new Error,className:d,methodName:_,sourceLink:g});try{return v.apply(this,t)}catch(t){var r=t,i=t.message,s=t.error,a=t.error_description,u={title:f||d+"."+_+" failed",content:[{type:"error",body:t}]};if(i&&/^\{.*\}$/.test(i)){var c=JSON.parse(i);u.subtitle=i,c.code&&(n?(n.code=c.code,n.msg=c.msg):(t.code=c.code,t.message=c.msg),r=n||t,u.content=p.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(u.subtitle=a,n?(n.code=s,n.msg=a):(t.code=s,t.message=a),r=n||t,u.content=p.map((function(t){return{type:"info",body:t}}))),o.printGroupLog(u),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r(this,void 0,void 0,(function(){var e,n,r,s,a,u,c,l;return i(this,(function(i){switch(i.label){case 0:e=h({err:new Error,className:d,methodName:_,sourceLink:g}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,v.apply(this,t)];case 2:return[2,i.sent()];case 3:throw n=i.sent(),r=n,s=n.message,a=n.error,u=n.error_description,c={title:f||d+"."+_+" failed",content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),c.subtitle=l,l.code&&(e?(e.code=l.code,e.message=l.msg):(n.code=l.code,n.message=l.msg),r=e||n,c.content=p.map((function(t){return{type:"info",body:t}})))),a&&u&&(c.subtitle=u,e?(e.code=a,e.msg=u):(n.code=a,n.message=u),r=e||n,c.content=p.map((function(t){return{type:"info",body:t}}))),o.printGroupLog(c),r;case 4:return[2]}}))}))}}}}},function(t,e,n){"use strict";function r(t){this.message=t}n.r(e),n.d(e,"InvalidTokenError",(function(){return s})),r.prototype=new Error,r.prototype.name="InvalidCharacterError";var i="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,o=0,s=0,a="";i=e.charAt(s++);~i&&(n=o%4?64*n+i:i,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return a};function o(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(i(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return i(e)}}function s(t){this.message=t}s.prototype=new Error,s.prototype.name="InvalidTokenError",e.default=function(t,e){if("string"!=typeof t)throw new s("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(o(t.split(".")[n]))}catch(t){throw new s("Invalid token specified: "+t.message)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"LoginState",(function(){return W})),n.d(e,"Auth",(function(){return F})),n.d(e,"registerAuth",(function(){return K}));var r,i,o=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"}(i||(i={}));var a=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(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,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,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(i){return(n=this._fnPromiseMap.get(t))||(n=new Promise((function(n,i){return a(r,void 0,void 0,(function(){var r,o,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(),o=n,[4,r];case 2:return o.apply(void 0,[a.sent()]),[3,5];case 3:return s=a.sent(),i(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}(),h=function(){return(h=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},l=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(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())}))},f=function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},d=function(t,e){return l(void 0,void 0,void 0,(function(){var n,r,o,s,a;return f(this,(function(u){switch(u.label){case 0:n=null,r=null,u.label=1;case 1:return u.trys.push([1,4,,5]),(o=Object.assign({},e)).method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body)),[4,fetch(t,o)];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:i.UNREACHABLE,error_description:a.message,error_uri:new URL(t).pathname},[3,5];case 5:if(r)throw r;return[2,n]}}))}))};var p=new(function(){function t(){}return t.prototype.getItem=function(t){return l(this,void 0,void 0,(function(){return f(this,(function(e){return[2,window.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return l(this,void 0,void 0,(function(){return f(this,(function(e){return window.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return l(this,void 0,void 0,(function(){return f(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 _(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 v,g,y,m=function(){function t(t){this._credentials=null,this._singlePromise=new c,this._tokenSectionName=t.tokenSectionName,this._storage=t.storage}return t.prototype.setCredentials=function(t){return l(this,void 0,void 0,(function(){var e;return f(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 f(this,(function(e){return[2,this._singlePromise.run("getCredentials",(function(){return l(t,void 0,void 0,(function(){var t;return f(this,(function(e){switch(e.label){case 0:return _(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 f(this,(function(e){return[2,this._singlePromise.run("_getStorageCredentials",(function(){return l(t,void 0,void 0,(function(){var t,e;return f(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.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}(),b=function(){function t(e){this._singlePromise=new c,this._apiOrigin=e.apiOrigin,this._clientId=e.clientId,this._retry=this._formatRetry(e.retry,t._defaultRetry),null!=e.baseRequest?this._baseRequest=e.baseRequest:this._baseRequest=d,this._tokenInURL=e.tokenInURL,this._headers=e.headers,this._storage=e.storage||p,this._localCredentials=new m({tokenSectionName:"credentials_"+e.clientId,storage:this._storage}),this._clientSecret=e.clientSecret,this._refreshTokenFunc=e.refreshTokenFunc||this._defaultRefreshTokenFunc}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;return f(this,(function(e){switch(e.label){case 0:return[4,this._getCredentials()];case 1:return(null==(t=e.sent())?void 0:t.access_token)?[2,Promise.resolve(t.access_token)]:[2,Promise.reject({error:i.UNAUTHENTICATED})]}}))}))},t.prototype.request=function(e,n){return l(this,void 0,void 0,(function(){var r,o,a,u,c,l,d;return f(this,(function(f){switch(f.label){case 0:return n||(n={}),r=this._formatRetry(n.retry,this._retry),n.headers=n.headers||{},this._headers&&(n.headers=h(h({},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:o=f.sent(),n.headers["x-device-id"]=o,f.label=2;case 2:return(null==n?void 0:n.withCredentials)?[4,this._getCredentials()]:[3,4];case 3:return(a=f.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),f.label=5;case 5:e.startsWith("/")&&(e=this._apiOrigin+e),u=null,c=r+1,l=0,f.label=6;case 6:if(!(l<c))return[3,15];f.label=7;case 7:return f.trys.push([7,9,,12]),[4,this._baseRequest(e,n)];case 8:return u=f.sent(),[3,15];case 9:return d=f.sent(),n.withCredentials&&d&&d.error===i.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,11];case 10:return f.sent(),[2,Promise.reject(d)];case 11:return l!==r&&d&&"unreachable"===d.error?[3,12]:[2,Promise.reject(d)];case 12:return[4,this._sleep(t._retryInterval)];case 13:f.sent(),f.label=14;case 14:return l++,[3,6];case 15:return[2,u]}}))}))},t.prototype._checkRetry=function(e){var n=null;if(("number"!=typeof e||e<t._minRetry||e>t._maxRetry)&&(n={error:i.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 f(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 f(this,(function(n){return[2,this._singlePromise.run("_refreshToken",(function(){return l(e,void 0,void 0,(function(){var e,n;return f(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!==i.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 f(this,(function(n){return[2,this._singlePromise.run("_anonymous",(function(){return l(e,void 0,void 0,(function(){var e,n;return f(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!==i.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._getCredentials=function(){return l(this,void 0,void 0,(function(){var t;return f(this,(function(e){switch(e.label){case 0:return[4,this._localCredentials.getCredentials()];case 1:return _(t=e.sent())?t&&"anonymous"===t.scope?[4,this._anonymousSignIn(t)]:[3,3]:[3,5];case 2:return t=e.sent(),[3,5];case 3:return[4,this._refreshToken(t)];case 4:t=e.sent(),e.label=5;case 5:return[2,t]}}))}))},t.prototype.getCredentialsSync=function(){return this._localCredentials._getStorageCredentialsSync()},t.prototype.getCredentialsAsync=function(){return this._localCredentials.getCredentials()},t.prototype.getScope=function(){return l(this,void 0,void 0,(function(){var t;return f(this,(function(e){switch(e.label){case 0:return[4,this._localCredentials.getCredentials()];case 1:return null==(t=e.sent())?[2,this._unAuthenticatedError("credentials not found")]:[2,t.scope]}}))}))},t.prototype.getGroups=function(){return l(this,void 0,void 0,(function(){var t;return f(this,(function(e){switch(e.label){case 0:return[4,this._localCredentials.getCredentials()];case 1:return null==(t=e.sent())?[2,this._unAuthenticatedError("credentials not found")]:[2,t.groups]}}))}))},t.prototype._getDeviceId=function(){return l(this,void 0,void 0,(function(){var t;return f(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){return Promise.reject({error:i.UNAUTHENTICATED,error_description:t})},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"}(v||(v={})),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"}(g||(g={})),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"}(y||(y={}));var I=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(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,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},E=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this._getDefaultOpenURIWithCallback()),t.storage||(t.storage=p),this._config=t,this._tokenSectionName="captcha_"+t.clientId}return t.prototype.request=function(t,e){return I(this,void 0,void 0,(function(){var n,r,i,o;return w(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,,8]),[4,this._config.request(r,e)];case 3:return i=s.sent(),[3,8];case 4:return"captcha_required"!==(o=s.sent()).error&&"captcha_invalid"!==o.error?[3,6]:[4,this._appendCaptchaTokenToURL(t,n,"captcha_invalid"===o.error)];case 5:return t=s.sent(),[2,this._config.request(t,e)];case 6:return[2,Promise.reject(o)];case 7:return[3,8];case 8:return[2,i]}}))}))},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 I(this,void 0,void 0,(function(){var e,n;return w(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 i=window.location,o=n.contentWindow.location;if(o.host+o.pathname===i.host+i.pathname){e.style.display="none";var s=new URLSearchParams(o.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 I(this,void 0,void 0,(function(){var n,r,i,o,s;return w(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(i=a.sent()).captcha_token?(o={captcha_token:i.captcha_token,expires_in:i.expires_in},this._saveCaptchaToken(o),[2,i.captcha_token]):[4,this._config.openURIWithCallback(i.url)];case 4:return s=a.sent(),this._saveCaptchaToken(s),[2,s.captcha_token]}}))}))},t.prototype._appendCaptchaTokenToURL=function(t,e,n){return I(this,void 0,void 0,(function(){var r;return w(this,(function(i){switch(i.label){case 0:return[4,this._getCaptchaToken(n,e)];case 1:return r=i.sent(),t.indexOf("?")>0?t+="&captcha_token="+r:t+="?captcha_token="+r,[2,t]}}))}))},t.prototype._saveCaptchaToken=function(t){return I(this,void 0,void 0,(function(){var e;return w(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 I(this,void 0,void 0,(function(){var t,e;return w(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(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(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,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},O=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 b(r)}if(!e){var i=n.request.bind(n),o=new E({clientId:t.clientId,request:i,storage:t.storage});e=o.request.bind(o)}this._config={apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:n,storage:t.storage||p}}return t.prototype.signIn=function(t){return S(this,void 0,void 0,(function(){var e;return R(this,(function(n){switch(n.label){case 0:return[4,this._config.request(v.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(){return S(this,void 0,void 0,(function(){var t;return R(this,(function(e){switch(e.label){case 0:return[4,this._config.request(v.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:{}})];case 1:return t=e.sent(),[4,this._config.credentialsClient.setCredentials(t)];case 2:return e.sent(),[2,Promise.resolve(t)]}}))}))},t.prototype.signUp=function(t){return S(this,void 0,void 0,(function(){var e;return R(this,(function(n){switch(n.label){case 0:return[4,this._config.request(v.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 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(v.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 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(v.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:!0,withCredentials:e})]}}))}))},t.prototype.verify=function(t){return S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(v.VERIFY_URL,{method:"POST",body:t})]}))}))},t.prototype.genProviderRedirectUri=function(t){return S(this,void 0,void 0,(function(){var e,n;return R(this,(function(r){return e=v.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 R(this,(function(e){return[2,this._config.request(v.PROVIDER_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.patchProviderToken=function(t){return S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(v.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]}))}))},t.prototype.signInWithProvider=function(t){return S(this,void 0,void 0,(function(){var e;return R(this,(function(n){switch(n.label){case 0:return[4,this._config.request(v.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 R(this,(function(e){return[2,this._config.request(v.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.getUserProfile=function(){return S(this,void 0,void 0,(function(){return R(this,(function(t){return[2,this.getUserInfo()]}))}))},t.prototype.getUserInfo=function(){return S(this,void 0,void 0,(function(){var t;return R(this,(function(e){switch(e.label){case 0:return[4,this._config.request(v.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 R(this,(function(r){return n=v.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 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 S(this,void 0,void 0,(function(){return R(this,(function(t){return[2,this._config.credentialsClient.getCredentialsAsync()]}))}))},t.prototype.transByProvider=function(t){return S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(v.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 R(this,(function(e){return[2,this._config.request(v.AUTH_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.getProviders=function(){return S(this,void 0,void 0,(function(){return R(this,(function(t){return[2,this._config.request(v.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},t.prototype.unbindProvider=function(t){return S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(v.PROVIDER_UNBIND_URL+"/"+t.provider_id,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.checkPassword=function(t){return S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(""+v.CHECK_PWD_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.bindPhone=function(t){return S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(""+v.BIND_CONTACT_URL,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.bindEmail=function(t){return S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(""+v.BIND_CONTACT_URL,{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.setPassword=function(t){return S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(""+v.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 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 S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(""+v.SUDO_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.getCurUserVerification=function(t){return S(this,void 0,void 0,(function(){return R(this,(function(e){return t.target="CUR_USER",[2,this._config.request(v.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]}))}))},t.prototype.changeBindedProvider=function(t){return S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(v.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 R(this,(function(e){return[2,this._config.request(v.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 R(this,(function(n){return e=new URLSearchParams(t),[2,this._config.request(v.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 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 S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(v.AUTH_RESET_PASSWORD,{method:"POST",body:t})]}))}))},t.prototype.deviceAuthorize=function(t){return S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(v.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.checkUsername=function(t){return S(this,void 0,void 0,(function(){return R(this,(function(e){return[2,this._config.request(v.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]}))}))},t.prototype.checkIfUserExist=function(t){return S(this,void 0,void 0,(function(){var e;return R(this,(function(n){return e=new URLSearchParams(t),[2,this._config.request(v.CHECK_IF_USER_EXIST+"?"+e.toString(),{method:"GET"})]}))}))},t.prototype.loginScope=function(){return S(this,void 0,void 0,(function(){return R(this,(function(t){return[2,this._config.credentialsClient.getScope()]}))}))},t.prototype.loginGroups=function(){return S(this,void 0,void 0,(function(){return R(this,(function(t){return[2,this._config.credentialsClient.getGroups()]}))}))},t.parseParamsToSearch=function(t){for(var e in t)t[e]||delete t[e];return new URLSearchParams(t).toString()},t}(),A=(n(5),function(){return(A=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)}),T=function(t){var e=t.apiOrigin,n=t.clientId;this.oauth2client=new b({apiOrigin:e,clientId:n}),this.authApi=new O(A({credentialsClient:this.oauth2client},t))},P=function(){return(P=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},U=function(t,e,n,r){var i,o=arguments.length,s=o<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--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,n,s):i(e,n))||s);return o>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)},N=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},L=function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},k=o.utils.printWarn,x=o.utils.throwError,D=o.constants.ERRORS,j=o.constants.COMMUNITY_SITE_URL,M=o.helpers.catchErrorsDecorator,q=o.events.CloudbaseEventEmitter,H="loginStateChanged",V=new q,B=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 N(this,void 0,void 0,(function(){return L(this,(function(t){return this.uid=this._getLocalUserInfo("uid"),this.gender=this._getLocalUserInfo("gender"),this.picture=this._getLocalUserInfo("picture"),this.email=this._getLocalUserInfo("email"),this.email_verified=this._getLocalUserInfo("email_verified"),this.phone_number=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.created_from=this._getLocalUserInfo("created_from"),this.providers=this._getLocalUserInfo("providers"),[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return N(this,void 0,void 0,(function(){var t,e,n,r;return L(this,(function(i){switch(i.label){case 0:return t=this,[4,this._getLocalUserInfoAsync("uid")];case 1:return t.uid=i.sent(),e=this,[4,this._getLocalUserInfoAsync("gender")];case 2:return e.gender=i.sent(),this.picture=this._getLocalUserInfo("picture"),n=this,[4,this._getLocalUserInfoAsync("email")];case 3:return n.email=i.sent(),this.email_verified=this._getLocalUserInfo("email_verified"),this.phone_number=this._getLocalUserInfo("phone_number"),r=this,[4,this._getLocalUserInfoAsync("username")];case 4:return r.username=i.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.created_from=this._getLocalUserInfo("created_from"),this.providers=this._getLocalUserInfo("providers"),[2]}}))}))},t.prototype.update=function(t){return N(this,void 0,void 0,(function(){var e;return L(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&&x(D.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(){return N(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return[4,this._oauthInstance.authApi.getUserInfo()];case 1:return t=e.sent(),this._setLocalUserInfo(t),[2,t]}}))}))},t.prototype._getLocalUserInfo=function(t){var e=this._cache.keys.userInfoKey;return this._cache.getStore(e)[t]},t.prototype._getLocalUserInfoAsync=function(t){return N(this,void 0,void 0,(function(){var e;return L(this,(function(n){switch(n.label){case 0:return e=this._cache.keys.userInfoKey,[4,this._cache.getStoreAsync(e)];case 1:return[2,n.sent()[t]]}}))}))},t.prototype._setUserInfo=function(){var t=this,e=this._cache.keys.userInfoKey,n=this._cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username"].forEach((function(e){t[e]=n[e]}))},t.prototype._setLocalUserInfo=function(t){var e=this._cache.keys.userInfoKey;this._cache.setStore(e,t),this._setUserInfo()},U([M({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"update",null),U([M({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[String,String]),C("design:returntype",void 0)],t.prototype,"updatePassword",null),U([M({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",void 0)],t.prototype,"updateUsername",null),U([M({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"refresh",null),t}(),W=function(){function t(t){var e=t.envId,n=t.cache,r=t.oauthInstance;e||x(D.INVALID_PARAMS,"envId is not defined"),this._cache=n,this._oauthInstance=r,this.user=new B({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 N(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,null===(t=this._oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}}))}))},t}(),F=function(){function t(t){this._config=t,this._cache=t.cache,this._oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.bindPhone(t)]}))}))},t.prototype.unbindProvider=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.unbindProvider(t)]}))}))},t.prototype.bindEmail=function(t){return this._oauthInstance.authApi.bindEmail(t)},t.prototype.verify=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.getVerification(t)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this._cache.mode){var t=this.hasLoginState();return t&&t.user||null}k(D.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return N(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return[4,this.getLoginState()];case 1:return(t=e.sent())?[4,t.user.checkLocalInfoAsync()]:[3,3];case 2:return e.sent(),[2,t.user||null];case 3:return[2,null]}}))}))},t.prototype.signInAnonymously=function(){return N(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this._oauthInstance.authApi.signInAnonymously()];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setCustomSignFunc=function(t){this._oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(){return N(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this._oauthInstance.authApi.signInWithCustomTicket()];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signIn=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this._oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signUp=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this._oauthInstance.authApi.signUp(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setPassword=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&x(D.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 N(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return t=this._cache.keys.userInfoKey,[4,this._oauthInstance.authApi.signOut()];case 1:return e.sent(),[4,this._cache.removeStoreAsync(t)];case 2:return e.sent(),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 W({envId:this._config.env,cache:this._cache,oauthInstance:this._oauthInstance}):null;k(D.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return N(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this._oauthInstance.authApi.getLoginState()];case 1:return t.sent()?[2,new W({envId:this._config.env,cache:this._cache,oauthInstance:this._oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(){return N(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this._oauthInstance.authApi.getUserInfo()]}))}))},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return N(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this._oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this._config.env}]}}))}))},t.prototype.grantProviderToken=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this._oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.grantToken=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this._oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this._oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return N(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this._oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return N(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this._oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return N(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this._oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return N(this,void 0,void 0,(function(){var e,n=this;return L(this,(function(r){switch(r.label){case 0:return V.on(H,(function(){return N(n,void 0,void 0,(function(){var e;return L(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=r.sent(),t.call(this,e),[2]}}))}))},t.prototype.createLoginState=function(){return N(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return[4,(t=new W({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([M({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),U([M({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"unbindProvider",null),U([M({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",void 0)],t.prototype,"bindEmail",null),U([M({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"verify",null),U([M({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"getVerification",null),U([M({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"getCurrentUser",null),U([M({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"signInAnonymously",null),U([M({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),U([M({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"signUp",null),U([M({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),U([M({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"signOut",null),U([M({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"getLoginState",null),U([M({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],t.prototype,"getUserInfo",null),U([M({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+j]}),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",Promise)],t.prototype,"bindWithProvider",null),t}(),G={name:"auth",namespace:"auth",entity:function(t){if(void 0===t&&(t={region:"",persistence:"local"}),this.authInstance)return k(D.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var e=this.platform,n=e.adapter,r=e.runtime,i=t.persistence||n.primaryStorage;i&&i!==this.config.persistence&&this.updateConfig({persistence:i});var o=this.config,s=o.env,a=o.persistence,u=o.debug,c=o.clientId,h=new T({clientId:c,apiOrigin:this.request.getBaseEndPoint()});return this.oauthInstance=h,this.authInstance=new F({env:s,region:t.region,persistence:a,debug:u,cache:this.cache,runtime:r,_fromApp:this,oauthInstance:h}),this.authInstance}};try{cloudbase.registerComponent(G)}catch(t){}function K(t){try{t.registerComponent(G)}catch(t){console.warn(t)}}}])}));