@cloudbase/js-sdk 1.7.1 → 2.0.0-alpha.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(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_auth",[],t):"object"==typeof exports?exports.cloudbase_auth=t():e.cloudbase_auth=t()}("undefined"!=typeof window?window:this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.helpers=t.utils=t.events=t.cache=t.adapters=t.constants=void 0;var s=i(n(3));t.constants=s;var c=i(n(8));t.adapters=c;var a=i(n(15));t.cache=a;var u=i(n(17));t.events=u;var h=i(n(1));t.utils=h;var f=i(n(18));t.helpers=f},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.createSign=t.formatUrl=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=r(n(10)),i=r(n(13)),s=r(n(14)),c=n(3);function a(e){var t=i.default.stringify(e);return t=(t=(t=t.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t},t.createSign=function(e,t){var n=a(s.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+a(s.default.parse(JSON.stringify(e)));return n+"."+a(o.default(n,t))},t.toQueryString=function(e){void 0===e&&(e={});var t=[];for(var n in e)t.push(n+"="+encodeURIComponent(e[n]));return t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var n=t||window.location.search,r=new RegExp("(^|&)"+e+"=([^&]*)(&|$)"),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]"+e+"=([^&#]*)"));return t?t[1]:""},t.removeParam=function(e,t){var n=t.split("?")[0],r=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===e&&r.splice(i,1);n=n+"?"+r.join("&")}return n},t.createPromiseCallback=function(){var e;if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e},t.execCallback=function(e,t,n){if(void 0===n&&(n=null),e&&"function"==typeof e)return e(t,n);if(t)throw t;return n},t.printWarn=function(e,t){console.warn("["+c.getSdkName()+"]["+e+"]:"+t)},t.printError=function(e,t){console.error({code:e,msg:"["+c.getSdkName()+"]["+e+"]:"+t})},t.printInfo=function(e,t){console.log("["+c.getSdkName()+"]["+e+"]:"+t)},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"["+c.getSdkName()+"]["+e+"]:"+t}))},t.printGroupLog=function(e){var t=e.title,n=e.subtitle,r=void 0===n?"":n,o=e.content,i=void 0===o?[]:o,s=e.printTrace,c=void 0!==s&&s,a=e.collapsed;void 0!==a&&a?console.groupCollapsed(t,r):console.group(t,r);for(var u=0,h=i;u<h.length;u++){var f=h[u],l=f.type,p=f.body;switch(l){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}c&&console.trace("stack trace:"),console.groupEnd()},t.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},t.transformPhone=function(e){return"+86"+e}},function(e,t,n){var r;e.exports=(r=r||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),r={},o=r.lib={},i=o.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=o.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||a).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[r+i>>>2]|=s<<24-(r+i)%4*8}else for(i=0;i<o;i+=4)t[r+i>>>2]=n[i>>>2];return this.sigBytes+=o,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],o=function(t){t=t;var n=987654321,r=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},i=0;i<t;i+=4){var c=o(4294967296*(n||e.random()));n=987654071*c(),r.push(4294967296*c()|0)}return new s.init(r,t)}}),c=r.enc={},a=c.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},u=c.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},h=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},f=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,c=o/(4*i),a=(c=t?e.ceil(c):e.max((0|c)-this._minBufferSize,0))*i,u=e.min(4*a,o);if(a){for(var h=0;h<a;h+=i)this._doProcessBlock(r,h);var f=r.splice(0,a);n.sigBytes-=u}return new s.init(f,u)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),l=(o.Hasher=f.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new l.HMAC.init(e,n).finalize(t)}}}),r.algo={});return r}(Math),r)},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(4),t),o(n(7),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var r="@cloudbase/js-sdk";t.setSdkName=function(e){r=e},t.getSdkName=function(){return r};var o="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";t.setProtocol=function(e){o=e},t.getProtocol=function(){return o},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},function(e,t,n){"use strict";var r;n.r(t),n.d(t,"StorageType",(function(){return r})),n.d(t,"AbstractSDKRequest",(function(){return o})),n.d(t,"AbstractStorage",(function(){return i})),n.d(t,"formatUrl",(function(){return s})),function(e){e.local="local",e.none="none",e.session="session"}(r||(r={}));var o=function(){},i=function(){};function s(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.registerProvider=t.registerAuth=void 0;var r=n(20);t.registerAuth=r.registerAuth,t.registerProvider=r.registerProvider},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var s,c=i(n(9)),a=n(1);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(s=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e){for(var t=0,n=a.isArray(e)?e:[e];t<n.length;t++){var r=n[t],o=r.isMatch,i=r.genAdapter,s=r.runtime;if(o())return{adapter:i(),runtime:s}}},t.useDefaultAdapter=function(){return{adapter:c.genAdapter(),runtime:s.WEB}}},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},c=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var a=n(5),u=n(1),h=n(4),f=function(e){function t(t){var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return o(t,e),t.prototype.get=function(e){return this._request(i(i({},e),{method:"get"}),this._restrictedMethods.includes("get"))},t.prototype.post=function(e){return this._request(i(i({},e),{method:"post"}),this._restrictedMethods.includes("post"))},t.prototype.put=function(e){return this._request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,n=e.file,r=e.name,o=new FormData;for(var s in t)o.append(s,t[s]);return o.append("key",r),o.append("file",n),this._request(i(i({},e),{data:o,method:"post"}),this._restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,(function(){var t,n,r,o;return c(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,n=window.URL.createObjectURL(new Blob([t])),r=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype._request=function(e,t){var n=this;void 0===t&&(t=!1);var r=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,c=e.url,a=e.headers,f=void 0===a?{}:a,l=e.data,p=e.responseType,d=e.withCredentials,y=e.body,g=e.onUploadProgress,_=u.formatUrl(h.getProtocol(),c,"get"===r?l:{}),v=new XMLHttpRequest;for(var m in v.open(r,_),p&&(v.responseType=p),f)v.setRequestHeader(m,f[m]);g&&v.upload.addEventListener("progress",g),v.onreadystatechange=function(){var e={};if(4===v.readyState){var t=v.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};t.forEach((function(e){var t=e.split(": "),r=t.shift().toLowerCase(),o=t.join(": ");n[r]=o})),e.header=n,e.statusCode=v.status;try{e.data="blob"===p?v.response:JSON.parse(v.responseText)}catch(t){e.data="blob"===p?v.response:v.responseText}clearTimeout(i),o(e)}},t&&n._timeout&&(i=setTimeout((function(){console.warn(n._timeoutMsg),v.abort()}),n._timeout)),s=u.isFormData(l)?l:"application/x-www-form-urlencoded"===f["content-type"]?u.toQueryString(l):y||(l?JSON.stringify(l):void 0),d&&(v.withCredentials=!0),v.send(s)}))},t}(a.AbstractSDKRequest);t.WebRequest=f,t.genAdapter=function(){return{root:window,reqClass:f,wsClass:WebSocket,localStorage:localStorage,sessionStorage:sessionStorage}}},function(e,t,n){var r;e.exports=(r=n(2),n(11),n(12),r.HmacSHA256)},function(e,t,n){var r;e.exports=(r=n(2),function(e){var t=r,n=t.lib,o=n.WordArray,i=n.Hasher,s=t.algo,c=[],a=[];!function(){function t(t){for(var n=e.sqrt(t),r=2;r<=n;r++)if(!(t%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,o=0;o<64;)t(r)&&(o<8&&(c[o]=n(e.pow(r,.5))),a[o]=n(e.pow(r,1/3)),o++),r++}();var u=[],h=s.SHA256=i.extend({_doReset:function(){this._hash=new o.init(c.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],c=n[4],h=n[5],f=n[6],l=n[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var d=u[p-15],y=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=u[p-2],_=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;u[p]=y+u[p-7]+_+u[p-16]}var v=r&o^r&i^o&i,m=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=l+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&h^~c&f)+a[p]+u[p];l=f,f=h,h=c,c=s+b|0,s=i,i=o,o=r,r=b+(m+v)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+c|0,n[5]=n[5]+h|0,n[6]=n[6]+f|0,n[7]=n[7]+l|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(h),t.HmacSHA256=i._createHmacHelper(h)}(Math),r.SHA256)},function(e,t,n){var r,o,i,s;e.exports=(r=n(2),i=(o=r).lib.Base,s=o.enc.Utf8,void(o.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=s.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),c=o.words,a=i.words,u=0;u<n;u++)c[u]^=1549556828,a[u]^=909522486;o.sigBytes=i.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))},function(e,t,n){var r,o,i;e.exports=(i=n(2),o=(r=i).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,n=e.sigBytes,r=this._map;e.clamp();for(var o=[],i=0;i<n;i+=3)for(var s=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,c=0;c<4&&i+.75*c<n;c++)o.push(r.charAt(s>>>6*(3-c)&63));var a=r.charAt(64);if(a)for(;o.length%4;)o.push(a);return o.join("")},parse:function(e){var t=e.length,n=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var i=0;i<n.length;i++)r[n.charCodeAt(i)]=i}var s=n.charAt(64);if(s){var c=e.indexOf(s);-1!==c&&(t=c)}return function(e,t,n){for(var r=[],i=0,s=0;s<t;s++)if(s%4){var c=n[e.charCodeAt(s-1)]<<s%4*2,a=n[e.charCodeAt(s)]>>>6-s%4*2;r[i>>>2]|=(c|a)<<24-i%4*8,i++}return o.create(r,i)}(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)},function(e,t,n){var r;e.exports=(r=n(2),r.enc.Utf8)},function(e,t,n){"use strict";(function(e){var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var c=n(5),a=n(1),u=n(3),h=function(e){function t(t){var n=e.call(this)||this;return n._root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return o(t,e),t.prototype.setItem=function(e,t){this._root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this._root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this._root.tcbCacheObject[e]},t.prototype.clear=function(){delete this._root.tcbCacheObject},t}(c.AbstractStorage);function f(e,t){switch(e){case"local":return t.localStorage?t.localStorage:(a.printWarn(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(t.root));case"none":return new h(t.root);case"session":return t.sessionStorage?t.sessionStorage:(a.printWarn(u.ERRORS.INVALID_PARAMS,"sessionStorage is not supported on current platform"),new h(t.root));default:return t.localStorage?t.localStorage:(a.printWarn(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(t.root))}}var l=function(){function t(e){this.keys={};var t=e.persistence,n=e.platformInfo,r=void 0===n?{}:n,o=e.keys,i=void 0===o?{}:o,s=e.alwaysLocalKeys,c=void 0===s?[]:s;this._platformInfo=r,this._alwaysLocalKeys=c,this._storage||(this._persistence=r.adapter.primaryStorage||t,this._storage=f(this._persistence,r.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this._storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this._persistence},enumerable:!1,configurable:!0}),t.prototype.updatePersistence=function(e){if("async"!==this.mode){if(e!==this._persistence){var t="local"===this._persistence;this._persistence=e;var n=f(e,this._platformInfo.adapter);for(var r in this.keys){var o=this.keys[r];if(!t||!this._alwaysLocalKeys.includes(r)){var i=this._storage.getItem(o);a.isUndefined(i)||a.isNull(i)||(n.setItem(o,i),this._storage.removeItem(o))}}this._storage=n}}else a.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use updatePersistenceAsync insteed")},t.prototype.updatePersistenceAsync=function(e){return i(this,void 0,void 0,(function(){var t,n,r,o,i,c,u,h;return s(this,(function(s){switch(s.label){case 0:if(e===this._persistence)return[2];for(o in t="local"===this._persistence,this._persistence=e,n=f(e,this._platformInfo.adapter),r=[],this.keys)r.push(o);i=0,s.label=1;case 1:return i<r.length?(c=r[i],u=this.keys[c],t&&this._alwaysLocalKeys.includes(c)?[3,4]:[4,this._storage.getItem(u)]):[3,5];case 2:return h=s.sent(),a.isUndefined(h)||a.isNull(h)?[3,4]:(n.setItem(u,h),[4,this._storage.removeItem(u)]);case 3:s.sent(),s.label=4;case 4:return i++,[3,1];case 5:return this._storage=n,[2]}}))}))},t.prototype.setStore=function(e,t,n){if("async"!==this.mode){if(this._storage)try{var r={version:n||"localCachev1",content:t};this._storage.setItem(e,JSON.stringify(r))}catch(e){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"["+u.getSdkName()+"]["+u.ERRORS.OPERATION_FAIL+"]setStore failed",info:e}))}}else a.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(e,t,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:if(!this._storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:t},[4,this._storage.setItem(e,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,n){var r;if("async"!==this.mode){try{if(void 0!==e&&(null===(r=e.env)||void 0===r?void 0:r.tcb_token))return e.env.tcb_token;if(!this._storage)return""}catch(e){return""}n=n||"localCachev1";var o=this._storage.getItem(t);return o&&o.indexOf(n)>=0?JSON.parse(o).content:""}a.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,n){var r;return i(this,void 0,void 0,(function(){var o;return s(this,(function(i){switch(i.label){case 0:try{if(void 0!==e&&(null===(r=e.env)||void 0===r?void 0:r.tcb_token))return[2,e.env.tcb_token];if(!this._storage)return[2,""]}catch(e){return[2,""]}return n=n||"localCachev1",[4,this._storage.getItem(t)];case 1:return(o=i.sent())&&o.indexOf(n)>=0?[2,JSON.parse(o).content]:[2,""]}}))}))},t.prototype.removeStore=function(e){"async"!==this.mode?this._storage.removeItem(e):a.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},t}();t.CloudbaseCache=l}).call(this,n(16))},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function c(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,u=[],h=!1,f=-1;function l(){h&&a&&(h=!1,a.length?u=a.concat(u):f=-1,u.length&&p())}function p(){if(!h){var e=c(l);h=!0;for(var t=u.length;t;){for(a=u,u=[];++f<t;)a&&a[f].run();f=-1,t=u.length}a=null,h=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function y(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new d(e,t)),1!==u.length||h||c(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,c=i.length;s<c;s++,o++)r[o]=i[s];return r};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=n(1);var c=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=c;var a=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return o(t,e),t}(c);t.IErrorEvent=a;var u=function(){function e(){this._listeners={}}return e.prototype.on=function(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this},e.prototype.off=function(e,t){return function(e,t,n){if(null==n?void 0:n[e]){var r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}(e,t,this._listeners),this},e.prototype.fire=function(e,t){if(s.isInstanceOf(e,a))return console.error(e.error),this;var n=s.isString(e)?new c(e,t||{}):e,r=n.name;if(this._listens(r)){n.target=this;for(var o=0,u=this._listeners[r]?i(this._listeners[r]):[];o<u.length;o++){u[o].call(this,n)}}return this},e.prototype._listens=function(e){return this._listeners[e]&&this._listeners[e].length>0},e}();t.CloudbaseEventEmitter=u;var h=new u;t.addEventListener=function(e,t){h.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),h.fire(e,t)},t.removeEventListener=function(e,t){h.off(e,t)}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(19),t)},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=n(1),s=n(3),c=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(c=-1!==navigator.userAgent.indexOf("Firefox"));var a=c?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function h(e){var t=e.err,n=e.className,r=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),a=c?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]\\s*\\(.*\\)$"),h=c?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]"),f=s.findIndex((function(e){return a.test(e)}));if(-1!==f){var l=s.filter((function(e,t){return t>f}));l.unshift(s[f].replace(h,n+"."+r).replace(u,o)),(i=new Error).stack=(c?"@debugger":"Error")+"\n"+l.join("\n")}return i}t.catchErrorsDecorator=function(e){var t=e.mode,n=void 0===t?"async":t,c=e.customInfo,f=void 0===c?{}:c,l=e.title,p=e.messages,d=void 0===p?[]:p;return function(e,t,c){if(s.IS_DEBUG_MODE){var p=f.className||e.constructor.name,y=f.methodName||t,g=c.value,_=function(e){var t="",n=e.stack.split("\n"),r=n.findIndex((function(e){return a.test(e)}));if(-1!==r){var o=u.exec(n[r+1]||"");t=o?o[0]:""}return t}(new Error);c.value="sync"===n?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=h({err:new Error,className:p,methodName:y,sourceLink:_});try{return g.apply(this,e)}catch(e){var r=e,o=e.message,s={title:l||p+"."+y+" failed",content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);s.subtitle=o,c.code&&(n?(n.code=c.code,n.msg=c.msg):(e.code=c.code,e.message=c.msg),r=n||e,s.content=d.map((function(e){return{type:"info",body:e}})))}throw i.printGroupLog(s),r}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(this,void 0,void 0,(function(){var t,n,r,s,c,a;return o(this,(function(o){switch(o.label){case 0:t=h({err:new Error,className:p,methodName:y,sourceLink:_}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,g.apply(this,e)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,c={title:l||p+"."+y+" failed",content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(a=JSON.parse(s),c.subtitle=a,a.code&&(t?(t.code=a.code,t.message=a.msg):(n.code=a.code,n.message=a.msg),r=t||n,c.content=d.map((function(e){return{type:"info",body:e}})))),i.printGroupLog(c),r;case 4:return[2]}}))}))}}}}},function(e,t,n){"use strict";n.r(t),n.d(t,"LoginState",(function(){return Fe})),n.d(t,"Auth",(function(){return Be})),n.d(t,"AuthProvider",(function(){return c})),n.d(t,"EVENTS",(function(){return Ye})),n.d(t,"eventBus",(function(){return Ge})),n.d(t,"registerAuth",(function(){return Je})),n.d(t,"registerProvider",(function(){return ze}));var r,o=n(0),i=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},s=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},c=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request}return e.prototype.checkLocalLoginState=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,o,i;return s(this,(function(s){switch(s.label){case 0:return e=this._cache.keys,t=e.accessTokenKey,n=e.accessTokenExpireKey,[4,this._cache.getStoreAsync(t)];case 1:return r=s.sent(),[4,this._cache.getStoreAsync(n)];case 2:return o=s.sent(),r?o&&o>Date.now()?[4,(i=new Fe({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,4]:[3,7];case 3:return s.sent(),[2,i];case 4:return[4,this._cache.removeStoreAsync(t)];case 5:return s.sent(),[4,this._cache.removeStoreAsync(n)];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},e.prototype.setRefreshToken=function(e){return i(this,void 0,void 0,(function(){var t,n,r,o;return s(this,(function(i){switch(i.label){case 0:return t=this._cache.keys,n=t.accessTokenKey,r=t.accessTokenExpireKey,o=t.refreshTokenKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,e)];case 3:return i.sent(),[2]}}))}))},e.prototype.setAccessToken=function(e,t){return i(this,void 0,void 0,(function(){var n,r,o;return s(this,(function(i){switch(i.label){case 0:return n=this._cache.keys,r=n.accessTokenKey,o=n.accessTokenExpireKey,[4,this._cache.setStoreAsync(r,e)];case 1:return i.sent(),[4,this._cache.setStoreAsync(o,t)];case 2:return i.sent(),[2]}}))}))},e.prototype.refreshUserInfo=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return"auth.getUserInfo",[4,this._request.send("auth.getUserInfo",{})];case 1:return e=t.sent().data,[4,this.setLocalUserInfo(e)];case 2:return t.sent(),[2,e]}}))}))},e.prototype.setLocalUserInfo=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._cache.keys.userInfoKey,[4,this._cache.setStoreAsync(t,e)];case 1:return n.sent(),[2]}}))}))},e}();!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL",e.PHONE="PHONE"}(r||(r={}));var a,u=(a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),h=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},f=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},l=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},p=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},d=o.constants.getSdkName,y=o.constants.ERRORS,g=o.constants.COMMUNITY_SITE_URL,_=o.adapters.RUNTIME,v=o.utils.getQuery,m=o.utils.getHash,b=o.utils.removeParam,w=o.utils.printWarn,A=o.helpers.catchErrorsDecorator,I=function(e){function t(t,n,r,o){var i=e.call(this,t)||this;return i._runtime=t.runtime,i._appid=n,i._scope=r,i._state=o||"weixin",i}return u(t,e),t.prototype.signIn=function(){return l(this,void 0,void 0,(function(){return p(this,(function(e){return[2,w(y.OPERATION_FAIL,"API signIn has been deprecated, please use signInWithRedirect insteed")]}))}))},t.prototype.signInWithRedirect=function(){return l(this,void 0,void 0,(function(){return p(this,(function(e){return[2,this._redirect()]}))}))},t.prototype.getRedirectResult=function(e){return l(this,void 0,void 0,(function(){var t;return p(this,(function(n){return(t=O())?[2,this._signInWithCode(t,e)]:[2,null]}))}))},t.prototype.getLinkRedirectResult=function(e){return void 0===e&&(e={}),l(this,void 0,void 0,(function(){var t,n,r,o,i,s;return p(this,(function(c){return t=e.withUnionId,n=void 0!==t&&t,(r=O())?(o=this._appid,i=function(e){switch(e){case"snsapi_login":return"WECHAT-OPEN";default:return"WECHAT-PUBLIC"}}(this._scope),s=this._runtime===_.WX_MP?"1":"0",[2,this._request.send("auth.linkWithWeixinCode",{payload:{appid:o,loginType:i,code:r,hybridMiniapp:s,withUnionId:n}})]):[2,null]}))}))},t.prototype._redirect=function(){var e=b("code",location.href);e=b("state",e),e=encodeURIComponent(e);var t="//open.weixin.qq.com/connect/oauth2/authorize";"snsapi_login"===this._scope&&(t="//open.weixin.qq.com/connect/qrconnect");try{location.href=t+"?appid="+this._appid+"&redirect_uri="+e+"&response_type=code&scope="+this._scope+"&state="+this._state+"#wechat_redirect"}catch(e){throw new Error("["+d()+"]["+y.UNKOWN_ERROR+"]"+e)}},t.prototype._signInWithCode=function(e,t){return l(this,void 0,void 0,(function(){var n,o,i,s,c,a,u,h;return p(this,(function(f){switch(f.label){case 0:return n=this._cache.keys,o=n.accessTokenKey,i=n.accessTokenExpireKey,s=n.refreshTokenKey,c=function(e){switch(e){case"snsapi_login":return"WECHAT-OPEN";default:return"WECHAT-PUBLIC"}}(this._scope),[4,this._getRefreshTokenByWXCode(this._appid,c,e,t)];case 1:return a=f.sent(),u=a.refreshToken,[4,this._cache.setStoreAsync(s,u)];case 2:return f.sent(),a.accessToken?[4,this._cache.setStoreAsync(o,a.accessToken)]:[3,4];case 3:f.sent(),f.label=4;case 4:return a.accessTokenExpire?[4,this._cache.setStoreAsync(i,String(a.accessTokenExpire+Date.now()))]:[3,6];case 5:f.sent(),f.label=6;case 6:return Ge.fire(Ye.LOGIN_STATE_CHANGED),Ge.fire(Ye.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.WECHAT,persistence:this._config.persistence}),[4,this.refreshUserInfo()];case 7:return f.sent(),[4,(h=new Fe({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return f.sent(),[2,h]}}))}))},t.prototype._getRefreshTokenByWXCode=function(e,t,n,r){return void 0===r&&(r={}),l(this,void 0,void 0,(function(){var o,i,s,c,a,u;return p(this,(function(h){return o=r.withUnionId,i=void 0!==o&&o,s=r.createUser,c=void 0===s||s,a="snsapi_base"!==this._scope&&(r.syncUserInfo||!1),"auth.signIn",u=this._runtime===_.WX_MP?"1":"0",[2,this._request.send("auth.signIn",{appid:e,loginType:t,hybridMiniapp:u,syncUserInfo:a,loginCredential:n,withUnionId:i,createUser:c}).then((function(e){if(e.code)throw new Error("["+d()+"]["+y.OPERATION_FAIL+"] failed login via wechat: "+e.code);if(e.refresh_token)return{refreshToken:e.refresh_token,accessToken:e.access_token,accessTokenExpire:e.access_token_expire};throw new Error("["+d()+"]["+y.OPERATION_FAIL+"] action:getJwt not return refreshToken")}))]}))}))},h([A({title:"跳转微信公众号授权失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().signInWithRedirect() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+g]}),f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",Promise)],t.prototype,"signInWithRedirect",null),h([A({title:"微信公众号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+g]}),f("design:type",Function),f("design:paramtypes",[Object]),f("design:returntype",Promise)],t.prototype,"getRedirectResult",null),h([A({title:"获取微信重定向绑定结果",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getLinkRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+g]}),f("design:type",Function),f("design:paramtypes",[Object]),f("design:returntype",Promise)],t.prototype,"getLinkRedirectResult",null),t}(c);function O(){return v("code")||m("code")}var S=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),P=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},E=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},k=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},T=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},R=o.constants.ERRORS,N=o.constants.COMMUNITY_SITE_URL,U=o.utils.throwError,L=o.utils.isString,x=o.events.addEventListener,C=o.helpers.catchErrorsDecorator,j=function(e){function t(t){var n=e.call(this,t)||this;return n._onConverted=n._onConverted.bind(n),x(Ye.ANONYMOUS_CONVERTED,n._onConverted),n}return S(t,e),t.prototype.signIn=function(){return k(this,void 0,void 0,(function(){var e,t,n,o,i,s,c;return T(this,(function(a){switch(a.label){case 0:return[4,this._cache.updatePersistenceAsync("local")];case 1:return a.sent(),e=this._cache.keys,t=e.anonymousUuidKey,n=e.refreshTokenKey,[4,this._cache.getStoreAsync(t)];case 2:return o=a.sent(),[4,this._cache.getStoreAsync(n)];case 3:return i=a.sent(),[4,this._request.send("auth.signInAnonymously",{anonymous_uuid:o,refresh_token:i})];case 4:return(s=a.sent()).uuid&&s.refresh_token?[4,this._setAnonymousUUID(s.uuid)]:[3,10];case 5:return a.sent(),[4,this.setRefreshToken(s.refresh_token)];case 6:return a.sent(),[4,this._request.refreshAccessToken()];case 7:return a.sent(),Ge.fire(Ye.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.ANONYMOUS,persistence:"local"}),Ge.fire(Ye.LOGIN_STATE_CHANGED),[4,(c=new Fe({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return a.sent(),[4,c.user.refresh()];case 9:return a.sent(),[2,c];case 10:throw new Error(JSON.stringify({code:R.OPERATION_FAIL,msg:JSON.stringify(s)||"anonymous signIn failed"}))}}))}))},t.prototype.linkAndRetrieveDataWithTicket=function(e){return k(this,void 0,void 0,(function(){var t,n,o,i,s,c,a;return T(this,(function(u){switch(u.label){case 0:return L(e)||U(R.INVALID_PARAMS,"ticket must be a string"),t=this._cache.keys,n=t.anonymousUuidKey,o=t.refreshTokenKey,[4,this._cache.getStoreAsync(n)];case 1:return i=u.sent(),[4,this._cache.getStoreAsync(o)];case 2:return s=u.sent(),[4,this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:i,refresh_token:s,ticket:e})];case 3:return(c=u.sent()).refresh_token?[4,this._clearAnonymousUUID()]:[3,8];case 4:return u.sent(),[4,this.setRefreshToken(c.refresh_token)];case 5:return u.sent(),[4,this._request.refreshAccessToken()];case 6:return u.sent(),Ge.fire(Ye.ANONYMOUS_CONVERTED,{env:this._config.env}),Ge.fire(Ye.LOGIN_TYPE_CHANGED,{loginType:r.CUSTOM,persistence:"local"}),[4,(a=new Fe({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 7:return u.sent(),[2,a];case 8:U(R.OPERATION_FAIL,JSON.stringify(c)||"linkAndRetrieveDataWithTicket failed"),u.label=9;case 9:return[2]}}))}))},t.prototype._setAnonymousUUID=function(e){return k(this,void 0,void 0,(function(){var t,n,o;return T(this,(function(i){switch(i.label){case 0:return t=this._cache.keys,n=t.anonymousUuidKey,o=t.loginTypeKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.setStoreAsync(n,e)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,r.ANONYMOUS)];case 3:return i.sent(),[2]}}))}))},t.prototype._clearAnonymousUUID=function(){return k(this,void 0,void 0,(function(){return T(this,(function(e){switch(e.label){case 0:return[4,this._cache.removeStoreAsync(this._cache.keys.anonymousUuidKey)];case 1:return e.sent(),[2]}}))}))},t.prototype._onConverted=function(e){return k(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return e.data.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(this._config.persistence)];case 1:return t.sent(),[2]}}))}))},P([C({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().anonymouseProvider().signIn() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+N]}),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Promise)],t.prototype,"signIn",null),t}(c),M=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),q=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},D=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},W=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},H=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},G=o.constants.ERRORS,K=o.constants.COMMUNITY_SITE_URL,F=o.utils.isString,B=o.helpers.catchErrorsDecorator,Y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return M(t,e),t.prototype.signIn=function(e){return W(this,void 0,void 0,(function(){var t,n,o,i,s,c,a;return H(this,(function(u){switch(u.label){case 0:if(!F(e))throw new Error(JSON.stringify({code:G.INVALID_PARAMS,msg:"ticket must be a string"}));return t=this._cache.keys.refreshTokenKey,i=(o=this._request).send,s=["auth.signInWithTicket"],c={ticket:e},[4,this._cache.getStoreAsync(t)];case 1:return[4,i.apply(o,s.concat([(c.refresh_token=u.sent()||"",c)]))];case 2:return(n=u.sent()).refresh_token?[4,this.setRefreshToken(n.refresh_token)]:[3,7];case 3:return u.sent(),[4,this._request.refreshAccessToken()];case 4:return u.sent(),Ge.fire(Ye.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.CUSTOM,persistence:this._config.persistence}),Ge.fire(Ye.LOGIN_STATE_CHANGED),[4,this.refreshUserInfo()];case 5:return u.sent(),[4,(a=new Fe({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 6:return u.sent(),[2,a];case 7:throw new Error(JSON.stringify({code:G.OPERATION_FAIL,msg:"custom signIn failed"}))}}))}))},q([B({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().customAuthProvider().signIn() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+K]}),D("design:type",Function),D("design:paramtypes",[String]),D("design:returntype",Promise)],t.prototype,"signIn",null),t}(c),V=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),J=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},z=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},X=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},$=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},Q=o.utils.throwError,Z=o.utils.isString,ee=o.constants.ERRORS,te=o.constants.COMMUNITY_SITE_URL,ne=o.helpers.catchErrorsDecorator,re=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return V(t,e),t.prototype.signIn=function(e,t){return X(this,void 0,void 0,(function(){var n,o,i,s,c;return $(this,(function(a){switch(a.label){case 0:return Z(e)||Q(ee.INVALID_PARAMS,"email must be a string"),n=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(n)||""})];case 1:return o=a.sent(),i=o.refresh_token,s=o.access_token,c=o.access_token_expire,i?[4,this.setRefreshToken(i)]:[3,8];case 2:return a.sent(),s&&c?[4,this.setAccessToken(s,c)]:[3,4];case 3:return a.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:a.sent(),a.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return a.sent(),Ge.fire(Ye.LOGIN_STATE_CHANGED),Ge.fire(Ye.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.EMAIL,persistence:this._config.persistence}),[2,new Fe({envId:this._config.env,cache:this._cache,request:this._request})];case 8:o.code?Q(ee.OPERATION_FAIL,"Email login fail["+o.code+"] "+o.message):Q(ee.OPERATION_FAIL,"Email login fail"),a.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t){return X(this,void 0,void 0,(function(){return $(this,(function(n){return[2,this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})]}))}))},t.prototype.resetPassword=function(e){return X(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this._request.send("auth.sendPasswordResetEmail",{email:e})]}))}))},t.prototype.resetPasswordWithToken=function(e,t){return X(this,void 0,void 0,(function(){return $(this,(function(n){return[2,this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})]}))}))},t.prototype.activate=function(e){return X(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this._request.send("auth.activateEndUserMail",{token:e})]}))}))},J([ne({title:"邮箱密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().emailAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 邮箱地址与密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+te]}),z("design:type",Function),z("design:paramtypes",[String,String]),z("design:returntype",Promise)],t.prototype,"signIn",null),J([ne({title:"邮箱注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithEmailAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+te]}),z("design:type",Function),z("design:paramtypes",[String,String]),z("design:returntype",Promise)],t.prototype,"signUp",null),J([ne({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用 auth().sendPasswordResetEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经与当前用户绑定"," 4 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+te]}),z("design:type",Function),z("design:paramtypes",[String]),z("design:returntype",Promise)],t.prototype,"resetPassword",null),J([ne({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+te]}),z("design:type",Function),z("design:paramtypes",[String,String]),z("design:returntype",Promise)],t.prototype,"resetPasswordWithToken",null),J([ne({title:"邮箱激活失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+te]}),z("design:type",Function),z("design:paramtypes",[String]),z("design:returntype",Promise)],t.prototype,"activate",null),t}(c),oe=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ie=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},se=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ce=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},ae=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},ue=o.utils.printWarn,he=o.constants.ERRORS,fe=o.constants.COMMUNITY_SITE_URL,le=o.helpers.catchErrorsDecorator,pe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return oe(t,e),t.prototype.signIn=function(e,t){return ce(this,void 0,void 0,(function(){var n,o,i,s,c,a,u,h,f;return ae(this,(function(l){switch(l.label){case 0:if("string"!=typeof e)throw new Error(JSON.stringify({code:he.INVALID_PARAMS,msg:"username must be a string"}));return"string"!=typeof t&&(t="",ue(he.INVALID_PARAMS,"password is empty")),n=this._cache.keys.refreshTokenKey,s=(i=this._request).send,c=["auth.signIn"],a={loginType:r.USERNAME,username:e,password:t},[4,this._cache.getStoreAsync(n)];case 1:return[4,s.apply(i,c.concat([(a.refresh_token=l.sent()||"",a)]))];case 2:return o=l.sent(),u=o.refresh_token,h=o.access_token_expire,f=o.access_token,u?[4,this.setRefreshToken(u)]:[3,9];case 3:return l.sent(),f&&h?[4,this.setAccessToken(f,h)]:[3,5];case 4:return l.sent(),[3,7];case 5:return[4,this._request.refreshAccessToken()];case 6:l.sent(),l.label=7;case 7:return[4,this.refreshUserInfo()];case 8:return l.sent(),Ge.fire(Ye.LOGIN_STATE_CHANGED),Ge.fire(Ye.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.USERNAME,persistence:this._config.persistence}),[2,new Fe({envId:this._config.env,cache:this._cache,request:this._request})];case 9:throw o.code?new Error(JSON.stringify({code:he.OPERATION_FAIL,msg:"login by username failed:["+o.code+"] "+o.message})):new Error(JSON.stringify({code:he.OPERATION_FAIL,msg:"login by username failed"}));case 10:return[2]}}))}))},ie([le({title:"用户名密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().signInWithUsernameAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录"," 3 - 用户名密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+fe]}),se("design:type",Function),se("design:paramtypes",[String,String]),se("design:returntype",Promise)],t.prototype,"signIn",null),t}(c),de=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ye=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},ge=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},_e=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},ve=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},me=o.utils.throwError,be=o.utils.isString,we=o.utils.transformPhone,Ae=o.constants.ERRORS,Ie=o.constants.COMMUNITY_SITE_URL,Oe=o.helpers.catchErrorsDecorator,Se="SIGNIN",Pe="SIGNUP",Ee="FORCERESETPWD",ke=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return de(t,e),t.prototype.signIn=function(e){return _e(this,void 0,void 0,(function(){var t,n,o,i,s,c,a,u,h;return ve(this,(function(f){switch(f.label){case 0:return t=e.phoneNumber,n=e.phoneCode,o=e.password,i=e.signMethod,be(t)||me(Ae.INVALID_PARAMS,"phoneNumber must be a string"),be(n)||be(o)||me(Ae.INVALID_PARAMS,"phoneCode or password must be a string"),i||(i=Se),s=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:r.PHONE,phoneNumber:we(t),phoneCode:n,password:o,refresh_token:this._cache.getStore(s)||"",signMethod:i})];case 1:return c=f.sent(),a=c.refresh_token,u=c.access_token,h=c.access_token_expire,a?[4,this.setRefreshToken(a)]:[3,8];case 2:return f.sent(),u&&h?[4,this.setAccessToken(u,h)]:[3,4];case 3:return f.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:f.sent(),f.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return f.sent(),Ge.fire(Ye.LOGIN_STATE_CHANGED),Ge.fire(Ye.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.PHONE,persistence:this._config.persistence}),[2,new Fe({envId:this._config.env,cache:this._cache,request:this._request})];case 8:c.code?me(Ae.OPERATION_FAIL,"Phone login fail["+c.code+"] "+c.message):me(Ae.OPERATION_FAIL,"Phone login fail"),f.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t,n){return _e(this,void 0,void 0,(function(){return ve(this,(function(r){return[2,this.signIn({phoneNumber:e,phoneCode:t,password:n,signMethod:Pe})]}))}))},t.prototype.forceResetPwd=function(e,t,n){return _e(this,void 0,void 0,(function(){return ve(this,(function(r){return[2,this.signIn({phoneNumber:e,phoneCode:t,password:n,signMethod:Ee})]}))}))},ye([Oe({title:"手机号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().SmsAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录"," 3 - 短信验证码/密码是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ie]}),ge("design:type",Function),ge("design:paramtypes",[Object]),ge("design:returntype",Promise)],t.prototype,"signIn",null),ye([Oe({title:"手机短信注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithPhoneCode() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ie]}),ge("design:type",Function),ge("design:paramtypes",[String,String,String]),ge("design:returntype",Promise)],t.prototype,"signUp",null),ye([Oe({title:"手机密码重置失败",messages:["请确认以下各项:"," 1 - 调用 auth().forceResetPwd() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ie]}),ge("design:type",Function),ge("design:paramtypes",[String,String,String]),ge("design:returntype",Promise)],t.prototype,"forceResetPwd",null),t}(c),Te=function(){return(Te=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Re=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},Ne=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ue=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},Le=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},xe=o.events.CloudbaseEventEmitter,Ce=o.adapters.RUNTIME,je=o.utils.printWarn,Me=o.utils.throwError,qe=o.utils.transformPhone,De=o.constants.ERRORS,We=o.constants.COMMUNITY_SITE_URL,He=o.helpers.catchErrorsDecorator,Ge=new xe,Ke=function(){function e(e){var t=e.cache,n=e.request;this._cache=t,this._request=n,this._setUserInfo()}return e.prototype.checkLocalInfo=function(){return Ue(this,void 0,void 0,(function(){return Le(this,(function(e){return this.uid=this._getLocalUserInfo("uid"),this.loginType=this._getLocalUserInfo("loginType"),this.openid=this._getLocalUserInfo("wxOpenId"),this.wxOpenId=this._getLocalUserInfo("wxOpenId"),this.wxPublicId=this._getLocalUserInfo("wxPublicId"),this.unionId=this._getLocalUserInfo("wxUnionId"),this.qqMiniOpenId=this._getLocalUserInfo("qqMiniOpenId"),this.customUserId=this._getLocalUserInfo("customUserId"),this.nickName=this._getLocalUserInfo("nickName"),this.gender=this._getLocalUserInfo("gender"),this.avatarUrl=this._getLocalUserInfo("avatarUrl"),this.email=this._getLocalUserInfo("email"),this.hasPassword=Boolean(this._getLocalUserInfo("hasPassword")),this.phone=this._getLocalUserInfo("phone"),this.username=this._getLocalUserInfo("username"),this.location={country:this._getLocalUserInfo("country"),province:this._getLocalUserInfo("province"),city:this._getLocalUserInfo("city")},[2]}))}))},e.prototype.checkLocalInfoAsync=function(){return Ue(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,c,a,u,h,f,l,p,d,y,g,_;return Le(this,(function(v){switch(v.label){case 0:return e=this,[4,this._getLocalUserInfoAsync("uid")];case 1:return e.uid=v.sent(),t=this,[4,this._getLocalUserInfoAsync("loginType")];case 2:return t.loginType=v.sent(),n=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 3:return n.openid=v.sent(),r=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 4:return r.wxOpenId=v.sent(),o=this,[4,this._getLocalUserInfoAsync("wxPublicId")];case 5:return o.wxPublicId=v.sent(),i=this,[4,this._getLocalUserInfoAsync("wxUnionId")];case 6:return i.unionId=v.sent(),s=this,[4,this._getLocalUserInfoAsync("qqMiniOpenId")];case 7:return s.qqMiniOpenId=v.sent(),c=this,[4,this._getLocalUserInfoAsync("customUserId")];case 8:return c.customUserId=v.sent(),a=this,[4,this._getLocalUserInfoAsync("nickName")];case 9:return a.nickName=v.sent(),u=this,[4,this._getLocalUserInfoAsync("gender")];case 10:return u.gender=v.sent(),h=this,[4,this._getLocalUserInfoAsync("avatarUrl")];case 11:return h.avatarUrl=v.sent(),f=this,[4,this._getLocalUserInfoAsync("email")];case 12:return f.email=v.sent(),l=this,p=Boolean,[4,this._getLocalUserInfoAsync("hasPassword")];case 13:return l.hasPassword=p.apply(void 0,[v.sent()]),d=this,[4,this._getLocalUserInfoAsync("phone")];case 14:return d.phone=v.sent(),y=this,[4,this._getLocalUserInfoAsync("username")];case 15:return y.username=v.sent(),g=this,_={},[4,this._getLocalUserInfoAsync("country")];case 16:return _.country=v.sent(),[4,this._getLocalUserInfoAsync("province")];case 17:return _.province=v.sent(),[4,this._getLocalUserInfoAsync("city")];case 18:return g.location=(_.city=v.sent(),_),[2]}}))}))},e.prototype.linkWithTicket=function(e){if("string"!=typeof e)throw new Error("ticket must be string");return this._request.send("auth.linkWithTicket",{ticket:e})},e.prototype.linkWithRedirect=function(e){e.signInWithRedirect()},e.prototype.getLinkedUidList=function(){return Ue(this,void 0,void 0,(function(){var e,t,n,r,o,i;return Le(this,(function(s){switch(s.label){case 0:return[4,this._request.send("auth.getLinkedUidList",{})];case 1:for(e=s.sent().data,t=!1,n=e.users,r=0,o=n;r<o.length;r++)if((i=o[r]).wxOpenId&&i.wxPublicId){t=!0;break}return[2,{users:n,hasPrimaryUid:t}]}}))}))},e.prototype.setPrimaryUid=function(e){return this._request.send("auth.setPrimaryUid",{uid:e})},e.prototype.unlink=function(e){return this._request.send("auth.unlink",{platform:e})},e.prototype.update=function(e){return Ue(this,void 0,void 0,(function(){var t,n,r,o,i,s,c;return Le(this,(function(a){switch(a.label){case 0:return t=e.nickName,n=e.gender,r=e.avatarUrl,o=e.province,i=e.country,s=e.city,[4,this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:r,province:o,country:i,city:s})];case 1:return c=a.sent().data,this._setLocalUserInfo(c),[2]}}))}))},e.prototype.updatePassword=function(e,t){return this._request.send("auth.updatePassword",{oldPassword:t,newPassword:e})},e.prototype.updateEmail=function(e,t){return this._request.send("auth.updateEmail",{newEmail:e,password:t})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&Me(De.INVALID_PARAMS,"username must be a string"),this._request.send("auth.updateUsername",{username:e})},e.prototype.refresh=function(){return Ue(this,void 0,void 0,(function(){var e;return Le(this,(function(t){switch(t.label){case 0:return"auth.getUserInfo",[4,this._request.send("auth.getUserInfo",{})];case 1:return e=t.sent().data,this._setLocalUserInfo(e),[2,e]}}))}))},e.prototype.linkWithPhoneNumber=function(e,t){return Ue(this,void 0,void 0,(function(){return Le(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:qe(e),phoneCode:t})]}))}))},e.prototype.updatePhoneNumber=function(e,t){return Ue(this,void 0,void 0,(function(){return Le(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:qe(e),phoneCode:t})]}))}))},e.prototype._getLocalUserInfo=function(e){var t=this._cache.keys.userInfoKey;return this._cache.getStore(t)[e]},e.prototype._getLocalUserInfoAsync=function(e){return Ue(this,void 0,void 0,(function(){var t;return Le(this,(function(n){switch(n.label){case 0:return t=this._cache.keys.userInfoKey,[4,this._cache.getStoreAsync(t)];case 1:return[2,n.sent()[e]]}}))}))},e.prototype._setUserInfo=function(){var e=this,t=this._cache.keys.userInfoKey,n=this._cache.getStore(t);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl","phone","username"].forEach((function(t){e[t]=n[t]})),this.location={country:n.country,province:n.province,city:n.city}},e.prototype._setLocalUserInfo=function(e){var t=this._cache.keys.userInfoKey;this._cache.setStore(t,e),this._setUserInfo()},Re([He({title:"绑定自定义登录失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithTicket() 的语法或参数是否正确"," 2 - 此账户是否已经绑定自定义登录"," 3 - ticket 参数是否归属当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[String]),Ne("design:returntype",Promise)],e.prototype,"linkWithTicket",null),Re([He({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithRedirect() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方"," 3 - 此第三方是否已经授权","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[Object]),Ne("design:returntype",void 0)],e.prototype,"linkWithRedirect",null),Re([He({title:"获取账户列表失败",messages:["请确认以下各项:"," 1 - 调用 User.getLinkedUidList() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[]),Ne("design:returntype",Promise)],e.prototype,"getLinkedUidList",null),Re([He({title:"设置微信主账号失败",messages:["请确认以下各项:"," 1 - 调用 User.setPrimaryUid() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[String]),Ne("design:returntype",void 0)],e.prototype,"setPrimaryUid",null),Re([He({title:"接触绑定失败",messages:["请确认以下各项:"," 1 - 调用 User.unlink() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[String]),Ne("design:returntype",void 0)],e.prototype,"unlink",null),Re([He({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[Object]),Ne("design:returntype",Promise)],e.prototype,"update",null),Re([He({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[String,String]),Ne("design:returntype",void 0)],e.prototype,"updatePassword",null),Re([He({title:"更新邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 User.updateEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[String,String]),Ne("design:returntype",void 0)],e.prototype,"updateEmail",null),Re([He({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[String]),Ne("design:returntype",void 0)],e.prototype,"updateUsername",null),Re([He({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[]),Ne("design:returntype",Promise)],e.prototype,"refresh",null),Re([He({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().linkWithPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[String,String]),Ne("design:returntype",Promise)],e.prototype,"linkWithPhoneNumber",null),Re([He({title:"更新手机号失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[String,String]),Ne("design:returntype",Promise)],e.prototype,"updatePhoneNumber",null),e}(),Fe=function(){function e(e){var t=e.envId,n=e.cache,r=e.request;t||Me(De.INVALID_PARAMS,"envId is not defined"),this._cache=n,this.user=new Ke({cache:n,request:r})}return e.prototype.checkLocalState=function(){return Ue(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return Le(this,(function(c){return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,o=this._cache.getStore(t),i=this._cache.getStore(n),s=this._cache.getStore(r),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},this._loginType=this._cache.getStore(this._cache.keys.loginTypeKey),this.user.checkLocalInfo(),[2]}))}))},e.prototype.checkLocalStateAsync=function(){return Ue(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,c;return Le(this,(function(a){switch(a.label){case 0:return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,[4,this._cache.getStoreAsync(t)];case 1:return o=a.sent(),[4,this._cache.getStoreAsync(n)];case 2:return i=a.sent(),[4,this._cache.getStoreAsync(r)];case 3:return s=a.sent(),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},c=this,[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 4:return c._loginType=a.sent(),[4,this.user.checkLocalInfoAsync()];case 5:return a.sent(),[2]}}))}))},Object.defineProperty(e.prototype,"isAnonymousAuth",{get:function(){return this.loginType===r.ANONYMOUS},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCustomAuth",{get:function(){return this.loginType===r.CUSTOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isWeixinAuth",{get:function(){return this.loginType===r.WECHAT||this.loginType===r.WECHAT_OPEN||this.loginType===r.WECHAT_PUBLIC},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsernameAuth",{get:function(){return this.loginType===r.USERNAME},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loginType",{get:function(){return this._loginType},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPhoneAuth",{get:function(){return this.loginType===r.PHONE},enumerable:!1,configurable:!0}),e}(),Be=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request,this._runtime=e.runtime||Ce.WEB,Ge.on(Ye.LOGIN_TYPE_CHANGED,this._onLoginTypeChanged.bind(this))}return Object.defineProperty(e.prototype,"currentUser",{get:function(){if("async"!==this._cache.mode){var e=this.hasLoginState();return e&&e.user||null}je(De.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrenUser insteed")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loginType",{get:function(){return this._cache.getStore(this._cache.keys.loginTypeKey)},enumerable:!1,configurable:!0}),e.prototype.getCurrenUser=function(){return Ue(this,void 0,void 0,(function(){var e;return Le(this,(function(t){switch(t.label){case 0:return[4,this.getLoginState()];case 1:return(e=t.sent())?[4,e.user.checkLocalInfoAsync()]:[3,3];case 2:return t.sent(),[2,e.user||null];case 3:return[2,null]}}))}))},e.prototype.getLoginType=function(){return Ue(this,void 0,void 0,(function(){return Le(this,(function(e){switch(e.label){case 0:return[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAccessToken=function(){return Ue(this,void 0,void 0,(function(){var e;return Le(this,(function(t){switch(t.label){case 0:return e={},[4,this._request.getAccessToken()];case 1:return[2,(e.accessToken=t.sent().accessToken,e.env=this._config.env,e)]}}))}))},e.prototype.weixinAuthProvider=function(e){var t=e.appid,n=e.scope,r=e.state;return this._weixinAuthProvider||(this._weixinAuthProvider=new I(Te(Te({},this._config),{cache:this._cache,request:this._request,runtime:this._runtime}),t,n,r)),this._weixinAuthProvider},e.prototype.anonymousAuthProvider=function(){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new j(Te(Te({},this._config),{cache:this._cache,request:this._request}))),this._anonymousAuthProvider},e.prototype.customAuthProvider=function(){return this._customAuthProvider||(this._customAuthProvider=new Y(Te(Te({},this._config),{cache:this._cache,request:this._request}))),this._customAuthProvider},e.prototype.emailAuthProvider=function(){return this._emailAuthProvider||(this._emailAuthProvider=new re(Te(Te({},this._config),{cache:this._cache,request:this._request}))),this._emailAuthProvider},e.prototype.usernameAuthProvider=function(){return this._usernameAuthProvider||(this._usernameAuthProvider=new pe(Te(Te({},this._config),{cache:this._cache,request:this._request}))),this._usernameAuthProvider},e.prototype.phoneAuthProvider=function(){return this._phoneAuthProvider||(this._phoneAuthProvider=new ke(Te(Te({},this._config),{cache:this._cache,request:this._request}))),this._phoneAuthProvider},e.prototype.signInWithUsernameAndPassword=function(e,t){return Ue(this,void 0,void 0,(function(){return Le(this,(function(n){return[2,this.usernameAuthProvider().signIn(e,t)]}))}))},e.prototype.isUsernameRegistered=function(e){return Ue(this,void 0,void 0,(function(){var t;return Le(this,(function(n){switch(n.label){case 0:return"string"!=typeof e&&Me(De.INVALID_PARAMS,"username must be a string"),[4,this._request.send("auth.isUsernameRegistered",{username:e})];case 1:return[2,null==(t=n.sent().data)?void 0:t.isRegistered]}}))}))},e.prototype.signInWithEmailAndPassword=function(e,t){return Ue(this,void 0,void 0,(function(){return Le(this,(function(n){return[2,this.emailAuthProvider().signIn(e,t)]}))}))},e.prototype.signUpWithEmailAndPassword=function(e,t){return Ue(this,void 0,void 0,(function(){return Le(this,(function(n){return[2,this.emailAuthProvider().signUp(e,t)]}))}))},e.prototype.sendPasswordResetEmail=function(e){return Ue(this,void 0,void 0,(function(){return Le(this,(function(t){return[2,this.emailAuthProvider().resetPassword(e)]}))}))},e.prototype.signOut=function(){return Ue(this,void 0,void 0,(function(){var e,t,n,o,i,s,c;return Le(this,(function(a){switch(a.label){case 0:return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,o=e.accessTokenExpireKey,i="auth.logout",[4,this._cache.getStoreAsync(t)];case 1:return(s=a.sent())?[4,this._request.send(i,{refresh_token:s})]:[2];case 2:return c=a.sent(),this._cache.removeStoreAsync(t),this._cache.removeStoreAsync(n),this._cache.removeStoreAsync(o),Ge.fire(Ye.LOGIN_STATE_CHANGED),Ge.fire(Ye.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.NULL,persistence:this._config.persistence}),[2,c]}}))}))},e.prototype.onLoginStateChanged=function(e){return Ue(this,void 0,void 0,(function(){var t,n=this;return Le(this,(function(r){switch(r.label){case 0:return Ge.on(Ye.LOGIN_STATE_CHANGED,(function(){return Ue(n,void 0,void 0,(function(){var t;return Le(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return t=n.sent(),e.call(this,t),[2]}}))}))})),[4,this.getLoginState()];case 1:return t=r.sent(),e.call(this,t),[2]}}))}))},e.prototype.onLoginStateExpired=function(e){Ge.on(Ye.LOGIN_STATE_EXPIRED,e.bind(this))},e.prototype.onAccessTokenRefreshed=function(e){Ge.on(Ye.ACCESS_TOKEN_REFRESHD,e.bind(this))},e.prototype.onAnonymousConverted=function(e){Ge.on(Ye.ANONYMOUS_CONVERTED,e.bind(this))},e.prototype.onLoginTypeChanged=function(e){var t=this;Ge.on(Ye.LOGIN_TYPE_CHANGED,(function(){return Ue(t,void 0,void 0,(function(){var t;return Le(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return t=n.sent(),e.call(this,t),[2]}}))}))}))},e.prototype.hasLoginState=function(){if("async"!==this._cache.mode){var e=this._cache.keys.refreshTokenKey;if(this._cache.getStore(e)){var t=new Fe({envId:this._config.env,cache:this._cache,request:this._request});return t.checkLocalState(),t}return null}je(De.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},e.prototype.getLoginState=function(){return Ue(this,void 0,void 0,(function(){var e,t;return Le(this,(function(n){switch(n.label){case 0:return e=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(e)];case 1:return n.sent()?[4,(t=new Fe({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,3];case 2:return n.sent(),[2,t];case 3:return[2,null]}}))}))},e.prototype.shouldRefreshAccessToken=function(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)},e.prototype.getUserInfo=function(){return Ue(this,void 0,void 0,(function(){var e;return Le(this,(function(t){switch(t.label){case 0:return"auth.getUserInfo",[4,this._request.send("auth.getUserInfo",{})];case 1:return(e=t.sent()).code?[2,e]:[2,Te(Te({},e.data),{requestId:e.seqId})]}}))}))},e.prototype.getAuthHeader=function(){var e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=this._cache.getStore(t);return{"x-cloudbase-credentials":this._cache.getStore(n)+"/@@/"+r}},e.prototype.getAuthHeaderAsync=function(){return Ue(this,void 0,void 0,(function(){var e,t,n,r;return Le(this,(function(o){switch(o.label){case 0:return[4,this._request.refreshAccessToken()];case 1:return o.sent(),e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,[4,this._cache.getStoreAsync(t)];case 2:return r=o.sent(),[4,this._cache.getStoreAsync(n)];case 3:return[2,{"x-cloudbase-credentials":o.sent()+"/@@/"+r}]}}))}))},e.prototype.sendPhoneCode=function(e){return Ue(this,void 0,void 0,(function(){return Le(this,(function(t){switch(t.label){case 0:return[4,this._request.send("auth.sendPhoneCode",{phoneNumber:qe(e)})];case 1:return[2,"Ok"===t.sent().data.SendStatus]}}))}))},e.prototype.signUpWithPhoneCode=function(e,t,n){return Ue(this,void 0,void 0,(function(){return Le(this,(function(r){return[2,this.phoneAuthProvider().signUp(e,t,n)]}))}))},e.prototype.signInWithPhoneCodeOrPassword=function(e){return Ue(this,void 0,void 0,(function(){return Le(this,(function(t){return[2,this.phoneAuthProvider().signIn(e)]}))}))},e.prototype.forceResetPwdByPhoneCode=function(e){return Ue(this,void 0,void 0,(function(){return Le(this,(function(t){return[2,this.phoneAuthProvider().signIn(Te(Te({},e),{signMethod:Ee}))]}))}))},e.prototype._onLoginTypeChanged=function(e){return Ue(this,void 0,void 0,(function(){var t,n,r;return Le(this,(function(o){switch(o.label){case 0:return t=e.data,n=t.loginType,r=t.persistence,t.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(r)];case 1:return o.sent(),[4,this._cache.setStoreAsync(this._cache.keys.loginTypeKey,n)];case 2:return o.sent(),[2]}}))}))},Re([He({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[]),Ne("design:returntype",Promise)],e.prototype,"getCurrenUser",null),Re([He({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[String]),Ne("design:returntype",Promise)],e.prototype,"isUsernameRegistered",null),Re([He({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[]),Ne("design:returntype",Promise)],e.prototype,"signOut",null),Re([He({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[]),Ne("design:returntype",Promise)],e.prototype,"getLoginState",null),Re([He({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[]),Ne("design:returntype",Promise)],e.prototype,"getUserInfo",null),Re([He({title:"发送短信验证码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+We]}),Ne("design:type",Function),Ne("design:paramtypes",[String]),Ne("design:returntype",Promise)],e.prototype,"sendPhoneCode",null),e}(),Ye={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRED:"loginStateExpire",LOGIN_TYPE_CHANGED:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",ACCESS_TOKEN_REFRESHD:"refreshAccessToken"},Ve={name:"auth",namespace:"auth",injectEvents:{bus:Ge,events:[Ye.LOGIN_TYPE_CHANGED,Ye.LOGIN_STATE_EXPIRED,Ye.LOGIN_STATE_CHANGED,Ye.ACCESS_TOKEN_REFRESHD,Ye.ANONYMOUS_CONVERTED]},entity:function(e){if(void 0===e&&(e={region:"",persistence:"local"}),this.authInstance)return je(De.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var t=this.platform,n=t.adapter,r=t.runtime,o=e.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=this.config,s=i.env,c=i.persistence,a=i.debug;return this.authInstance=new Be({env:s,region:e.region,persistence:c,debug:a,cache:this.cache,request:this.request,runtime:r}),this.authInstance}};try{cloudbase.registerComponent(Ve)}catch(e){}function Je(e){try{e.registerComponent(Ve)}catch(e){console.warn(e)}}function ze(e,t){Be.prototype[e]=function(n){var r="_"+e;return this[r]||(this[r]=new t(Te(Te({},n),this._config))),this[r]}}}])}));
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,s,a,u,l,h,f;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:s=o.sent(),n.headers["x-device-id"]=s,o.label=2;case 2:return(null==n?void 0:n.withCredentials)?[4,this._getCredentials()]:[3,4];case 3:return(a=o.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),o.label=5;case 5:e.startsWith("/")&&(e=this._apiOrigin+e),u=null,l=i+1,h=0,o.label=6;case 6:if(!(h<l))return[3,13];o.label=7;case 7:return o.trys.push([7,9,,10]),[4,this._baseRequest(e,n)];case 8:return u=o.sent(),[3,13];case 9:return f=o.sent(),h!==i&&f&&"unreachable"===f.error?[3,10]:[2,Promise.reject(f)];case 10:return[4,this._sleep(t._retryInterval)];case 11:o.sent(),o.label=12;case 12:return h++,[3,6];case 13:return[2,u]}}))}))},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._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="undefined"!=typeof location&&"http:"===location.protocol?"http:":"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(){return i(this,(function(e){return[2,this._config.request(o.ApiUrls.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:!0})]}))}))},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()).picture&&(t.avatarUrl=t.picture),t.sub&&(t.uid=t.sub),[2,t]}}))}))},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,n;return i(this,(function(r){return e=new URL(o.ApiUrls.USER_QUERY_URL),n=new URLSearchParams(t),e.search=n.toString(),[2,this._config.request(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_SET_PASSWORD,{method:"POST",body:t,withCredentials:!0})]}))}))},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.AUTH_GET_DEVICE_CODE,{method:"GET",body:t,withCredentials:!0})]}))}))},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 g})),n.d(e,"Auth",(function(){return m})),n.d(e,"registerAuth",(function(){return I}));var r=n(0),i=n(9),o=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},s=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},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=r.utils.printWarn,l=r.utils.throwError,h=r.constants.ERRORS,f=r.constants.COMMUNITY_SITE_URL,d=r.helpers.catchErrorsDecorator,p=r.events.CloudbaseEventEmitter,_="loginStateChanged",v=new p,y=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 a(this,void 0,void 0,(function(){return u(this,(function(t){return this.uid=this._getLocalUserInfo("uid"),this.gender=this._getLocalUserInfo("gender"),this.picture=this._getLocalUserInfo("picture"),this.avatarUrl=this._getLocalUserInfo("avatarUrl"),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 a(this,void 0,void 0,(function(){var t,e,n,r,i;return u(this,(function(o){switch(o.label){case 0:return t=this,[4,this._getLocalUserInfoAsync("uid")];case 1:return t.uid=o.sent(),e=this,[4,this._getLocalUserInfoAsync("gender")];case 2:return e.gender=o.sent(),this.picture=this._getLocalUserInfo("picture"),n=this,[4,this._getLocalUserInfoAsync("avatarUrl")];case 3:return n.avatarUrl=o.sent(),r=this,[4,this._getLocalUserInfoAsync("email")];case 4:return r.email=o.sent(),this.email_verified=this._getLocalUserInfo("email_verified"),this.phone_number=this._getLocalUserInfo("phone_number"),i=this,[4,this._getLocalUserInfoAsync("username")];case 5:return i.username=o.sent(),this.name=this._getLocalUserInfo("name"),this.birthdate=this._getLocalUserInfo("birthdate"),this.zoneinfo=this._getLocalUserInfo("zoneinfo"),this.locale=this._getLocalUserInfo("locale"),this.sub=this._getLocalUserInfo("sub"),this.created_from=this._getLocalUserInfo("created_from"),this.providers=this._getLocalUserInfo("providers"),[2]}}))}))},t.prototype.update=function(t){return a(this,void 0,void 0,(function(){var e,n,r,i,o,s,a;return u(this,(function(u){switch(u.label){case 0:return e=t.name,n=t.gender,r=t.avatarUrl,i=t.province,o=t.country,s=t.city,[4,this._oauthInstance.authApi.setUserProfile({name:e,gender:n,avatarUrl:r,province:i,country:o,city:s})];case 1:return a=u.sent(),this._setLocalUserInfo(a),[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&&l(h.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(){return a(this,void 0,void 0,(function(){var t;return u(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 a(this,void 0,void 0,(function(){var e;return u(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","avatarUrl","phone","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()},o([d({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],t.prototype,"update",null),o([d({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[String,String]),s("design:returntype",void 0)],t.prototype,"updatePassword",null),o([d({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[String]),s("design:returntype",void 0)],t.prototype,"updateUsername",null),o([d({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[]),s("design:returntype",Promise)],t.prototype,"refresh",null),t}(),g=function(){function t(t){var e=t.envId,n=t.cache,r=t.oauthInstance;e||l(h.INVALID_PARAMS,"envId is not defined"),this._cache=n,this._oauthInstance=r,this.user=new y({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 a(this,void 0,void 0,(function(){return u(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}(),m=function(){function t(t){this._config=t,this._cache=t.cache,this._oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return a(this,void 0,void 0,(function(){return u(this,(function(e){return[2,this._oauthInstance.authApi.bindPhone(t)]}))}))},t.prototype.unbindProvider=function(t){return a(this,void 0,void 0,(function(){return u(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 a(this,void 0,void 0,(function(){return u(this,(function(e){return[2,this._oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t){return a(this,void 0,void 0,(function(){return u(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}c(h.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return a(this,void 0,void 0,(function(){var t;return u(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 a(this,void 0,void 0,(function(){return u(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 a(this,void 0,void 0,(function(){return u(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 a(this,void 0,void 0,(function(){return u(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 a(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return console.log("ggg"),[4,this._oauthInstance.authApi.signUp(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setPassword=function(t){return a(this,void 0,void 0,(function(){return u(this,(function(e){return[2,this._oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return a(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:"string"!=typeof t&&l(h.INVALID_PARAMS,"username must be a string"),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this._oauthInstance.authApi.checkUsername({username:t})];case 2:return e.sent(),[2,!0];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},t.prototype.signOut=function(){return a(this,void 0,void 0,(function(){var t;return u(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(_),[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 g({envId:this._config.env,cache:this._cache,oauthInstance:this._oauthInstance}):null;c(h.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return a(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._oauthInstance.authApi.getLoginState()];case 1:return t.sent()?[2,new g({envId:this._config.env,cache:this._cache,oauthInstance:this._oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(){return a(this,void 0,void 0,(function(){return u(this,(function(t){return[2,this._oauthInstance.authApi.getUserInfo()]}))}))},t.prototype.bindWithProvider=function(t){return a(this,void 0,void 0,(function(){return u(this,(function(e){return[2,this._oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return a(this,void 0,void 0,(function(){return u(this,(function(e){return[2,this._oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return a(this,void 0,void 0,(function(){return u(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 a(this,void 0,void 0,(function(){return u(this,(function(e){return[2,this._oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return a(this,void 0,void 0,(function(){return u(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 a(this,void 0,void 0,(function(){return u(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 a(this,void 0,void 0,(function(){return u(this,(function(e){return[2,this._oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return a(this,void 0,void 0,(function(){return u(this,(function(e){return[2,this._oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return a(this,void 0,void 0,(function(){return u(this,(function(e){return[2,this._oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return a(this,void 0,void 0,(function(){return u(this,(function(e){return[2,this._oauthInstance.authApi.sudo(t)]}))}))},t.prototype.onLoginStateChanged=function(t){return a(this,void 0,void 0,(function(){var e,n=this;return u(this,(function(r){switch(r.label){case 0:return v.on(_,(function(){return a(n,void 0,void 0,(function(){var e;return u(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 a(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return[4,(t=new g({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(_),[2,t]}}))}))},o([d({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),o([d({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],t.prototype,"unbindProvider",null),o([d({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",void 0)],t.prototype,"bindEmail",null),o([d({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],t.prototype,"verify",null),o([d({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],t.prototype,"getVerification",null),o([d({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[]),s("design:returntype",Promise)],t.prototype,"getCurrentUser",null),o([d({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[]),s("design:returntype",Promise)],t.prototype,"signInAnonymously",null),o([d({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[]),s("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),o([d({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],t.prototype,"signUp",null),o([d({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[String]),s("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),o([d({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[]),s("design:returntype",Promise)],t.prototype,"signOut",null),o([d({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[]),s("design:returntype",Promise)],t.prototype,"getLoginState",null),o([d({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[]),s("design:returntype",Promise)],t.prototype,"getUserInfo",null),o([d({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),s("design:type",Function),s("design:paramtypes",[Object]),s("design:returntype",Promise)],t.prototype,"bindWithProvider",null),t}(),b={name:"auth",namespace:"auth",entity:function(t){if(void 0===t&&(t={region:"",persistence:"local"}),this.authInstance)return c(h.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,l=s.debug,f=s.clientId,d=new i.CloudbaseOAuth({clientId:f,apiOrigin:this.request.getBaseEndPoint()});return this.oauthInstance=d,this.authInstance=new m({env:a,region:t.region,persistence:u,debug:l,cache:this.cache,runtime:r,_fromApp:this,oauthInstance:d}),this.authInstance}};try{cloudbase.registerComponent(b)}catch(t){}function I(t){try{t.registerComponent(b)}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"}(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;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,3,,7]),[2,this._config.request(r,e)];case 3:return"captcha_required"!==(o=i.sent()).error&&"captcha_invalid"!==o.error?[3,5]:[4,this._appendCaptchaTokenToURL(t,n,"captcha_invalid"===o.error)];case 4:return t=i.sent(),[2,this._config.request(t,e)];case 5:return[2,Promise.reject(o)];case 6:return[3,7];case 7:return[2]}}))}))},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"),document.body.appendChild(t)}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})}])}));