@cloudbase/js-sdk 3.6.9-beta.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/dist/index.esm.js +1 -1
- package/app/dist/index.esm.js.map +1 -1
- package/app/dist/index.js +1 -1
- package/app/dist/index.js.map +1 -1
- package/app/dist/index.node.esm.js +1 -1
- package/app/dist/index.node.esm.js.map +1 -1
- package/app/dist/index.node.js +1 -1
- package/app/dist/index.node.js.map +1 -1
- package/auth/dist/index.esm.js +1 -1
- package/auth/dist/index.esm.js.map +1 -1
- package/auth/dist/index.js +1 -1
- package/auth/dist/index.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.node.cjs.js +1 -1
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.esm.js +1 -1
- package/dist/index.node.esm.js.map +1 -1
- package/miniprogram_dist/auth/index.js +1 -1
- package/miniprogram_dist/index.js +1 -1
- package/miniprogram_dist/oauth/index.js +1 -1
- package/oauth/dist/index.esm.js +1 -1
- package/oauth/dist/index.esm.js.map +1 -1
- package/oauth/dist/index.js +1 -1
- package/oauth/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/types/package.json +1 -1
- package/utilities/package.json +3 -3
package/auth/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(){"use strict";var e,t,r={548:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.useAuthAdapter=void 0;var s=r(19),a=function(){function e(e){var t,r;try{this.localStorage=(null==e?void 0:e.localStorage)||((null===(r=null===(t=null==e?void 0:e.adapter)||void 0===t?void 0:t.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(t){this.localStorage=(null==e?void 0:e.localStorage)||{}}}return e.prototype.getItem=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.localStorage.getItem(e)]})})},e.prototype.removeItem=function(e){return i(this,void 0,void 0,function(){return o(this,function(t){return this.localStorage.removeItem(e),[2]})})},e.prototype.setItem=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(r){return this.localStorage.setItem(e,t),[2]})})},e.prototype.getItemSync=function(e){return this.localStorage.getItem(e)},e.prototype.setItemSync=function(e,t){this.localStorage.setItem(e,t)},e.prototype.removeItemSync=function(e){this.localStorage.removeItem(e)},e}(),u=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,c=function(e,t){var r,n,i,o,s=null===(r=null==t?void 0:t.headers)||void 0===r?void 0:r["x-request-id"];return e||(e={}),((null==e?void 0:e.code)||(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.error_code))&&(e={error:e.code||e.data.error,error_description:e.data.error_description||e.message||e.code||e.data.error_code,request_id:e.requestId,error_code:null===(i=e.data)||void 0===i?void 0:i.error_code}),(null==e?void 0:e.request_id)||(e.request_id=e.request_id||s),(null==e?void 0:e.error)?(e.error_uri=(o=null==t?void 0:t.url,u.test(o)?RegExp.$1:o),e):(null==e?void 0:e.data)||{}};t.useAuthAdapter=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var r=n({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(r.storage=new a({localStorage:t.localStorage,adapter:t})),!e.captchaOptions&&(null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!e.baseRequest&&!e.request&&(null==t?void 0:t.reqClass)){var s={timeout:1e4,restrictedMethods:["get","post","upload","download","request"],auth:e.auth},u=new t.reqClass(s);r.baseRequest=function(e,t){var r,s,a,h,l;return i(this,void 0,void 0,function(){var i,d,p,f;return o(this,function(o){switch(o.label){case 0:if(i={},d=(null===(r=t.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(p=null===(a=null===(s=null==u?void 0:u[d])||void 0===s?void 0:s.bind)||void 0===a?void 0:a.call(s,u)))throw new Error("invalid 【".concat(d,"】 request method"));o.label=1;case 1:return o.trys.push([1,3,,4]),(null===(h=t.headers)||void 0===h?void 0:h["content-type"])&&!(null===(l=t.headers)||void 0===l?void 0:l["content-type"].includes("application/json"))||["string","undefined"].includes(typeof t.body)||(t.data=t.data||t.body,t.body=JSON.stringify(t.body)),[4,p(n({url:e},t))];case 2:return i=o.sent(),i=c(i,n(n({},t),{url:e})),[3,4];case 3:throw f=o.sent(),i=n(n({},null==f?void 0:f.data),f);case 4:if(null==i?void 0:i.error)throw i;return[2,i]}})})}}}catch(e){console.error("user adapter generate fail:",e)}return r}(e,e.adapter):function(e,t){var r=n({},e),u={};if((null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!s.adapterForWxMp.isMatch()||e.storage&&e.baseRequest)return r;try{var h=s.adapterForWxMp.genAdapter({}),l=h.localStorage,d=h.reqClass;if(l&&(u.storage=new a({localStorage:l,adapter:t})),d){var p=new d({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});u.request=function(e){return function(t,r){return i(this,void 0,void 0,function(){return o(this,function(i){return[2,new Promise(function(i,o){var s=Object.assign({},r);s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));var a=wx.request({url:t,data:s.body,timeout:e._timeout,method:s.method||"GET",header:s.headers,success:function(e){(e=c(e,n(n({},r),{url:t}))).error&&o(e),i(e)},fail:function(e){o({error:"unreachable",error_description:e.message})},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("request")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{a.abort()}catch(e){}}}})})]})})}}(p)}return r.captchaOptions&&(u.baseRequest=u.request,u.request=void 0),n(n({},r),u)}catch(e){console.error("adapter generate fail:",e)}return r}(e,e.adapter)}},895:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},o.apply(this,arguments)},s=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},u=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},c=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},h=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=t.AuthError=t.AuthErrorCode=t.AuthErrorCategory=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=t.Auth=t.generateAuthInstance=t.LoginState=t.User=void 0;var l=r(722),d=r(548),p=r(19),f=r(266),v=r(916);Object.defineProperty(t,"WeixinAuthProvider",{enumerable:!0,get:function(){return v.WeixinAuthProvider}}),Object.defineProperty(t,"CustomAuthProvider",{enumerable:!0,get:function(){return v.CustomAuthProvider}}),Object.defineProperty(t,"AnonymousAuthProvider",{enumerable:!0,get:function(){return v.AnonymousAuthProvider}});var g=r(683),y=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},m=t.User=function(){function e(e){var t=e.cache,r=e.oauthInstance;this.cache=t,this.oauthInstance=r,this.setUserInfo()}var t,r,n;return e.prototype.checkLocalInfo=function(){return u(this,void 0,void 0,function(){return c(this,function(e){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]})})},e.prototype.checkLocalInfoAsync=function(){return u(this,void 0,void 0,function(){var e,t,r,n;return c(this,function(i){switch(i.label){case 0:return e=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return e.uid=i.sent(),t=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return t.gender=i.sent(),this.picture=this.getLocalUserInfo("picture"),r=this,[4,this.getLocalUserInfoAsync("email")];case 3:return r.email=i.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),n=this,[4,this.getLocalUserInfoAsync("username")];case 4:return n.username=i.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}})})},e.prototype.update=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(o({},e))];case 1:return t=r.sent(),this.setLocalUserInfo(t),[2]}})})},e.prototype.updateUserBasicInfo=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(o({},e))];case 1:return t.sent(),[4,this.refresh()];case 2:return t.sent(),[2]}})})},e.prototype.updatePassword=function(e,t){return this.oauthInstance.authApi.updatePasswordByOld({old_password:t,new_password:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&(0,p.throwError)(p.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(e)];case 1:if("INVALID_ACCESS_TOKEN"===(t=r.sent()).code)throw this.setLocalUserInfo({}),t;return this.setLocalUserInfo(t),[2,t]}})})},e.prototype.getLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);return e?r[e]:r||{}},e.prototype.setLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey;this.cache.setStore(t,e),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(t)];case 1:return[2,r.sent()[e]]}})})},e.prototype.setUserInfo=function(){var e=this,t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at","open_id"].forEach(function(t){e[t]=r[t]})},s([(0,p.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(t=void 0!==l.authModels&&l.authModels.UserProfile)?t:Object]),a("design:returntype","function"==typeof(r="undefined"!=typeof Promise&&Promise)?r:Object)],e.prototype,"update",null),s([(0,p.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String,String]),a("design:returntype",void 0)],e.prototype,"updatePassword",null),s([(0,p.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype",void 0)],e.prototype,"updateUsername",null),s([(0,p.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(n="undefined"!=typeof Promise&&Promise)?n:Object)],e.prototype,"refresh",null),e}();(0,v.applyUserV1Compat)(m);var _=function(){function e(e){var t=e.envId,r=e.cache,n=e.oauthInstance;t||(0,p.throwError)(p.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new m({cache:this.cache,oauthInstance:n})}return e.prototype.checkLocalState=function(){var e;this.oauthLoginState=null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},e.prototype.checkLocalStateAsync=function(){var e;return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.getLoginState()];case 1:return t.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return t.sent(),[2]}})})},e}();t.LoginState=_;var E=function(e){function t(t){var r=e.call(this)||this;return r.listeners=new Map,r.hasListenerSetUp=!1,r.config=t,r.oauthInstance=t.oauthInstance,r.cache=t.cache,r.init(),r.setAccessKey(),r}var r,n,d,v,m,E,b,I,A,w,T,S,O,P,R,C,U,N,D,L,k;return i(t,e),t.prototype.signInAnonymously=function(e){return u(this,void 0,Promise,function(){var t,r,n,i,s;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];case 1:return a.sent(),[4,this.createLoginState()];case 2:return t=a.sent(),[4,this.getSession()];case 3:return r=a.sent().data,n=(void 0===r?{}:r).session,[2,o(o({},t),{data:{user:n.user,session:n},error:null})];case 4:return i=a.sent(),(s=new l.AuthError(i,{method:"signInAnonymously"})).category===l.AuthErrorCategory.PROVIDER_NOT_ENABLED?(console.error(s.helpMessage),console.error("[CloudBase Auth] 提示:匿名登录需要在控制台开启「匿名登录」。\n 如果您需要使用用户名密码登录,请改用 auth.signInWithPassword({ username, password })。\n 不要在匿名登录失败后自动回退到密码登录,这两种方式的使用场景不同。")):(console.warn("[CloudBase Auth] signInAnonymously 失败 [".concat(s.category,"]: ").concat(s.message)),s.loginMethodHint&&console.warn(s.loginMethodHint)),[2,{data:{user:null,session:null},error:s}];case 5:return[2]}})})},t.prototype.signUp=function(e){return u(this,void 0,Promise,function(){var t,r,n=this;return c(this,function(i){switch(i.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?(e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[4,this.oauthInstance.authApi.signUp(e)]):[3,2];case 1:return i.sent(),[2,this.createLoginState()];case 2:return i.trys.push([2,4,,5]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email,usage:l.VerificationUsage.EMAIL}:{phone_number:this.formatPhone(e.phone)})];case 3:return t=i.sent(),[2,{data:{verifyOtp:function(r){var i=r.token,s=r.messageId,a=void 0===s?t.verification_id:s;return u(n,void 0,Promise,function(){var r,n,s,u,h;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.verify({verification_id:a||t.verification_id,verification_code:String(i)})];case 1:return r=c.sent(),t.is_user?[4,this.signIn({username:e.email||this.formatPhone(e.phone),verification_token:r.verification_token})]:[3,3];case 2:return c.sent(),[3,6];case 3:return delete(n=JSON.parse(JSON.stringify(e))).email,delete n.phone,[4,this.oauthInstance.authApi.signUp(o(o(o({},n),e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}),{verification_token:r.verification_token,verification_code:i}))];case 4:return c.sent(),[4,this.createLoginState()];case 5:c.sent(),c.label=6;case 6:return[4,this.getSession()];case 7:return s=c.sent().data,[2,{data:{user:(u=(void 0===s?{}:s).session).user,session:u},error:null}];case 8:return h=c.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(h,{method:"signUp"})}];case 9:return[2]}})})}},error:null}];case 4:return r=i.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(r,{method:"signUp"})}];case 5:return[2]}})})},t.prototype.signOut=function(e){var t,r;return u(this,void 0,Promise,function(){var n,i,s;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),n=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return i=a.sent(),[4,this.cache.removeStoreAsync(n)];case 2:return a.sent(),this.setAccessKey(),null===(t=this.config.eventBus)||void 0===t||t.fire(l.EVENTS.LOGIN_STATE_CHANGED,{eventType:l.LOGIN_STATE_CHANGED_TYPE.SIGN_OUT}),null===(r=this.config.eventBus)||void 0===r||r.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT}),[2,o(o({},i),{data:{},error:null})];case 3:return s=a.sent(),[2,{data:{},error:new l.AuthError(s,{method:"signOut"})}];case 4:return[2]}})})},t.prototype.onAuthStateChange=function(e){var t=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var r=Math.random().toString(36);return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(e),{data:{subscription:{id:r,callback:e,unsubscribe:function(){var n=t.listeners.get(r);n&&(n.delete(e),0===n.size&&t.listeners.delete(r))}}}}},t.prototype.signInWithPassword=function(e){var t,r;return u(this,void 0,Promise,function(){var n,i,s,a,u,h,d,p;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),this.validateAtLeastOne(e,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),n="username"in e?e.username:void 0,i="email"in e?e.email:void 0,s="phone"in e?e.phone:void 0,a=null!==(r=null===(t=e.options)||void 0===t?void 0:t.is_encrypt)&&void 0!==r?r:e.is_encrypt,[4,this.signIn(o({username:n||i||this.formatPhone(s),password:e.password},a?{isEncrypt:!0,version:"v2"}:{}))];case 1:return c.sent(),[4,this.getSession()];case 2:return u=c.sent().data,[2,{data:{user:(h=(void 0===u?{}:u).session).user,session:h},error:null}];case 3:return d=c.sent(),(p=new l.AuthError(d,{method:"signInWithPassword"})).category===l.AuthErrorCategory.PROVIDER_NOT_ENABLED?console.error(p.helpMessage):p.category===l.AuthErrorCategory.INVALID_CREDENTIALS||p.category===l.AuthErrorCategory.USER_NOT_FOUND?console.warn(p.helpMessage):console.warn("[CloudBase Auth] signInWithPassword 失败 [".concat(p.category,"]: ").concat(p.message)),p.loginMethodHint&&console.info(p.loginMethodHint),[2,{data:{user:null,session:null},error:p}];case 4:return[2]}})})},t.prototype.signInWithIdToken=function(e){return u(this,void 0,Promise,function(){var t,r,n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(e,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:e.token})];case 1:return i.sent(),[4,this.getSession()];case 2:return t=i.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=i.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(n,{method:"signInWithIdToken"})}];case 4:return[2]}})})},t.prototype.signInWithOtp=function(e){return u(this,void 0,Promise,function(){var t,r,n,i,s,a=this;return c(this,function(h){switch(h.label){case 0:if(t=e.options,r="email"in e?e.email:void 0,n="phone"in e?e.phone:void 0,!(null==t?void 0:t.emailRedirectTo)&&(void 0===(null==t?void 0:t.shouldCreateUser)||(null==t?void 0:t.shouldCreateUser)))return[2,this.signUp(r?{email:r}:{phone:n})];h.label=1;case 1:return h.trys.push([1,3,,4]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(o(o({email_redirect_to:null==t?void 0:t.emailRedirectTo},r?{email:r,usage:l.VerificationUsage.EMAIL}:{phone_number:this.formatPhone(n)}),{target:(null==t?void 0:t.emailRedirectTo)&&(null==t?void 0:t.shouldCreateUser)?"ANY":"USER"}))];case 2:return i=h.sent(),[2,{data:{user:null,session:null,verifyOtp:function(e){var t=e.token,o=e.messageId,s=void 0===o?i.verification_id:o;return u(a,void 0,Promise,function(){return c(this,function(e){return[2,this.verifyOtp(r?{email:r,token:String(t),messageId:s}:{phone:n,token:String(t),messageId:s})]})})}},error:null}];case 3:return s=h.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(s,{method:"signInWithOtp"})}];case 4:return[2]}})})},t.prototype.verifyOAuth=function(e){return u(this,void 0,Promise,function(){var t,r,n,i,s,a,u,h,d;return c(this,function(c){switch(c.label){case 0:t={},c.label=1;case 1:return c.trys.push([1,7,,8]),r=(null==e?void 0:e.code)||g.utils.getQuery("code"),n=(null==e?void 0:e.state)||g.utils.getQuery("state"),r?n?(i=(0,f.getBrowserSession)(n),t.type=null==i?void 0:i.type,(s=(null==e?void 0:e.provider)||(null==i?void 0:i.provider)||g.utils.getQuery("provider"))?[4,this.grantProviderToken({provider_id:s,provider_redirect_uri:location.origin+location.pathname,provider_code:r})]:[2,{data:o(o({},t),{user:null,session:null,redirectUrl:null}),error:new l.AuthError({message:"Provider is required"})}]):[2,{data:{user:null,session:null,redirectUrl:null},error:new l.AuthError({message:"State is required"})}]:[2,{data:{user:null,session:null,redirectUrl:null},error:new l.AuthError({message:"Code is required"})}];case 2:return a=c.sent().provider_token,u=void 0,i.type!==l.OAUTH_TYPE.BIND_IDENTITY?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:a,provider:s,fireEvent:!0})];case 3:return u=c.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:a})];case 5:(u=c.sent()).data=o(o({},t),u.data),c.label=6;case 6:return(h=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),h.delete("state"),u.data.redirectUrl=(0,f.addUrlSearch)(void 0===(null==i?void 0:i.search)?"?".concat(h.toString()):null==i?void 0:i.search,(null==i?void 0:i.hash)||location.hash),(0,f.removeBrowserSession)(n),[2,u];case 7:return d=c.sent(),[2,{data:o(o({},t),{user:null,session:null,redirectUrl:null}),error:new l.AuthError(d,{method:"verifyOAuth"})}];case 8:return[2]}})})},t.prototype.signInWithOAuth=function(e){var t,r,n,i,o;return u(this,void 0,Promise,function(){var s,a,u,h,d,p,v,g,m;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),s=(null===(t=e.options)||void 0===t?void 0:t.redirectTo)||location.href,a=new URL(s),u=a.origin+a.pathname,h=(null===(r=e.options)||void 0===r?void 0:r.state)||"prd-".concat(e.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:e.provider,provider_redirect_uri:u,state:h})];case 1:return d=c.sent().uri,p=decodeURIComponent(d),v=p,(null===(n=e.options)||void 0===n?void 0:n.queryParams)&&(g=new URL(p),Object.entries(e.options.queryParams).forEach(function(e){var t=e[0],r=e[1];g.searchParams.set(t,r)}),v=g.toString()),(0,f.saveToBrowserSession)(h,{provider:e.provider,search:a.search,hash:a.hash,type:(null===(i=e.options)||void 0===i?void 0:i.type)||l.OAUTH_TYPE.SIGN_IN}),y()&&!(null===(o=e.options)||void 0===o?void 0:o.skipBrowserRedirect)&&window.location.assign(v),[2,{data:{url:v,provider:e.provider},error:null}];case 2:return m=c.sent(),[2,{data:{url:null,provider:null},error:new l.AuthError(m,{method:"signInWithOAuth"})}];case 3:return[2]}})})},t.prototype.getClaims=function(){return u(this,void 0,Promise,function(){var e,t;return c(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return e=r.sent().accessToken,[2,{data:(0,l.weAppJwtDecodeAll)(e),error:null}];case 2:return t=r.sent(),[2,{data:{claims:null,header:null,signature:null},error:new l.AuthError(t,{method:"getClaims"})}];case 3:return[2]}})})},t.prototype.resetPasswordForEmail=function(e,t){return u(this,void 0,Promise,function(){var r,n,i,s,a,h,d=this;return c(this,function(p){switch(p.label){case 0:return p.trys.push([0,2,,3]),this.validateParams({emailOrPhone:e},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),r=(t||{}).redirectTo,n=e.includes("@"),i=void 0,n?i={email:e,usage:l.VerificationUsage.RECOVERY}:(s=this.formatPhone(e),i={phone_number:s}),[4,this.getVerification(o(o({},i),{target:"USER"}))];case 1:return a=p.sent(),[2,{data:{updateUser:function(t){return u(d,void 0,Promise,function(){var i,o,s,u;return c(this,function(c){switch(c.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.verify({verification_id:a.verification_id,verification_code:t.nonce})];case 2:return i=c.sent(),[4,this.oauthInstance.authApi.resetPassword({email:n?e:void 0,phone_number:n?void 0:e,new_password:t.password,verification_token:i.verification_token})];case 3:return c.sent(),null===(u=this.config.eventBus)||void 0===u||u.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:n?e:void 0,phone:n?void 0:e,password:t.password})];case 4:return o=c.sent(),r&&y()&&window.location.assign(r),[2,o];case 5:return s=c.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(s,{method:"resetPasswordForEmail"})}];case 6:return[2]}})})}},error:null}];case 2:return h=p.sent(),[2,{data:{updateUser:null},error:new l.AuthError(h,{method:"resetPasswordForEmail"})}];case 3:return[2]}})})},t.prototype.resetPasswordForOld=function(e){return u(this,void 0,Promise,function(){var t,r,n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:e.old_password,new_password:e.new_password})];case 1:return i.sent(),[4,this.getSession()];case 2:return t=i.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=i.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(n,{method:"resetPasswordForOld"})}];case 4:return[2]}})})},t.prototype.verifyOtp=function(e){return u(this,void 0,Promise,function(){var t,r,n,i,o,s,a;return c(this,function(u){switch(u.label){case 0:return u.trys.push([0,6,,7]),t=e.type,r=String(e.token),n="email"in e?e.email:void 0,i="phone"in e?e.phone:void 0,this.validateParams(e,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(t)?[4,this.verify({verification_id:e.messageId,verification_code:r})]:[3,2];case 1:return u.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:e.messageId,is_user:!0},verificationCode:r,username:n||this.formatPhone(i)||"",loginType:n?"email":"phone"})];case 3:u.sent(),u.label=4;case 4:return[4,this.getSession()];case 5:return o=u.sent().data,[2,{data:{user:(s=(void 0===o?{}:o).session).user,session:s},error:null}];case 6:return a=u.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(a,{method:"verifyOtp"})}];case 7:return[2]}})})},t.prototype.getSession=function(){return u(this,void 0,Promise,function(){var e,t,r,n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=i.sent())&&"accessKey"!==e.scope?[4,this.getUser(!1)]:[2,{data:{session:null,user:null},error:null}];case 2:return t=i.sent().data,r=(void 0===t?{}:t).user,[2,{data:{session:o(o({},e),{user:r}),user:r},error:null}];case 3:return n=i.sent(),[2,{data:{session:null,user:null},error:new l.AuthError(n,{method:"getSession"})}];case 4:return[2]}})})},t.prototype.refreshSession=function(e){return u(this,void 0,Promise,function(){var t,r,n,i,s;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(t=a.sent()).refresh_token=e||t.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(t)];case 2:return r=a.sent(),[4,this.getUser(!1)];case 3:return n=a.sent().data,[2,{data:{user:i=(void 0===n?{}:n).user,session:o(o({},r),{user:i})},error:null}];case 4:return s=a.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(s,{method:"refreshSession"})}];case 5:return[2]}})})},t.prototype.getUser=function(e){return void 0===e&&(e=!0),u(this,void 0,Promise,function(){var t,r,n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(t=i.sent())&&"accessKey"!==t.scope?(r=this.convertToUser,[4,this.getCurrentUser(e)]):[2,{data:{user:null},error:null}];case 2:return[2,{data:{user:r.apply(this,[i.sent()])},error:null}];case 3:return n=i.sent(),[2,{data:{user:null},error:new l.AuthError(n,{method:"getUser"})}];case 4:return[2]}})})},t.prototype.refreshUser=function(){return u(this,void 0,Promise,function(){var e,t,r;return c(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return n.sent(),[4,this.getSession()];case 2:return e=n.sent().data,[2,{data:{user:(t=(void 0===e?{}:e).session).user,session:t},error:null}];case 3:return r=n.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(r,{method:"refreshUser"})}];case 4:return[2]}})})},t.prototype.updateUser=function(e){var t;return u(this,void 0,Promise,function(){var r,n,i,s,a,d,p,f,v,g,y,m,_,E=this;return c(this,function(b){switch(b.label){case 0:if(b.trys.push([0,8,,9]),r=["password","new_password"].find(function(t){var r=e[t];return null!=r&&""!==r}))throw new l.AuthError({message:'updateUser 不支持更新密码,检测到传入了 "'.concat(r,'" 参数。如需修改密码请使用 resetPasswordForOld(旧密码修改)、resetPasswordForEmail(验证码重置)或 reauthenticate(重新认证后改密)')});if(!Object.keys(e).some(function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]}))throw new l.AuthError({message:"At least one field must be provided for update"});return n=e.email,i=e.phone,s=h(e,["email","phone"]),d=void 0!==i,p={},(a=void 0!==n)||d?(f=void 0,a?(f={email:e.email,usage:l.VerificationUsage.REAUTHENTICATION},v="email_change"):(g=this.formatPhone(e.phone),f={phone_number:g},v="phone_change"),[4,this.getVerification(o({},f))]):[3,4];case 1:return y=b.sent(),Object.keys(s).length>0?[4,this.updateUserBasicInfo(s)]:[3,3];case 2:b.sent(),b.label=3;case 3:return p={messageId:y.verification_id,verifyOtp:function(t){return u(E,void 0,Promise,function(){var r,n,i,o;return c(this,function(s){switch(s.label){case 0:return s.trys.push([0,11,,12]),t.email&&e.email===t.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:t.token,messageId:y.verification_id})]:[3,3];case 1:return(r=s.sent()).error?[2,r]:[4,this.updateUserBasicInfo({email:e.email})];case 2:return s.sent(),[3,9];case 3:return t.phone&&e.phone===t.phone?[4,this.verifyOtp({type:"phone_change",phone:e.phone,token:t.token,messageId:y.verification_id})]:[3,6];case 4:return(r=s.sent()).error?[2,r]:[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return s.sent(),[3,9];case 6:return[4,this.verifyOtp(a?{type:v,email:e.email,token:t.token,messageId:y.verification_id}:{type:v,phone:e.phone,token:t.token,messageId:y.verification_id})];case 7:return(r=s.sent()).error?[2,r]:[4,this.updateUserBasicInfo(e)];case 8:s.sent(),s.label=9;case 9:return[4,this.getUser(!1)];case 10:return n=s.sent().data.user,null===(o=this.config.eventBus)||void 0===o||o.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:{user:n},error:null}];case 11:return i=s.sent(),[2,{data:{user:null},error:new l.AuthError(i,{method:"updateUser"})}];case 12:return[2]}})})}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:b.sent(),b.label=6;case 6:return[4,this.getUser(!1)];case 7:return m=b.sent().data.user,Object.keys(s).length>0&&(null===(t=this.config.eventBus)||void 0===t||t.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.USER_UPDATED})),[2,{data:o({user:m},p),error:null}];case 8:return _=b.sent(),[2,{data:{user:null},error:new l.AuthError(_,{method:"updateUser"})}];case 9:return[2]}})})},t.prototype.getUserIdentities=function(){var e;return u(this,void 0,Promise,function(){var t,r;return c(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return t=n.sent(),[2,{data:{identities:null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.filter(function(e){return!!e.bind})},error:null}];case 2:return r=n.sent(),[2,{data:{identities:null},error:new l.AuthError(r,{method:"getUserIdentities"})}];case 3:return[2]}})})},t.prototype.linkIdentity=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:e.provider,options:{type:l.OAUTH_TYPE.BIND_IDENTITY}})];case 1:return r.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return t=r.sent(),[2,{data:{provider:null},error:new l.AuthError(t,{method:"linkIdentity"})}];case 3:return[2]}})})},t.prototype.unlinkIdentity=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:e.provider})];case 1:return r.sent(),[2,{data:{},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new l.AuthError(t,{method:"unlinkIdentity"})}];case 3:return[2]}})})},t.prototype.reauthenticate=function(){return u(this,void 0,Promise,function(){var e,t,r,n,i=this;return c(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.getUser(!1)];case 1:return e=s.sent().data.user,this.validateAtLeastOne(e,[["email","phone"]],"You must provide either an email or phone number"),t=e.email?{email:e.email,usage:l.VerificationUsage.REAUTHENTICATION}:{phone_number:this.formatPhone(e.phone)},[4,this.getVerification(t)];case 2:return r=s.sent(),[2,{data:{updateUser:function(e){return u(i,void 0,Promise,function(){var n,i,s,a,u;return c(this,function(c){switch(c.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"}}),c.label=1;case 1:return c.trys.push([1,9,,10]),e.password?[4,this.verify({verification_id:r.verification_id,verification_code:e.nonce})]:[3,5];case 2:return n=c.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:n.verification_token})];case 3:return i=c.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:e.password,sudo_token:i.sudo_token})];case 4:return c.sent(),[3,7];case 5:return[4,this.signInWithUsername(o(o({verificationInfo:r,verificationCode:e.nonce},t),{loginType:t.email?"email":"phone"}))];case 6:c.sent(),c.label=7;case 7:return[4,this.getSession()];case 8:return s=c.sent().data,[2,{data:{user:(a=(void 0===s?{}:s).session).user,session:a},error:null}];case 9:return u=c.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(u,{method:"reauthenticate"})}];case 10:return[2]}})})}},error:null}];case 3:return n=s.sent(),[2,{data:{updateUser:null},error:new l.AuthError(n,{method:"reauthenticate"})}];case 4:return[2]}})})},t.prototype.resend=function(e){return u(this,void 0,Promise,function(){var t,r,n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),t="signup"===e.type?"ANY":"USER",r={target:t},"email"in e&&(r.email=e.email,r.usage=l.VerificationUsage.EMAIL),"phone"in e&&(r.phone_number=this.formatPhone(e.phone)),[4,this.oauthInstance.authApi.getVerification(r)];case 1:return[2,{data:{messageId:i.sent().verification_id},error:null}];case 2:return n=i.sent(),[2,{data:{messageId:null},error:new l.AuthError(n,{method:"resend"})}];case 3:return[2]}})})},t.prototype.setSession=function(e){var t;return u(this,void 0,Promise,function(){var r,n,i;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(e,{throwError:!0})];case 1:return o.sent(),[4,this.getSession()];case 2:return r=o.sent().data,n=(void 0===r?{}:r).session,null===(t=this.config.eventBus)||void 0===t||t.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,{data:{user:n.user,session:n},error:null}];case 3:return i=o.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(i,{method:"setSession"})}];case 4:return[2]}})})},t.prototype.exchangeCodeForSession=function(){return u(this,void 0,void 0,function(){return c(this,function(e){return[2]})})},t.prototype.deleteUser=function(e){return u(this,void 0,Promise,function(){var t,r;return c(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(e)];case 1:return t=n.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:t})];case 2:return n.sent(),[2,{data:{},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new l.AuthError(r,{method:"deleteUser"})}];case 4:return[2]}})})},t.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),u(this,void 0,Promise,function(){var t,r,n,i,o;return c(this,function(s){try{return t=e.config_version||"env",r=Object.keys(e.query||{}).map(function(t){return"".concat(t,"=").concat(e.query[t])}).join("&"),p.adapterForWxMp.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(r?"?".concat(r):"")}):(n=e.redirect_uri||window.location.href,i=new URL(n),o="".concat(i.origin,"/__auth/?app_id=").concat(e.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(t,"&redirect_uri=").concat(encodeURIComponent(n)).concat(r?"&".concat(r):""),window.location.href=o),[2,{data:{},error:null}]}catch(e){return[2,{data:{},error:new l.AuthError(e,{method:"toDefaultLoginPage"})}]}return[2]})})},t.prototype.signInWithCustomTicket=function(e){return u(this,void 0,Promise,function(){var t,r,n,i;return c(this,function(s){switch(s.label){case 0:e&&this.setCustomSignFunc(e),s.label=1;case 1:return s.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return s.sent(),[4,this.createLoginState()];case 3:return t=s.sent(),[4,this.getSession()];case 4:return r=s.sent().data,n=(void 0===r?{}:r).session,[2,o(o({},t),{data:{user:n.user,session:n},error:null})];case 5:return i=s.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(i,{method:"signInWithCustomTicket"})}];case 6:return[2]}})})},t.prototype.signInWithOpenId=function(e){var t=(void 0===e?{}:e).useWxCloud,r=void 0===t||t;return u(this,void 0,Promise,function(){var e,t,n,i,s,a,h=this;return c(this,function(d){switch(d.label){case 0:if(!p.adapterForWxMp.isMatch())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,t=function(t){return u(h,void 0,void 0,function(){var n,i;return c(this,function(o){switch(o.label){case 0:n=void 0,i=void 0,o.label=1;case 1:return o.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},r)];case 2:if((null==(n=o.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:n.provider_token},r)];case 3:if(null==(i=o.sent())?void 0:i.error_code)throw i;return[3,5];case 4:throw o.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(i)];case 6:return o.sent(),[2]}})})},d.label=1;case 1:return d.trys.push([1,5,,6]),[4,new Promise(function(e,r){wx.login({success:function(n){return u(h,void 0,void 0,function(){var i;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,t(n.code)];case 1:return o.sent(),e(!0),[3,3];case 2:return i=o.sent(),r(i),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})})];case 2:return d.sent(),[4,this.createLoginState()];case 3:return n=d.sent(),[4,this.getSession()];case 4:return i=d.sent().data,s=(void 0===i?{}:i).session,[2,o(o({},n),{data:{user:s.user,session:s},error:null})];case 5:return a=d.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(a,{method:"signInWithOpenId"})}];case 6:return[2]}})})},t.prototype.signInWithPhoneAuth=function(e){var t=e.phoneCode,r=void 0===t?"":t,n=e.useWxCloud,i=void 0!==n&&n;return u(this,void 0,Promise,function(){var e,t,n,s,a,u,h,d,f;return c(this,function(c){switch(c.label){case 0:return p.adapterForWxMp.isMatch()?(e=wx.getAccountInfoSync().miniProgram,t={provider_params:{provider_code_type:"phone",code:r,appid:e.appId},provider_id:e.appId},[4,wx.login()]):[2,{data:{user:null,session:null},error:new l.AuthError({message:"wx api undefined"})}];case 1:n=c.sent().code,t.provider_code=n,c.label=2;case 2:return c.trys.push([2,5,,6]),[4,this.oauthInstance.authApi.grantProviderToken(t,i)];case 3:if((s=c.sent()).error_code)throw s;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:s.provider_token},i)];case 4:if(null==(a=c.sent())?void 0:a.error_code)throw a;return[3,6];case 5:return u=c.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(u,{method:"signInWithPhoneAuth"})}];case 6:return[4,this.createLoginState()];case 7:return h=c.sent(),[4,this.getSession()];case 8:return d=c.sent().data,f=(void 0===d?{}:d).session,[2,o(o({},h),{data:{user:f.user,session:f},error:null})]}})})},t.prototype.bindPhoneNumber=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.editContact(e)]})})},t.prototype.unbindProvider=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.unbindProvider(e)]})})},t.prototype.bindEmail=function(e){return this.oauthInstance.authApi.editContact(e)},t.prototype.verify=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.verify(e)]})})},t.prototype.getVerification=function(e,t){return u(this,void 0,Promise,function(){return c(this,function(r){return e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[2,this.oauthInstance.authApi.getVerification(e,t)]})})},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var e=this.hasLoginState();return e&&e.user||null}(0,p.printWarn)(p.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(e){return void 0===e&&(e=!0),u(this,void 0,Promise,function(){var t,r,n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),e?[4,this.getLoginState()]:[3,3];case 1:return(t=i.sent())?[4,t.user.refresh()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[3,5];case 4:return i.sent(),[3,5];case 5:return[4,this.getLoginState()];case 6:return(r=i.sent())?(n=r.user.getLocalUserInfo(),[4,r.user.checkLocalInfoAsync()]):[3,8];case 7:return i.sent(),[2,o(o({},r.user),n)];case 8:return[2,null]}})})},t.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return u(this,void 0,Promise,function(){var e,r,n=this;return c(this,function(i){switch(i.label){case 0:if(!p.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,r=function(r){return u(n,void 0,void 0,function(){var n,i;return c(this,function(o){switch(o.label){case 0:n=void 0,i=void 0,o.label=1;case 1:return o.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},t)];case 2:if((null==(n=o.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:n.provider_token},t)];case 3:if(null==(i=o.sent())?void 0:i.error_code)throw i;return[3,5];case 4:throw o.sent();case 5:return[2]}})})},[4,new Promise(function(e,t){wx.login({success:function(i){return u(n,void 0,void 0,function(){var n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,r(i.code)];case 1:return o.sent(),e(!0),[3,3];case 2:return n=o.sent(),t(n),[3,3];case 3:return[2]}})})},fail:function(e){var r=new Error(null==e?void 0:e.errMsg);r.code=null==e?void 0:e.errno,t(r)}})})];case 1:return i.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}})})},t.prototype.bindOpenId=function(){return u(this,void 0,Promise,function(){var e,t,r=this;return c(this,function(n){switch(n.label){case 0:if(!p.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return u(r,void 0,void 0,function(){var r;return c(this,function(n){switch(n.label){case 0:r=void 0,n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}})];case 2:if((null==(r=n.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:r.provider_token})];case 3:return n.sent(),[3,5];case 4:throw n.sent();case 5:return[2]}})})},[4,new Promise(function(e,n){wx.login({success:function(i){return u(r,void 0,void 0,function(){var r;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,t(i.code)];case 1:return o.sent(),e(!0),[3,3];case 2:return r=o.sent(),n(r),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})})];case 1:return n.sent(),[2]}})})},t.prototype.signInWithUnionId=function(){return u(this,void 0,Promise,function(){var e=this;return c(this,function(t){switch(t.label){case 0:if(!p.adapterForWxMp.isMatch())throw Error("wx api undefined");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise(function(t,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(i){return u(e,void 0,void 0,function(){var e,o,s,a,u;return c(this,function(c){switch(c.label){case 0:e=null==n?void 0:n.appId,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:i.code,provider_id:e,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return o=c.sent(),(s=o.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:e,provider_token:s})]:(r(o),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(t(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})})];case 2:return t.sent(),[3,4];case 3:throw t.sent();case 4:return[2,this.createLoginState()]}})})},t.prototype.signInWithSms=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,i=void 0===n?"":n,o=e.phoneNum,s=void 0===o?"":o,a=e.bindInfo,h=void 0===a?void 0:a;return u(this,void 0,Promise,function(){return c(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:i,bindInfo:h,username:s,loginType:"sms"})]}catch(e){throw e}return[2]})})},t.prototype.signInWithEmail=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,i=void 0===n?"":n,o=e.bindInfo,s=void 0===o?void 0:o,a=e.email,h=void 0===a?"":a;return u(this,void 0,Promise,function(){return c(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:i,bindInfo:s,username:h,loginType:"email"})]}catch(e){throw e}return[2]})})},t.prototype.setCustomSignFunc=function(e){this.oauthInstance.authApi.setCustomSignFunc(e)},t.prototype.signIn=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signIn(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.setPassword=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.setPassword(e)]})})},t.prototype.isUsernameRegistered=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,p.throwError)(p.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:e})];case 1:return[2,t.sent().exist]}})})},t.prototype.hasLoginState=function(){var e;if("async"!==this.cache.mode)return(null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync())?new _({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,p.printWarn)(p.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},t.prototype.getLoginState=function(){return u(this,void 0,Promise,function(){var e;return c(this,function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,null];case 4:return e?[2,new _({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}})})},t.prototype.getUserInfo=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.getCurrentUser()]})})},t.prototype.getWedaUserInfo=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]})})},t.prototype.updateUserBasicInfo=function(e){return u(this,void 0,void 0,function(){var t;return c(this,function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(t=r.sent())?[4,t.user.updateUserBasicInfo(e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}})})},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]})})},t.prototype.queryUser=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]})})},t.prototype.getAccessToken=function(){return u(this,void 0,Promise,function(){return c(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:e.sent(),env:this.config.env}]}})})},t.prototype.grantProviderToken=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]})})},t.prototype.patchProviderToken=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]})})},t.prototype.signInWithProvider=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.grantToken=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.grantToken(e)];case 1:return t.sent(),[2,this.createLoginState()]}})})},t.prototype.genProviderRedirectUri=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]})})},t.prototype.resetPassword=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]})})},t.prototype.deviceAuthorize=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]})})},t.prototype.sudo=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.sudo(e)]})})},t.prototype.deleteMe=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]})})},t.prototype.getProviders=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getProviders()]})})},t.prototype.loginScope=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.loginScope()]})})},t.prototype.loginGroups=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.loginGroups()]})})},t.prototype.onLoginStateChanged=function(e){var t;return u(this,void 0,void 0,function(){var r,n=this;return c(this,function(i){switch(i.label){case 0:return null===(t=this.config.eventBus)||void 0===t||t.on(l.EVENTS.LOGIN_STATE_CHANGED,function(t){return u(n,void 0,void 0,function(){var r,n,i;return c(this,function(s){switch(s.label){case 0:return(null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.eventType)===l.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR?[3,2]:[4,this.getLoginState()];case 1:return n=s.sent(),[3,3];case 2:n={},s.label=3;case 3:return r=n,e.call(this,o(o({},t),r)),[2]}})})}),[4,this.getLoginState()];case 1:return r=i.sent(),e.call(this,r),[2]}})})},t.prototype.refreshTokenForce=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]})})},t.prototype.getCredentials=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getCredentials()]})})},t.prototype.setCredentials=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(e)];case 1:return t.sent(),[2]}})})},t.prototype.getProviderSubType=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]})})},t.prototype.createCaptchaData=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]})})},t.prototype.verifyCaptchaData=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]})})},t.prototype.getMiniProgramQrCode=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]})})},t.prototype.getMiniProgramQrCodeStatus=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]})})},t.prototype.modifyPassword=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]})})},t.prototype.modifyPasswordWithoutLogin=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]})})},t.prototype.getUserBehaviorLog=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.getUserBehaviorLog(e)]})})},t.prototype.signInWithUsername=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,i=void 0===n?"":n,s=e.username,a=void 0===s?"":s,h=e.bindInfo,l=void 0===h?void 0:h,d=e.loginType,p=void 0===d?"":d;return u(this,void 0,Promise,function(){var e,t,n,s,u,h,d;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:i})];case 1:if(null==(e=c.sent())?void 0:e.error_code)throw e;return t=e.verification_token,n=this.formatPhone(a),s={phone_number:n},"email"===p&&(s={email:n=a}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:t})]:[3,5];case 2:if(null==(u=c.sent())?void 0:u.error_code)throw u;return l?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==l?void 0:l.providerToken})]:[3,4];case 3:if(null==(h=c.sent())?void 0:h.error_code)throw h;c.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(o(o({},s),{verification_token:t,provider_token:null==l?void 0:l.providerId}))];case 6:if(null==(d=c.sent())?void 0:d.error_code)throw d;c.label=7;case 7:return[2,this.createLoginState()];case 8:throw c.sent();case 9:return[2]}})})},t.prototype.createLoginState=function(e,t){var r,n;return u(this,void 0,Promise,function(){var i;return c(this,function(o){switch(o.label){case 0:return[4,(i=new _({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return o.sent(),(null==t?void 0:t.userInfo)?(i.user.setLocalUserInfo(t.userInfo),[3,5]):[3,2];case 2:return(null==t?void 0:t.asyncRefreshUser)?(i.user.refresh(e),[3,5]):[3,3];case 3:return[4,i.user.refresh(e)];case 4:o.sent(),o.label=5;case 5:return null===(r=this.config.eventBus)||void 0===r||r.fire(l.EVENTS.LOGIN_STATE_CHANGED,{eventType:l.LOGIN_STATE_CHANGED_TYPE.SIGN_IN}),null===(n=this.config.eventBus)||void 0===n||n.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,i]}})})},t.prototype.setAccessKey=function(){var e,t;return u(this,void 0,void 0,function(){var r,n;return c(this,function(i){if(r="",n="",this.config.accessKey?(r=this.config.accessKey,n="accessKey"):(null===(e=this.config.auth)||void 0===e?void 0:e.secretId)&&(null===(t=this.config.auth)||void 0===t?void 0:t.secretKey)&&(r="",n=l.DEFAULT_NODE_ACCESS_SCOPE),!n)return[2];try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:r,token_type:"Bearer",scope:n,expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]})})},t.prototype.formatPhone=function(e){return!/\s+/.test(e)&&/^\+\d{1,3}\d+/.test(e)?e.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(e)?e:"+86 ".concat(e)},t.prototype.notifyListeners=function(e,t,r){this.listeners.forEach(function(n){n.forEach(function(n){try{n(e,t,r)}catch(e){console.error("Error in auth state change callback:",e)}})})},t.prototype.setupListeners=function(){var e,t=this;null===(e=this.config.eventBus)||void 0===e||e.on(l.EVENTS.AUTH_STATE_CHANGED,function(e){return u(t,void 0,void 0,function(){var t,r,n,i,o;return c(this,function(s){switch(s.label){case 0:return t=null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.event,r=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(t,n,r),[2]}})})})},t.prototype.convertToUser=function(e){var t,r,n,i,o,s;if(!e)return null;var a=(null==e?void 0:e.email)||"",u=(null==e?void 0:e.phone_number)||"",c=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:c,aud:"authenticated",role:null===(r=null===(t=e.groups)||void 0===t?void 0:t.map)||void 0===r?void 0:r.call(t,function(e){return"string"==typeof e?e:e.id}),email:a||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:u,phone_confirmed_at:u?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(n=e.loginType)||void 0===n?void 0:n.toLowerCase())||"cloudbase",providers:[(null===(i=e.loginType)||void 0===i?void 0:i.toLowerCase())||"cloudbase"]},user_metadata:{name:null==e?void 0:e.name,picture:null==e?void 0:e.picture,username:null==e?void 0:e.username,gender:null==e?void 0:e.gender,locale:null==e?void 0:e.locale,uid:e.uid,nickName:e.nickName||(null==e?void 0:e.name),avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:null!==(o=e.hasPassword)&&void 0!==o?o:"SET"===e.password,open_id:null==e?void 0:e.open_id},identities:(null===(s=null==e?void 0:e.providers)||void 0===s?void 0:s.map(function(t){return{id:t.id||"",identity_id:t.id||"",user_id:c,identity_data:{provider_id:t.id,provider_user_id:t.provider_user_id,name:t.name},provider:t.id||"cloudbase",created_at:e.created_at,updated_at:e.updated_at,last_sign_in_at:e.last_sign_in_at}}))||[],created_at:e.created_at,updated_at:e.updated_at,is_anonymous:"anonymous"===e.name}},t.prototype.validateParams=function(e,t){for(var r=0,n=Object.entries(t);r<n.length;r++){var i=n[r],o=i[0],s=i[1];if(s.required&&(void 0===(null==e?void 0:e[o])||null===(null==e?void 0:e[o])||""===(null==e?void 0:e[o])))throw new l.AuthError({message:s.message})}},t.prototype.validateAtLeastOne=function(e,t,r){if(!t.some(function(t){return t.some(function(t){return void 0!==(null==e?void 0:e[t])&&null!==(null==e?void 0:e[t])&&""!==(null==e?void 0:e[t])})}))throw new l.AuthError({message:r})},t.prototype.init=function(){var e;return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return t.sent()&&(null===(e=this.config.eventBus)||void 0===e||e.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION})),[3,3];case 2:return t.sent(),[3,3];case 3:return[2,{error:null}]}})})},s([(0,p.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(r=void 0!==l.authModels&&l.authModels.BindPhoneRequest)?r:Object]),a("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),s([(0,p.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(n=void 0!==l.authModels&&l.authModels.UnbindProviderRequest)?n:Object]),a("design:returntype","function"==typeof(d="undefined"!=typeof Promise&&Promise)?d:Object)],t.prototype,"unbindProvider",null),s([(0,p.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(v=void 0!==l.authModels&&l.authModels.BindEmailRequest)?v:Object]),a("design:returntype",void 0)],t.prototype,"bindEmail",null),s([(0,p.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(m=void 0!==l.authModels&&l.authModels.VerifyRequest)?m:Object]),a("design:returntype","function"==typeof(E="undefined"!=typeof Promise&&Promise)?E:Object)],t.prototype,"verify",null),s([(0,p.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(b=void 0!==l.authModels&&l.authModels.GetVerificationRequest)?b:Object,Object]),a("design:returntype","function"==typeof(I="undefined"!=typeof Promise&&Promise)?I:Object)],t.prototype,"getVerification",null),s([(0,p.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(A="undefined"!=typeof Promise&&Promise)?A:Object)],t.prototype,"getCurrentUser",null),s([(0,p.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(w="undefined"!=typeof Promise&&Promise)?w:Object)],t.prototype,"signInAnonymouslyInWx",null),s([(0,p.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],t.prototype,"bindOpenId",null),s([(0,p.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(S="undefined"!=typeof Promise&&Promise)?S:Object)],t.prototype,"signInWithUnionId",null),s([(0,p.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(O="undefined"!=typeof Promise&&Promise)?O:Object)],t.prototype,"signInWithSms",null),s([(0,p.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(P="undefined"!=typeof Promise&&Promise)?P:Object)],t.prototype,"signInWithEmail",null),s([(0,p.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype","function"==typeof(R="undefined"!=typeof Promise&&Promise)?R:Object)],t.prototype,"isUsernameRegistered",null),s([(0,p.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(C="undefined"!=typeof Promise&&Promise)?C:Object)],t.prototype,"getLoginState",null),s([(0,p.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(U="undefined"!=typeof Promise&&Promise)?U:Object)],t.prototype,"getUserInfo",null),s([(0,p.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(N="undefined"!=typeof Promise&&Promise)?N:Object)],t.prototype,"getWedaUserInfo",null),s([(0,p.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(D=void 0!==l.authModels&&l.authModels.BindWithProviderRequest)?D:Object]),a("design:returntype","function"==typeof(L="undefined"!=typeof Promise&&Promise)?L:Object)],t.prototype,"bindWithProvider",null),s([(0,p.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(k="undefined"!=typeof Promise&&Promise)?k:Object)],t.prototype,"getProviderSubType",null),t}(v.AuthV1Compat);function b(e,t){var r,n,i,s,a=this,h=e.region,f=void 0===h?"ap-shanghai":h,v=e.i18n,g=e.accessKey,y=e.useWxCloud,m=(null==t?void 0:t.platform)||p.useDefaultAdapter.bind(t)(),_=m.runtime,b=m.adapter,I=t||{},A=I.env,w=I.clientId,T=I.debug,S=I.cache,O=I.app,P=I.getApiOrigin,R=(t||{}).apiOrigin;R||(R="https://".concat(A,".").concat(f,".tcb-api.tencentcloudapi.com"));var C,U={env:A,clientId:w,i18n:v,accessKey:g,useWxCloud:y,eventBus:new p.CloudbaseEventEmitter},N=new l.CloudbaseOAuth((0,d.useAuthAdapter)(o(o({},U),{apiOrigin:R,getApiOrigin:P,apiPath:(null==e?void 0:e.apiPath)||l.AUTH_API_PREFIX,storage:null==e?void 0:e.storage,baseRequest:null==e?void 0:e.baseRequest,request:null==e?void 0:e.request,anonymousSignInFunc:null==e?void 0:e.anonymousSignInFunc,captchaOptions:null==e?void 0:e.captchaOptions,wxCloud:null==e?void 0:e.wxCloud,adapter:b,onCredentialsError:(C=U.eventBus,function(e){C.fire(l.EVENTS.LOGIN_STATE_CHANGED,o(o({},e),{eventType:l.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR}))}),headers:o({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:T,auth:null===(n=null===(r=t.app)||void 0===r?void 0:r.config)||void 0===n?void 0:n.auth}))),D=new E(o(o({},U),{region:f,persistence:e.persistence,debug:T,cache:S||new p.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(A)},platformInfo:m}),runtime:_||"web",_fromApp:O,oauthInstance:N,auth:null===(s=null===(i=t.app)||void 0===i?void 0:i.config)||void 0===s?void 0:s.auth}));return N.initializeSession(function(e,t){return u(a,void 0,void 0,function(){return c(this,function(r){return e?(e.type===l.OAUTH_TYPE.SIGN_IN?t?U.eventBus.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.SIGNED_IN,info:o(o({},e),{error:t})}):e.user&&D.createLoginState({},{userInfo:e.user}):e.type===l.OAUTH_TYPE.BIND_IDENTITY&&U.eventBus.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:o(o({},e),{error:t})}),[2]):[2]})})}),{authInstance:D,oauthInstance:N}}t.Auth=E,t.generateAuthInstance=b;var I="auth";function A(e,t){for(var r=[],n=0;n<=e.length;n++)r[n]=[n];for(var i=0;i<=t.length;i++)r[0][i]=i;for(n=1;n<=e.length;n++)for(i=1;i<=t.length;i++){var o=e[n-1].toLowerCase()===t[i-1].toLowerCase()?0:1;r[n][i]=Math.min(r[n-1][i]+1,r[n][i-1]+1,r[n-1][i-1]+o)}return r[e.length][t.length]}var w={name:"auth",namespace:I,entity:function(e){var t=function(e){var t,r=this;if(this.authInstance&&!e)return this.authInstance;e=e||{region:"",persistence:"local",apiPath:l.AUTH_API_PREFIX};var n=this.platform.adapter,i=e.persistence||n.primaryStorage;i&&i!==this.config.persistence&&this.updateConfig({persistence:i});var s=b(o(o({wxCloud:this.config.wxCloud,storage:this.config.storage},e),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(t=this.config.auth)||void 0===t?void 0:t.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,getApiOrigin:function(){return r.request.getBaseEndPoint(r.config.endPointMode||"CLOUD_API")},platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),a=s.authInstance,u=s.oauthInstance;return this.oauthInstance=u,this.authInstance=a,this.authInstance},r=t.call(this,e);Object.assign(t,r),Object.setPrototypeOf(t,Object.getPrototypeOf(r));var n="undefined"!=typeof Proxy?new Proxy(t,{get:function(e,t,r){var n=Reflect.get(e,t,r);if(void 0!==n||"string"!=typeof t)return n;var i=function(e,t){for(var r=null,n=1/0,i=0,o=t;i<o.length;i++){var s=o[i];if(!s.startsWith("_")&&"constructor"!==s){var a=A(e,s);a<n&&(n=a,r=s)}}return r}(t,Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)).filter(function(t){return"function"==typeof e[t]}));return i&&console.warn("[CloudBase Auth] auth.".concat(t," is not a function. Did you mean: auth.").concat(i,"() ?")),n}}):t;return this[I]=n,n}};try{cloudbase.registerComponent(w)}catch(e){}var T=r(722);Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return T.AuthErrorCategory}}),Object.defineProperty(t,"AuthErrorCode",{enumerable:!0,get:function(){return T.AuthErrorCode}}),Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return T.AuthError}}),t.registerAuth=function(e){try{e.registerComponent(w)}catch(e){console.warn(e)}}},19:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.adapterForWxMp=t.CloudbaseCache=t.CloudbaseEventEmitter=t.catchErrorsDecorator=t.COMMUNITY_SITE_URL=t.ERRORS=t.throwError=t.printWarn=void 0;var i=r(616);Object.defineProperty(t,"printWarn",{enumerable:!0,get:function(){return i.printWarn}}),Object.defineProperty(t,"throwError",{enumerable:!0,get:function(){return i.throwError}});var o=r(794);Object.defineProperty(t,"ERRORS",{enumerable:!0,get:function(){return o.ERRORS}}),Object.defineProperty(t,"COMMUNITY_SITE_URL",{enumerable:!0,get:function(){return o.COMMUNITY_SITE_URL}});var s=r(141);Object.defineProperty(t,"catchErrorsDecorator",{enumerable:!0,get:function(){return s.catchErrorsDecorator}});var a=r(689);Object.defineProperty(t,"CloudbaseEventEmitter",{enumerable:!0,get:function(){return a.CloudbaseEventEmitter}});var u=r(197);Object.defineProperty(t,"CloudbaseCache",{enumerable:!0,get:function(){return u.CloudbaseCache}});var c=r(917);Object.defineProperty(t,"adapterForWxMp",{enumerable:!0,get:function(){return n(c).default}});var h=r(182);Object.defineProperty(t,"useDefaultAdapter",{enumerable:!0,get:function(){return h.useDefaultAdapter}})},266:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.removeUrlParams=t.addUrlSearch=t.removeBrowserSession=t.getBrowserSession=t.saveToBrowserSession=void 0,t.saveToBrowserSession=function(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch(e){console.error("Failed to save to browser session:",e)}},t.getBrowserSession=function(e){try{return JSON.parse(sessionStorage.getItem(e))}catch(e){return console.error("Failed to get browser session:",e),null}},t.removeBrowserSession=function(e){try{return sessionStorage.removeItem(e),!0}catch(e){return console.error("Failed to remove browser session:",e),null}},t.addUrlSearch=function(e,t){if(void 0!==e){var r=new URL(window.location.href);return r.search=e,r.hash=t||r.hash,window.history.replaceState({},"",r.href),r.href}},t.removeUrlParams=function(e){if("undefined"!=typeof window)try{var t=new URL(window.location.href);e.forEach(function(e){t.searchParams.delete(e)}),window.history.replaceState({},"",t.href)}catch(e){console.error("Failed to remove URL params:",e)}}},916:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.applyUserV1Compat=t.AuthV1Compat=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=void 0;var s=r(722),a=r(19),u=function(){function e(e){}return e.prototype.signInWithRedirect=function(){throw new Error("[v1 兼容] WeixinAuthProvider.signInWithRedirect() 在当前版本中无法实现。 建议使用 auth.signInWithOAuth({ provider: 'providerId' }) 替代。")},e.prototype.getRedirectResult=function(e){return i(this,void 0,Promise,function(){return o(this,function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getRedirectResult() 在当前版本中无法实现。 建议使用 auth.verifyOAuth({ code, state, provider }) 替代。")})})},e.prototype.getLinkRedirectResult=function(e){return i(this,void 0,Promise,function(){return o(this,function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getLinkRedirectResult() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")})})},e}();t.WeixinAuthProvider=u;var c=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.authInstance.signInWithCustomTicket(function(){return Promise.resolve(e)})];case 1:return t.sent(),[2]}})})},e}();t.CustomAuthProvider=c;var h=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(){return i(this,void 0,Promise,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.authInstance.signInAnonymously({})];case 1:return e.sent(),[2]}})})},e}();t.AnonymousAuthProvider=h;var l=function(){function e(){}return e.prototype.weixinAuthProvider=function(e){return new u({authInstance:this,appid:e.appid,scope:e.scope})},e.prototype.customAuthProvider=function(){return new c({authInstance:this})},e.prototype.anonymousAuthProvider=function(){return new h({authInstance:this})},e.prototype.signUpWithEmailAndPassword=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signUp({email:e,password:t})];case 1:return[2,r.sent()]}})})},e.prototype.signInWithEmailAndPassword=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}})})},e.prototype.sendPasswordResetEmail=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),[4,this.getVerification({email:e})];case 1:return t.sent(),[2]}})})},e.prototype.signInWithUsernameAndPassword=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"username must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}})})},e.prototype.sendPhoneCode=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),t=this.formatPhone(e),[4,this.getVerification({phone_number:t})];case 1:return r.sent(),[2,!0]}})})},e.prototype.signUpWithPhoneCode=function(e,t,r){return i(this,void 0,Promise,function(){var i;return o(this,function(o){switch(o.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),i=this.formatPhone(e),[4,this.signUp(n({phone_number:i,verification_code:t},r?{password:r}:{}))];case 1:return o.sent(),[2,this.createLoginState()]}})})},e.prototype.signInWithPhoneCodeOrPassword=function(e){return i(this,void 0,Promise,function(){var t,r,n,i;return o(this,function(o){switch(o.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),i=this.formatPhone(t),n?[4,this.signIn({username:i,password:n})]:[3,2];case 1:return o.sent(),[3,5];case 2:return r?[4,this.signIn({username:i,verification_token:r})]:[3,4];case 3:return o.sent(),[3,5];case 4:(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode or password must be provided"),o.label=5;case 5:return[2,this.createLoginState()]}})})},e.prototype.forceResetPwdByPhoneCode=function(e){return i(this,void 0,Promise,function(){var t,r,n,i;return o(this,function(o){switch(o.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof r&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),"string"!=typeof n&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),i=this.formatPhone(t),[4,this.resetPassword({phone_number:i,new_password:n,verification_token:r})];case 1:return o.sent(),[4,this.signIn({username:i,password:n})];case 2:return o.sent(),[2,this.createLoginState()]}})})},e.prototype.shouldRefreshAccessToken=function(e){throw new Error("[v1 兼容] shouldRefreshAccessToken() 在当前版本中无法实现。 建议使用 auth.onAuthStateChange(callback) 来监听 TOKEN_REFRESHED 事件替代。")},e.prototype.onLoginStateExpired=function(e){var t=this;this.onLoginStateChanged(function(r){(null==r?void 0:r.eventType)===s.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR&&e.call(t)})},e.prototype.onAccessTokenRefreshed=function(e){var t=this;this.onAuthStateChange(function(r){r===s.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED&&e.call(t)})},e.prototype.onAnonymousConverted=function(e){var t=this;this.onAuthStateChange(function(r){r===s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&e.call(t)})},e.prototype.onLoginTypeChanged=function(e){var t=this;this.onAuthStateChange(function(r){r!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&r!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT||e.call(t)})},e}();t.AuthV1Compat=l,t.applyUserV1Compat=function(e){e.prototype.linkWithTicket=function(e){return i(this,void 0,Promise,function(){return o(this,function(e){throw new Error("[v1 兼容] User.linkWithTicket() 在当前版本中无法实现。 建议使用 auth.signInWithCustomTicket(() => Promise.resolve(ticket)) 替代。")})})},e.prototype.linkWithRedirect=function(e){throw new Error("[v1 兼容] User.linkWithRedirect() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")},e.prototype.updateEmail=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"newEmail must be a string"),[4,this.updateUserBasicInfo({email:e})];case 1:return t.sent(),[2]}})})},e.prototype.linkWithPhoneNumber=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(e){throw new Error("[v1 兼容] User.linkWithPhoneNumber() 在当前版本中无法实现。 建议使用 auth.bindPhoneNumber({ phone_number, verification_token, sudo_token }) 替代。")})})},e.prototype.updatePhoneNumber=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(e){throw new Error("[v1 兼容] User.updatePhoneNumber() 在当前版本中无法实现。 建议使用 auth.updateUser({ phone: newPhoneNumber }) 替代。")})})},e.prototype.unlink=function(e){return i(this,void 0,Promise,function(){return o(this,function(e){throw new Error("[v1 兼容] User.unlink() 在当前版本中无法实现。 建议使用 auth.unlinkIdentity({ provider: loginType }) 替代。")})})}}},304:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=void 0;var n=r(895);t.registerAuth=n.registerAuth;try{window.registerAuth=t.registerAuth}catch(e){}},413:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Auth=void 0;var u=r(949),c=r(257),h=r(462),l=r(631),d=a(r(639)),p=r(308);function f(e,t){var n;return i(this,void 0,void 0,function(){var s,a=this;return o(this,function(u){s=function(){return i(a,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return e.trys.push([0,1,,6]),[2,r(814)];case 1:e.sent(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,Promise.resolve().then(r.t.bind(r,814,23))];case 3:return[2,e.sent()];case 4:return e.sent(),[2];case 5:return[3,6];case 6:return[2]}})})};try{if(((null===(n=null==t?void 0:t.root)||void 0===n?void 0:n.globalThis)||globalThis).IS_MP_BUILD)return[2];if(e)return[2,s()]}catch(t){if(e)return[2,s()]}return[2]})})}var v=function(){function e(e){var t=e.request,r=e.credentialsClient;if(!r){var i={apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,storage:e.storage,env:e.env,baseRequest:e.baseRequest,anonymousSignInFunc:e.anonymousSignInFunc,wxCloud:e.wxCloud,onCredentialsError:e.onCredentialsError,headers:e.headers||{},i18n:e.i18n,debug:e.debug};r=new c.OAuth2Client(i)}if(!t){var o=r.request.bind(r),s=new h.Captcha(n({env:e.env,clientId:e.clientId,request:o,storage:e.storage,adapter:e.adapter,oauthInstance:this},e.captchaOptions));t=s.request.bind(s)}this.config={env:e.env,apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,request:t,credentialsClient:r,storage:e.storage||c.defaultStorage,adapter:e.adapter}}return e.parseParamsToSearch=function(e){return Object.keys(e).forEach(function(t){e[t]||delete e[t]}),new d.default(e).toString()},e.prototype.getParamsByVersion=function(e,t){var r,n=(0,l.deepClone)(e),i=(null===(r={v2:u.ApiUrlsV2}[null==n?void 0:n.version])||void 0===r?void 0:r[t])||u.ApiUrls[t];return n&&delete n.version,{params:n,url:i}},e.prototype.signIn=function(e){return i(this,void 0,Promise,function(){var t,r,i,s;return o(this,function(o){switch(o.label){case 0:return t=e.version||"v1",(r=this.getParamsByVersion(e,"AUTH_SIGN_IN_URL")).params.query&&delete r.params.query,[4,this.getEncryptParams(r.params)];case 1:return i=o.sent(),[4,this.config.request(r.url,{method:"POST",body:i})];case 2:return s=o.sent(),[4,this.config.credentialsClient.setCredentials(n(n({},s),{version:t}))];case 3:return o.sent(),[2,Promise.resolve(s)]}})})},e.prototype.signInAnonymously=function(e,t){return void 0===e&&(e={}),void 0===t&&(t=!1),i(this,void 0,Promise,function(){var r;return o(this,function(n){switch(n.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:e,useWxCloud:t})];case 1:return r=n.sent(),[4,this.config.credentialsClient.setCredentials(r)];case 2:return n.sent(),[2,Promise.resolve(r)]}})})},e.prototype.signUp=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_UP_URL,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}})})},e.prototype.signOut=function(e){return i(this,void 0,Promise,function(){var t,r,n,i;return o(this,function(o){switch(o.label){case 0:if(t={},!e)return[3,6];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.config.request(u.ApiUrls.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:e})];case 2:return t=o.sent(),[3,4];case 3:return(r=o.sent()).error!==u.ErrorType.UNAUTHENTICATED&&console.log("sign_out_error",r),[3,4];case 4:return[4,this.config.credentialsClient.setCredentials()];case 5:return o.sent(),[2,t];case 6:return[4,this.config.credentialsClient.getAccessToken()];case 7:return n=o.sent(),[4,this.config.request(u.ApiUrls.AUTH_REVOKE_URL,{method:"POST",body:{token:n}})];case 8:return i=o.sent(),[4,this.config.credentialsClient.setCredentials()];case 9:return o.sent(),[2,Promise.resolve(i)]}})})},e.prototype.revokeAllDevices=function(){return i(this,void 0,Promise,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})];case 1:return e.sent(),[2]}})})},e.prototype.revokeDevice=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.config.request(u.ApiUrls.AUTHORIZED_DEVICES_DELETE_URL+e.device_id,{method:"DELETE",withCredentials:!0})];case 1:return t.sent(),[2]}})})},e.prototype.getVerification=function(e,t){return i(this,void 0,Promise,function(){var r,n;return o(this,function(i){switch(i.label){case 0:return r=!1,"CUR_USER"!==e.target?[3,1]:(r=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:i.sent()&&(r=!0),i.label=3;case 3:return(n=(0,l.deepClone)(e)).phone_number&&!/^\+\d{1,3}\s+\d+/.test(n.phone_number)&&(n.phone_number="+86 ".concat(n.phone_number)),[2,this.config.request(u.ApiUrls.VERIFICATION_URL,{method:"POST",body:n,withCaptcha:(null==t?void 0:t.withCaptcha)||!1,withCredentials:r})]}})})},e.prototype.verify=function(e){return i(this,void 0,Promise,function(){var t,r;return o(this,function(i){switch(i.label){case 0:return t=this.getParamsByVersion(e,"VERIFY_URL"),[4,this.config.request(t.url,{method:"POST",body:t.params})];case 1:return r=i.sent(),"v2"!==(null==e?void 0:e.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(n(n({},r),{version:"v2"}))];case 2:i.sent(),i.label=3;case 3:return[2,r]}})})},e.prototype.genProviderRedirectUri=function(t){return i(this,void 0,Promise,function(){var r,n,i,a,c;return o(this,function(o){return r=t.provider_redirect_uri,n=t.other_params,i=void 0===n?{}:n,a=s(t,["provider_redirect_uri","other_params"]),r&&!a.redirect_uri&&(a.redirect_uri=r),c="".concat(u.ApiUrls.PROVIDER_URI_URL,"?").concat(e.parseParamsToSearch(a)),Object.keys(i).forEach(function(e){var t=i[e];("sign_out_uri"!==e||(null==t?void 0:t.length)>0)&&(c+="&other_params[".concat(e,"]=").concat(encodeURIComponent(t)))}),[2,this.config.request(c,{method:"GET"})]})})},e.prototype.grantProviderToken=function(e,t){return void 0===t&&(t=!1),i(this,void 0,Promise,function(){return o(this,function(r){return[2,this.config.request(u.ApiUrls.PROVIDER_TOKEN_URL,{method:"POST",body:e,useWxCloud:t})]})})},e.prototype.patchProviderToken=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})]})})},e.prototype.signInWithProvider=function(e,t){return void 0===t&&(t=!1),i(this,void 0,Promise,function(){var r,i;return o(this,function(o){switch(o.label){case 0:return r=this.getParamsByVersion(e,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:t})];case 1:return i=o.sent(),[4,this.config.credentialsClient.setCredentials(n(n({},i),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return o.sent(),[2,Promise.resolve(i)]}})})},e.prototype.toBindIdentity=function(e){var t,r;return i(this,void 0,void 0,function(){var n,i,s,a;return o(this,function(o){switch(o.label){case 0:return(i=e.credentials)?[3,2]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 1:i=o.sent(),o.label=2;case 2:n=i,o.label=3;case 3:return o.trys.push([3,5,,6]),[4,this.bindWithProvider({provider_token:e.provider_token},n)];case 4:return o.sent(),s={data:{type:u.OAUTH_TYPE.BIND_IDENTITY,provider:e.provider},error:null},[3,6];case 5:return a=o.sent(),s={data:{type:u.OAUTH_TYPE.BIND_IDENTITY},error:new p.AuthError(a)},[3,6];case 6:return e.fireEvent&&(null===(r=null===(t=this.config.eventBus)||void 0===t?void 0:t.fire)||void 0===r||r.call(t,u.EVENTS.AUTH_STATE_CHANGED,{event:u.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:s})),[2,s]}})})},e.prototype.getInitialSession=function(){return i(this,void 0,Promise,function(){var e,t,r,i,s,a,c,h,l,d,f,v,g,y,m;return o(this,function(o){switch(o.label){case 0:e={},o.label=1;case 1:if(o.trys.push([1,12,,13]),"undefined"==typeof window||"undefined"==typeof document)return[2,{data:null,error:null}];if(t=new URLSearchParams(null===location||void 0===location?void 0:location.search),r=t.get("code"),i=t.get("state"),!r||!i)return[2,{data:null,error:null}];s=null;try{s=JSON.parse(sessionStorage.getItem(i)||"null")}catch(e){}return e={type:null==s?void 0:s.type},a=t.get("error"),c=t.get("error_description"),a||c?[2,{data:e,error:new p.AuthError({message:c||a||"Unknown error from OAuth provider"})}]:(h=(null==s?void 0:s.provider)||t.get("provider"))?(l=location.origin+location.pathname,[4,this.grantProviderToken({provider_id:h,provider_redirect_uri:l,provider_code:r})]):[2,{data:e,error:new p.AuthError({message:"Provider is required for OAuth verification"})}];case 2:return d=o.sent().provider_token,f=void 0,v=null,g=void 0,s.type!==u.OAUTH_TYPE.BIND_IDENTITY?[3,5]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 3:return f=o.sent(),[4,this.toBindIdentity({provider:h,provider_token:d,credentials:f})];case 4:return g=o.sent(),[3,11];case 5:return s.type!==u.OAUTH_TYPE.SIGN_IN?[3,11]:(g=this.getParamsByVersion({provider:h},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(g.url,{method:"POST",body:{provider_token:d}})]);case 6:f=o.sent(),o.label=7;case 7:return o.trys.push([7,9,,10]),[4,this.getUserInfo({credentials:f})];case 8:return v=o.sent(),[3,10];case 9:return y=o.sent(),console.error("get user info error",y),[3,10];case 10:g={data:n(n({},e),{session:f,user:v}),error:null},o.label=11;case 11:t.delete("code"),t.delete("state"),t.delete("provider"),this.restoreUrlState(void 0===(null==s?void 0:s.search)?"?".concat(t.toString()):s.search,(null==s?void 0:s.hash)||location.hash);try{sessionStorage.removeItem(i)}catch(e){}return[2,g];case 12:return m=o.sent(),[2,{data:e,error:new p.AuthError(m)}];case 13:return[2]}})})},e.prototype.signInCustom=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}})})},e.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),i(this,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}})})},e.prototype.bindWithProvider=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(r){return[2,this.config.request(u.ApiUrls.PROVIDER_BIND_URL,{method:"POST",body:e,withCredentials:!0,getCredentials:t?function(){return t}:void 0})]})})},e.prototype.getUserProfile=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.getUserInfo(e)]})})},e.prototype.getUserInfo=function(e){var t,r,n;return void 0===e&&(e={}),i(this,void 0,Promise,function(){var i,s,a,u,c;return o(this,function(o){switch(o.label){case 0:return i=this.getParamsByVersion(e,"USER_ME_URL"),(null===(t=i.params)||void 0===t?void 0:t.query)&&(s=new d.default(i.params.query),i.url+="?".concat(s.toString())),[4,this.config.request(i.url,{method:"GET",withCredentials:!0,getCredentials:e.credentials?function(){return e.credentials}:void 0})];case 1:if((a=o.sent()).sub&&(a.uid=a.sub),null===(r=a.providers)||void 0===r?void 0:r.length)try{"undefined"!=typeof wx&&wx.getAccountInfoSync&&(u=null===(n=wx.getAccountInfoSync().miniProgram)||void 0===n?void 0:n.appId,(null==(c=a.providers.find(function(e){return e.id===u}))?void 0:c.provider_user_id)&&(a.open_id=c.provider_user_id))}catch(e){}return[2,a]}})})},e.prototype.getWedaUserInfo=function(){return i(this,void 0,Promise,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.config.request(u.ApiUrls.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,e.sent()]}})})},e.prototype.deleteMe=function(t){return i(this,void 0,Promise,function(){var r,n;return o(this,function(i){return r=this.getParamsByVersion(t,"USER_ME_URL"),n="".concat(r.url,"?").concat(e.parseParamsToSearch(r.params)),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]})})},e.prototype.hasLoginState=function(){return i(this,void 0,Promise,function(){return o(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}})})},e.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},e.prototype.getLoginState=function(){return i(this,void 0,Promise,function(){return o(this,function(e){return[2,this.config.credentialsClient.getCredentialsAsync()]})})},e.prototype.transByProvider=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})]})})},e.prototype.grantToken=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){return t=this.getParamsByVersion(e,"AUTH_TOKEN_URL"),[2,this.config.request(t.url,{method:"POST",body:t.params})]})})},e.prototype.getProviders=function(){return i(this,void 0,Promise,function(){return o(this,function(e){return[2,this.config.request(u.ApiUrls.PROVIDER_LIST,{method:"GET",withCredentials:!0})]})})},e.prototype.unbindProvider=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})]})})},e.prototype.checkPassword=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.editContact=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})]})})},e.prototype.setPassword=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})]})})},e.prototype.updatePasswordByOld=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return[4,this.sudo({password:e.old_password})];case 1:return t=r.sent(),[2,this.setPassword({sudo_token:t.sudo_token,new_password:e.new_password})]}})})},e.prototype.sudo=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.SUDO_URL),{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.sendVerificationCodeToCurrentUser=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return e.target="CUR_USER",[2,this.config.request(u.ApiUrls.VERIFICATION_URL,{method:"POST",body:e,withCredentials:!0,withCaptcha:!0})]})})},e.prototype.changeBoundProvider=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.PROVIDER_LIST,"/").concat(e.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:e.trans_token},withCredentials:!0})]})})},e.prototype.setUserProfile=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})]})})},e.prototype.updateUserBasicInfo=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.queryUserProfile=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){return t=new d.default(e),[2,this.config.request("".concat(u.ApiUrls.USER_QUERY_URL,"?").concat(t.toString()),{method:"GET",withCredentials:!0})]})})},e.prototype.setCustomSignFunc=function(e){this.getCustomSignTicketFn=e},e.prototype.signInWithCustomTicket=function(){return i(this,void 0,Promise,function(){var e,t;return o(this,function(r){switch(r.label){case 0:return(e=this.getCustomSignTicketFn)?[4,e()]:[2,Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"})];case 1:return t=r.sent(),[2,this.signInCustom({provider_id:"custom",ticket:t})]}})})},e.prototype.resetPassword=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.AUTH_RESET_PASSWORD,{method:"POST",body:e})]})})},e.prototype.authorize=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.authorizeDevice=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.deviceAuthorize=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.AUTH_GET_DEVICE_CODE,{method:"POST",body:e})]})})},e.prototype.authorizeInfo=function(t){return i(this,void 0,Promise,function(){var r,n,i;return o(this,function(o){switch(o.label){case 0:return r="".concat(u.ApiUrls.AUTHORIZE_INFO_URL,"?").concat(e.parseParamsToSearch(t)),n=!0,i=!1,[4,this.hasLoginState()];case 1:return o.sent()&&(i=!0,n=!1),[2,this.config.request(r,{method:"GET",withBasicAuth:n,withCredentials:i})]}})})},e.prototype.checkUsername=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})]})})},e.prototype.checkIfUserExist=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){return t=new d.default(e),[2,this.config.request("".concat(u.ApiUrls.CHECK_IF_USER_EXIST,"?").concat(t.toString()),{method:"GET"})]})})},e.prototype.loginScope=function(){return i(this,void 0,Promise,function(){return o(this,function(e){return[2,this.config.credentialsClient.getScope()]})})},e.prototype.loginGroups=function(){return i(this,void 0,Promise,function(){return o(this,function(e){return[2,this.config.credentialsClient.getGroups()]})})},e.prototype.refreshTokenForce=function(e){return i(this,void 0,void 0,function(){var t;return o(this,function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return t=r.sent(),[4,this.config.credentialsClient.refreshToken(n(n({},t),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return[2,r.sent()]}})})},e.prototype.getCredentials=function(){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.config.credentialsClient.getCredentials()]})})},e.prototype.getPublicKey=function(){return i(this,void 0,Promise,function(){return o(this,function(e){return[2,this.config.request(u.ApiUrlsV2.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]})})},e.prototype.getEncryptParams=function(e){return i(this,void 0,Promise,function(){var t,r,n,i,s,a;return o(this,function(o){switch(o.label){case 0:return t=e.isEncrypt,delete e.isEncrypt,r=(0,l.deepClone)(e),[4,f(t,this.config.adapter)];case 1:if(!(n=o.sent()))return[2,e];i="",s="",o.label=2;case 2:return o.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(a=o.sent(),i=a.public_key,s=a.public_key_thumbprint,!i||!s)throw a;return[3,5];case 4:throw o.sent();case 5:return[2,{params:n.getEncryptInfo({publicKey:i,payload:r}),public_key_thumbprint:s}]}})})},e.prototype.getProviderSubType=function(){return i(this,void 0,Promise,function(){return o(this,function(e){return[2,this.config.request(u.ApiUrls.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})]})})},e.prototype.verifyCaptchaData=function(e){var t=e.token,r=e.key;return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.config.request(u.ApiUrls.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:r},withCredentials:!1})]})})},e.prototype.createCaptchaData=function(e){var t=e.state,r=e.redirect_uri,n=void 0===r?void 0:r;return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.config.request(u.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:n},withCredentials:!1})]})})},e.prototype.getMiniProgramCode=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.GET_MINIPROGRAM_QRCODE,{method:"POST",body:e})]})})},e.prototype.getMiniProgramQrCodeStatus=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:e})]})})},e.prototype.getUserBehaviorLog=function(e){return i(this,void 0,Promise,function(){var t,r;return o(this,function(n){return t={LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"},r="".concat(u.ApiUrls.GET_USER_BEHAVIOR_LOG,"?").concat(t[e.type],"&limit=").concat(e.limit).concat(e.page_token?"&page_token=".concat(e.page_token):""),[2,this.config.request(r,{method:"GET",withCredentials:!0})]})})},e.prototype.modifyPassword=function(e){return i(this,void 0,Promise,function(){var t,r,n,i,s,a;return o(this,function(o){switch(o.label){case 0:return t="",r="",[4,f(!0,this.config.adapter)];case 1:if(!(n=o.sent()))throw new Error("do not support encrypt, a encrypt util required.");o.label=2;case 2:return o.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(i=o.sent(),t=i.public_key,r=i.public_key_thumbprint,!t||!r)throw i;return[3,5];case 4:throw o.sent();case 5:return s=e.password?n.getEncryptInfo({publicKey:t,payload:e.password}):"",a=n.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(u.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:e.user_id,encrypt_password:s,encrypt_new_password:a,public_key_thumbprint:r}})]}})})},e.prototype.modifyPasswordWithoutLogin=function(e){return i(this,void 0,Promise,function(){var t,r,n,i,s,a;return o(this,function(o){switch(o.label){case 0:return t="",r="",[4,f(!0,this.config.adapter)];case 1:if(!(n=o.sent()))throw new Error("do not support encrypt, a encrypt util required.");o.label=2;case 2:return o.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(i=o.sent(),t=i.public_key,r=i.public_key_thumbprint,!t||!r)throw i;return[3,5];case 4:throw o.sent();case 5:return s=e.password?n.getEncryptInfo({publicKey:t,payload:e.password}):"",a=n.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(u.ApiUrlsV2.AUTH_RESET_PASSWORD,{method:"POST",body:{username:e.username,password:s,new_password:a,public_key_thumbprint:r}})]}})})},e.prototype.restoreUrlState=function(e,t){if(void 0!==e)try{var r=new URL(window.location.href);r.search=e,r.hash=t||"",window.history.replaceState(null,"",r.toString()),window.location.replace(r.toString())}catch(e){}},e}();t.Auth=v},308:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.isAuthError=t.AuthError=t.AuthErrorCategory=void 0;var o,s=r(949);!function(e){e.PROVIDER_NOT_ENABLED="PROVIDER_NOT_ENABLED",e.INVALID_CREDENTIALS="INVALID_CREDENTIALS",e.USER_NOT_FOUND="USER_NOT_FOUND",e.USER_STATUS_ABNORMAL="USER_STATUS_ABNORMAL",e.SERVICE_ERROR="SERVICE_ERROR",e.INVALID_PARAMS="INVALID_PARAMS",e.AUTH_METHOD_MISMATCH="AUTH_METHOD_MISMATCH",e.RATE_LIMITED="RATE_LIMITED",e.CAPTCHA_REQUIRED="CAPTCHA_REQUIRED",e.CAPTCHA_INVALID="CAPTCHA_INVALID",e.MFA_REQUIRED="MFA_REQUIRED",e.PRECONDITION_FAILED="PRECONDITION_FAILED",e.VERIFICATION_FAILED="VERIFICATION_FAILED",e.UNKNOWN="UNKNOWN"}(o=t.AuthErrorCategory||(t.AuthErrorCategory={}));var a="https://tcb.cloud.tencent.com/dev?envId=#/identity/login-manage",u="https://docs.cloudbase.net/api-reference/webv3/initialization",c=function(e){function t(t,r){var n,i=this,c=t.error_description||t.message;return(i=e.call(this,c)||this).__isAuthError=!0,i.name="AuthError",i.status=t.error,i.code=String(t.error||t.error_code||"unknown").toLowerCase(),i.errorCode="number"==typeof t.error_code?t.error_code:"string"==typeof t.error_code&&parseInt(t.error_code,10)||void 0,i.requestId=t.requestId,i.category=function(e,t,r){if(!e&&!t&&!r)return o.UNKNOWN;try{var n=(e||"").toLowerCase(),i="string"==typeof r?parseInt(r,10):r;return i===s.AuthErrorCode.CAPTCHA_REQUIRED||t===s.ErrorType.CAPTCHA_REQUIRED?o.CAPTCHA_REQUIRED:i===s.AuthErrorCode.CAPTCHA_INVALID||t===s.ErrorType.CAPTCHA_INVALID?o.CAPTCHA_INVALID:i===s.AuthErrorCode.MFA_PHONE_REQUIRED||t===s.ErrorType.MFA_PHONE_REQUIRED?o.MFA_REQUIRED:i===s.AuthErrorCode.LOGIN_TYPE_DISABLED||t===s.ErrorType.LOGIN_TYPE_DISABLED?o.PROVIDER_NOT_ENABLED:i===s.AuthErrorCode.RESOURCE_EXHAUSTED||t===s.ErrorType.RESOURCE_EXHAUSTED?o.RATE_LIMITED:i===s.AuthErrorCode.INTERNAL||i===s.AuthErrorCode.UNAVAILABLE||i===s.AuthErrorCode.UNIMPLEMENTED||i===s.AuthErrorCode.ABORTED?o.SERVICE_ERROR:i===s.AuthErrorCode.NOT_FOUND?o.USER_NOT_FOUND:i===s.AuthErrorCode.UNAUTHENTICATED?o.INVALID_CREDENTIALS:i===s.AuthErrorCode.INVALID_ARGUMENT&&(n.includes("验证码")||n.includes("verification")||n.includes("verification_code")||n.includes("verification_id")||n.includes("does not match")||n.includes("token expired")||n.includes("token error")||n.includes("过期"))?o.VERIFICATION_FAILED:t===s.ErrorType.PROVIDER_NOT_ENABLED||t===s.ErrorType.LOGIN_METHOD_DISABLED||n.includes("身份源")||n.includes("开启")||n.includes("identity provider")||n.includes("provider not enabled")||n.includes("login method")||n.includes("登录方式")||n.includes("not enabled")||n.includes("未开启")||n.includes("未启用")||n.includes("请联系开发者")||n.includes("anonymous login is not enabled")||n.includes("匿名登录未开启")?o.PROVIDER_NOT_ENABLED:t===s.ErrorType.FAILED_PRECONDITION||i===s.AuthErrorCode.FAILED_PRECONDITION&&!n.includes("请联系开发者")?n.includes("不存在")||n.includes("not found")||n.includes("未注册")?o.USER_NOT_FOUND:o.PRECONDITION_FAILED:t===s.ErrorType.INVALID_PASSWORD||t===s.ErrorType.INVALID_GRANT||t===s.ErrorType.INVALID_VERIFICATION_CODE||t===s.ErrorType.INVALID_USERNAME_OR_PASSWORD||t===s.ErrorType.INVALID_CREDENTIALS||t===s.ErrorType.WRONG_PASSWORD||t===s.ErrorType.UNAUTHENTICATED||t===s.ErrorType.INVALID_TWO_FACTOR||t===s.ErrorType.INVALID_TWO_FACTOR_RECOVERY||t===s.ErrorType.PASSWORD_NOT_SET||n.includes("密码不正确")||n.includes("password")||n.includes("invalid_password")||n.includes("凭据")||n.includes("credentials")||n.includes("验证码")||n.includes("verification")||n.includes("invalid_verification_code")||n.includes("invalid_username_or_password")||n.includes("username or password")||n.includes("用户名或密码")||n.includes("wrong password")||n.includes("incorrect password")?o.INVALID_CREDENTIALS:t===s.ErrorType.NOT_FOUND||t===s.ErrorType.USER_NOT_FOUND||n.includes("用户不存在")||n.includes("not found")||n.includes("user not found")||n.includes("no such user")||n.includes("user does not exist")?o.USER_NOT_FOUND:t===s.ErrorType.USER_BLOCKED||t===s.ErrorType.USER_PENDING||t===s.ErrorType.UNDER_REVIEW||t===s.ErrorType.INVALID_STATUS||n.includes("被封禁")||n.includes("blocked")||n.includes("pending")||n.includes("审核")||n.includes("review")||n.includes("locked")||n.includes("已锁定")?o.USER_STATUS_ABNORMAL:t===s.ErrorType.SERVER_ERROR||t===s.ErrorType.UNAVAILABLE||t===s.ErrorType.TEMPORARILY_UNAVAILABLE||t===s.ErrorType.INTERNAL||t===s.ErrorType.UNREACHABLE||t===s.ErrorType.DEADLINE_EXCEEDED||t===s.ErrorType.DATA_LOSS||t===s.ErrorType.ABORTED||n.includes("network")||n.includes("timeout")||n.includes("timed out")||n.includes("超时")||n.includes("smtp is not set")||n.includes("sms sender does not config")?o.SERVICE_ERROR:t===s.ErrorType.INVALID_ARGUMENT||t===s.ErrorType.INVALID_REQUEST||t===s.ErrorType.INVALID_SCOPE||t===s.ErrorType.INVALID_REQUEST_URI||t===s.ErrorType.INVALID_REQUEST_OBJECT||i===s.AuthErrorCode.INVALID_ARGUMENT?o.INVALID_PARAMS:t===s.ErrorType.PERMISSION_DENIED||t===s.ErrorType.ACCESS_DENIED||t===s.ErrorType.UNAUTHORIZED_CLIENT?o.PROVIDER_NOT_ENABLED:o.UNKNOWN}catch(e){return t}}(c,i.status,i.errorCode),i.helpMessage=function(e,t){var r=(null==t?void 0:t.method)||"signIn",n={signInWithPassword:"「用户名密码登录」",signInAnonymously:"「匿名登录」",signInWithOtp:"「短信验证码登录」或「邮箱验证码登录」",signUp:"「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"对应的第三方身份源",signInWithIdToken:"对应的第三方身份源",signInWithOpenId:"「微信小程序 OpenID 登录」",signInWithPhoneAuth:"「微信小程序手机号授权登录」",signInWithCustomTicket:"「自定义登录」",getVerification:"「短信验证码登录」或「邮箱验证码登录」",verify:"「短信验证码登录」或「邮箱验证码登录」",verifyOtp:"「短信验证码登录」或「邮箱验证码登录」",resetPasswordForEmail:"「邮箱验证码登录」",reauthenticate:"「短信验证码登录」或「邮箱验证码登录」"}[r]||"对应的登录方式";switch(e){case o.PROVIDER_NOT_ENABLED:return"[CloudBase Auth] 登录方式未开启\n\n"+" 当前调用的 ".concat(r,"() 所需的登录方式尚未在云开发控制台启用。\n")+" 需要开启的登录方式:".concat(n,"\n")+"\n 请按以下步骤开启:\n"+" 1. 打开云开发控制台:".concat(a,"\n")+" 2. 选择对应的云开发环境\n 3. 进入「登录授权」页面,在「登录方式」或「身份源列表」中开启所需的登录方式\n\n 各登录方法与所需登录方式的对应关系:\n - signInWithPassword → 「用户名密码登录」\n - signInAnonymously → 「匿名登录」\n - signInWithOtp/signUp → 「短信验证码登录」或「邮箱验证码登录」\n - signInWithOAuth/signInWithIdToken → 对应的第三方身份源\n\n 如使用 CLI/MCP 工具,可通过 auth 工具查询和配置身份源状态。\n"+" 更多帮助请参考文档:".concat(u);case o.INVALID_CREDENTIALS:return"[CloudBase Auth] 凭据验证失败\n\n"+" 调用 ".concat(r,"() 时凭据校验未通过。\n")+"\n 请按优先级逐项排查:\n 1. 确认用户名/邮箱/手机号是否拼写正确、格式完整\n 2. 确认密码是否正确(注意大小写、特殊字符、前后空格)\n 3. 确认用户账号确实存在(可通过 auth.isUsernameRegistered() 检查)\n 4. 确认凭据参数来源可靠(环境变量、配置文件中的值是否已正确设置)\n 5. 如使用加密登录(is_encrypt: true),请确认公钥版本正确\n\n 如忘记密码,可通过 auth.resetPasswordForEmail() 重置密码。\n\n 提示:如果是 AI agent / 自动化测试场景,请确认 ENV_ID、USERNAME、PASSWORD\n 等环境变量已正确传入,且对应用户已在目标环境中注册。";case o.USER_NOT_FOUND:return"[CloudBase Auth] 用户不存在\n\n 请检查以下项目:\n 1. 确认用户名/邮箱/手机号是否正确\n 2. 确认是在正确的云开发环境(envId)下操作\n 3. 如果是新用户,请先通过 auth.signUp() 注册\n"+" 4. 也可在云开发控制台手动创建用户:".concat(a,"\n")+"\n 提示:不同环境(开发/测试/生产)的用户库是隔离的,请确认 envId 正确。";case o.USER_STATUS_ABNORMAL:return"[CloudBase Auth] 用户状态异常\n\n 当前用户账号可能处于以下状态之一:\n - 账号已被封禁\n - 账号正在审核中\n - 账号已被锁定(多次密码错误)\n\n"+" 请联系管理员在云开发控制台检查用户状态:".concat(a);case o.SERVICE_ERROR:return"[CloudBase Auth] 服务异常\n\n 请检查以下项目:\n 1. 网络连接是否正常\n 2. 云开发环境是否正常运行\n 3. 稍后重试,如持续失败请联系技术支持\n\n 提示:如果是超时错误,请检查网络环境和请求频率。\n 常见服务端错误:smtp 未配置、短信服务未配置、wedaapis 未设置等。";case o.INVALID_PARAMS:return"[CloudBase Auth] 参数错误\n\n 请检查传入的参数是否符合要求:\n - 不能同时输入手机号和邮箱\n - 手机号格式需正确(如 +86 开头)\n - 必须提供手机号或邮箱\n\n"+" 参考 API 文档确认各参数的格式和约束:".concat(u);case o.AUTH_METHOD_MISMATCH:return"[CloudBase Auth] 登录方式不匹配\n\n"+" 调用 ".concat(r,"() 时遇到错误,可能原因:\n")+" - 匿名登录失败后尝试了用户名密码登录,但凭据不正确或用户不存在\n - 应使用匿名登录但传入了密码参数\n - 应使用密码登录但未传入正确的凭据\n\n 建议:\n 1. 明确当前场景需要的登录方式:\n - 无需用户注册 → auth.signInAnonymously()\n - 有用户名和密码 → auth.signInWithPassword({ username, password })\n - 第三方平台 → auth.signInWithOAuth({ provider })\n 2. 不要在同一流程中混合使用不同的登录方式\n 3. 每种登录方式需要在控制台开启对应的身份源\n"+" 4. 控制台地址:".concat(a);case o.RATE_LIMITED:return"[CloudBase Auth] 发送频率受限\n\n 验证码发送过于频繁,已触发频率限制。\n\n 限制规则:\n - 手机号:每分钟最多 1 条,每天有上限\n - 邮箱:每分钟有上限,每天有上限(默认 50 条)\n\n 建议:\n 1. 检查 error.retryAfter 获取建议等待时间\n 2. 在 UI 中显示倒计时,防止用户重复点击\n 3. 如业务需要更高频率,请联系技术支持调整限额";case o.CAPTCHA_REQUIRED:return"[CloudBase Auth] 需要滑块验证码\n\n 当前操作触发了风控策略,需要完成滑块验证。\n\n 处理方式:\n 1. 调用滑块验证码 SDK 展示验证组件\n 2. 用户完成验证后,将 captcha_token 附带到请求中重新发送\n 3. 可通过 getVerification 的 options.withCaptcha 参数自动携带验证码";case o.CAPTCHA_INVALID:return"[CloudBase Auth] 滑块验证码校验失败\n\n 提交的验证码 token 校验未通过(可能已过期或 client_id 不匹配)。\n\n 处理方式:\n 1. 刷新滑块验证码,让用户重新验证\n 2. 确认 captcha 组件初始化的 client_id 与认证配置一致";case o.MFA_REQUIRED:return"[CloudBase Auth] 需要 MFA 验证\n\n 当前操作要求用户绑定手机号进行多因素认证 (MFA)。\n\n 处理方式:\n 1. 引导用户进入手机号绑定流程\n 2. 绑定完成后重新执行原操作\n 3. error 中可能包含 MFA 详情信息";case o.PRECONDITION_FAILED:return"[CloudBase Auth] 前置条件不满足\n\n 当前操作的前置条件不满足,常见原因:\n - 该手机号/邮箱已被其他账号绑定\n - 目标用户不存在或已存在(与 target 参数冲突)\n - 当前邮箱/手机号未注册用户\n\n 请根据 error.message 中的具体描述处理。";case o.VERIFICATION_FAILED:return'[CloudBase Auth] 验证码校验失败\n\n 验证码验证未通过,常见原因:\n - 验证码已过期(通常有效期为几分钟)\n - 验证码输入不正确\n - verification_id 无效或已被使用\n - 验证码不属于当前项目(project id does not match)\n\n 处理方式:\n 1. 提示用户"验证码已过期或不正确,请重新获取"\n 2. 调用 getVerification() 重新发送验证码\n 3. 确保 verification_id 与最新发送的验证码对应\n\n 注意:每次重新发送验证码后,之前的 verification_id 即失效。';default:return"[CloudBase Auth] 操作失败\n\n 如果问题持续存在,建议:\n"+" 1. 检查云开发控制台的认证配置:".concat(a,"\n")+" 2. 到官方问答社区提问:https://cnb.cool/tencent/cloud/cloudbase/community/-/issues\n"+" 3. 查阅文档:".concat(u)}}(i.category,r),i.loginMethodHint=(n=null==r?void 0:r.method)&&{signInWithPassword:"当前使用「用户名密码登录」,需确保:\n ✓ 控制台已开启「用户名密码登录」\n ✓ 用户已注册且凭据正确\n 如果不需要用户系统,建议改用 auth.signInAnonymously()",signInAnonymously:"当前使用「匿名登录」,需确保:\n ✓ 控制台已开启「匿名登录」\n 注意:匿名用户无需用户名密码,适用于快速体验或临时访问场景",signInWithOtp:"当前使用「OTP 验证码登录」,需确保:\n ✓ 控制台已开启「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"当前使用「第三方 OAuth 登录」,需确保:\n ✓ 控制台已配置并开启对应的第三方身份源"}[n]||"",i.category===o.RATE_LIMITED&&(i.retryAfter=t.retry_after||t.retryAfter||void 0),i}return i(t,e),t.prototype.toJSON=function(){return{name:this.name,message:this.message,code:this.code,errorCode:this.errorCode,status:this.status,requestId:this.requestId,category:this.category,retryAfter:this.retryAfter}},t}(Error);t.AuthError=c,t.isAuthError=function(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}},949:function(e,t){var r,n,i,o,s,a;Object.defineProperty(t,"__esModule",{value:!0}),t.VerificationUsage=t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.EVENTS=t.AUTH_STATE_CHANGED_TYPE=t.LOGIN_STATE_CHANGED_TYPE=t.AuthErrorCode=t.ErrorType=t.VerificationUsages=t.ApiUrlsV2=t.ApiUrls=t.AUTH_API_PREFIX=void 0,t.AUTH_API_PREFIX="/auth",(a=t.ApiUrls||(t.ApiUrls={})).AUTH_SIGN_UP_URL="/v1/signup",a.AUTH_TOKEN_URL="/v1/token",a.AUTH_REVOKE_URL="/v1/revoke",a.WEDA_USER_URL="/v1/plugin/weda/userinfo",a.AUTH_RESET_PASSWORD="/v1/reset",a.AUTH_GET_DEVICE_CODE="/v1/device/code",a.CHECK_USERNAME="/v1/checkUsername",a.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",a.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",a.AUTH_SIGN_IN_URL="/v1/signin",a.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",a.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",a.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",a.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",a.PROVIDER_TOKEN_URL="/v1/provider/token",a.PROVIDER_URI_URL="/v1/provider/uri",a.USER_ME_URL="/v1/user/me",a.AUTH_SIGNOUT_URL="/v1/user/signout",a.USER_QUERY_URL="/v1/user/query",a.USER_PRIFILE_URL="/v1/user/profile",a.USER_BASIC_EDIT_URL="/v1/user/basic/edit",a.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",a.PROVIDER_LIST="/v1/user/provider",a.PROVIDER_BIND_URL="/v1/user/provider/bind",a.PROVIDER_UNBIND_URL="/v1/user/provider",a.CHECK_PWD_URL="/v1/user/sudo",a.SUDO_URL="/v1/user/sudo",a.BIND_CONTACT_URL="/v1/user/contact",a.AUTH_SET_PASSWORD="/v1/user/password",a.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",a.AUTHORIZE_URL="/v1/user/authorize",a.AUTHORIZE_INFO_URL="/v1/user/authorize/info",a.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",a.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",a.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",a.VERIFICATION_URL="/v1/verification",a.VERIFY_URL="/v1/verification/verify",a.CAPTCHA_DATA_URL="/v1/captcha/data",a.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",a.GET_CAPTCHA_URL="/v1/captcha/init",a.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",a.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status",(s=t.ApiUrlsV2||(t.ApiUrlsV2={})).AUTH_SIGN_IN_URL="/v2/signin/username",s.AUTH_TOKEN_URL="/v2/token",s.USER_ME_URL="/v2/user/me",s.VERIFY_URL="/v2/signin/verificationcode",s.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",s.AUTH_PUBLIC_KEY="/v2/signin/publichkey",s.AUTH_RESET_PASSWORD="/v2/signin/password/update",(o=t.VerificationUsages||(t.VerificationUsages={})).REGISTER="REGISTER",o.SIGN_IN="SIGN_IN",o.PASSWORD_RESET="PASSWORD_RESET",o.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",o.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE",(i=t.ErrorType||(t.ErrorType={})).UNREACHABLE="unreachable",i.LOCAL="local",i.CANCELLED="cancelled",i.UNKNOWN="unknown",i.UNAUTHENTICATED="unauthenticated",i.RESOURCE_EXHAUSTED="resource_exhausted",i.FAILED_PRECONDITION="failed_precondition",i.INVALID_ARGUMENT="invalid_argument",i.DEADLINE_EXCEEDED="deadline_exceeded",i.NOT_FOUND="not_found",i.ALREADY_EXISTS="already_exists",i.PERMISSION_DENIED="permission_denied",i.ABORTED="aborted",i.OUT_OF_RANGE="out_of_range",i.UNIMPLEMENTED="unimplemented",i.INTERNAL="internal",i.UNAVAILABLE="unavailable",i.DATA_LOSS="data_loss",i.INVALID_PASSWORD="invalid_password",i.PASSWORD_NOT_SET="password_not_set",i.INVALID_STATUS="invalid_status",i.USER_PENDING="user_pending",i.USER_BLOCKED="user_blocked",i.INVALID_VERIFICATION_CODE="invalid_verification_code",i.TWO_FACTOR_REQUIRED="two_factor_required",i.INVALID_TWO_FACTOR="invalid_two_factor",i.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",i.UNDER_REVIEW="under_review",i.INVALID_REQUEST="invalid_request",i.UNAUTHORIZED_CLIENT="unauthorized_client",i.ACCESS_DENIED="access_denied",i.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",i.INVALID_SCOPE="invalid_scope",i.INVALID_GRANT="invalid_grant",i.SERVER_ERROR="server_error",i.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",i.INTERACTION_REQUIRED="interaction_required",i.LOGIN_REQUIRED="login_required",i.ACCOUNT_SELECTION_REQUIRED="account_selection_required",i.CONSENT_REQUIRED="consent_required",i.INVALID_REQUEST_URI="invalid_request_uri",i.INVALID_REQUEST_OBJECT="invalid_request_object",i.REQUEST_NOT_SUPPORTED="request_not_supported",i.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",i.REGISTRATION_NOT_SUPPORTED="registration_not_supported",i.CAPTCHA_REQUIRED="captcha_required",i.CAPTCHA_INVALID="captcha_invalid",i.PROVIDER_NOT_ENABLED="provider_not_enabled",i.LOGIN_METHOD_DISABLED="login_method_disabled",i.INVALID_USERNAME_OR_PASSWORD="invalid_username_or_password",i.INVALID_CREDENTIALS="invalid_credentials",i.WRONG_PASSWORD="wrong_password",i.USER_NOT_FOUND="user_not_found",i.MFA_PHONE_REQUIRED="mfa_phone_required",i.LOGIN_TYPE_DISABLED="login_type_disabled",i.PROVIDER_ERROR="provider_error",(n=t.AuthErrorCode||(t.AuthErrorCode={}))[n.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",n[n.NOT_FOUND=5]="NOT_FOUND",n[n.PERMISSION_DENIED=7]="PERMISSION_DENIED",n[n.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",n[n.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",n[n.ABORTED=10]="ABORTED",n[n.UNIMPLEMENTED=12]="UNIMPLEMENTED",n[n.INTERNAL=13]="INTERNAL",n[n.UNAVAILABLE=14]="UNAVAILABLE",n[n.UNAUTHENTICATED=16]="UNAUTHENTICATED",n[n.CAPTCHA_REQUIRED=4001]="CAPTCHA_REQUIRED",n[n.CAPTCHA_INVALID=4002]="CAPTCHA_INVALID",n[n.PROVIDER_ERROR=4019]="PROVIDER_ERROR",n[n.UNAUTHORIZED_CLIENT=4022]="UNAUTHORIZED_CLIENT",n[n.MFA_PHONE_REQUIRED=4042]="MFA_PHONE_REQUIRED",n[n.LOGIN_TYPE_DISABLED=4045]="LOGIN_TYPE_DISABLED",t.LOGIN_STATE_CHANGED_TYPE={SIGN_OUT:"sign_out",SIGN_IN:"sign_in",CREDENTIALS_ERROR:"credentials_error"},t.AUTH_STATE_CHANGED_TYPE={SIGNED_OUT:"SIGNED_OUT",SIGNED_IN:"SIGNED_IN",INITIAL_SESSION:"INITIAL_SESSION",PASSWORD_RECOVERY:"PASSWORD_RECOVERY",TOKEN_REFRESHED:"TOKEN_REFRESHED",USER_UPDATED:"USER_UPDATED",BIND_IDENTITY:"BIND_IDENTITY"},t.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",AUTH_STATE_CHANGED:"authStateChanged"},t.OAUTH_TYPE={SIGN_IN:"sign_in",BIND_IDENTITY:"bind_identity"},t.DEFAULT_NODE_ACCESS_SCOPE="node-sdk-scope",(r=t.VerificationUsage||(t.VerificationUsage={})).EMAIL="email",r.RECOVERY="recovery",r.REAUTHENTICATION="reauthentication"},538:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},84:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.openURIWithCallback=void 0;var s=r(689),a=r(616),u=function(e,t){var r;return function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];clearTimeout(r),r=setTimeout(function(){return e.apply(null,n)},t)}},c=new s.CloudbaseEventEmitter,h="resolveCaptchaData",l="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",d="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",p="background:#6c757d;cursor:not-allowed";t.openURIWithCallback=function(e,t){return i(void 0,void 0,Promise,function(){var r,s,f,v;return o(this,function(g){return r=(0,a.parseCaptcha)(e),s=r.captchaData,f=r.state,v=r.token,function(e){var t=e.oauthInstance,r=e.captchaState,s="captcha-image",a=function(){return i(void 0,void 0,void 0,function(){var e,i;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,t.createCaptchaData({state:r.state})];case 1:return e=o.sent(),r=n(n({},r),{captchaData:e.data,token:e.token}),document.getElementById(s).src=e.data,[3,3];case 2:return i=o.sent(),console.error("刷新图形验证码失败",i),[3,3];case 3:return[2]}})})},f=function(e,t,r){var n=document.createElement(e);return t&&(n.style.cssText=t),r&&(n.textContent=r),n},v=f("div","position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999"),g=f("div","position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:320px;padding:20px;background:#fff;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.2);z-index:1000");g.appendChild(f("p","margin-bottom:15px","请输入你看到的字符:"));var y=f("div","display:flex;align-items:center;justify-content:space-between;margin-bottom:15px"),m=f("img","width:100%;height:auto;border:1px solid #eee");m.id=s,m.src=r.captchaData,y.appendChild(m);var _=f("button",l,"刷新");_.onclick=u(function(){return i(void 0,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:_.textContent="加载中...",_.disabled=!0,_.style.cssText="".concat(l,";").concat(p),e.label=1;case 1:return e.trys.push([1,,3,4]),[4,a()];case 2:return e.sent(),[3,4];case 3:return _.textContent="刷新",_.disabled=!1,_.style.cssText=l,[7];case 4:return[2]}})})},500),y.appendChild(_),g.appendChild(y);var E=f("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");E.type="text",E.placeholder="输入字符",E.maxLength=4,g.appendChild(E);var b=f("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");g.appendChild(b);var I=function(e){b.textContent=e,b.style.display="block"},A=f("button",d,"确定");A.onclick=u(function(){return i(void 0,void 0,void 0,function(){var e,n,i,s;return o(this,function(o){switch(o.label){case 0:if(!(e=E.value.trim()))return I("请输入字符"),[2];b.style.display="none",A.textContent="验证中...",A.disabled=!0,A.style.cssText="".concat(d,";").concat(p),o.label=1;case 1:return o.trys.push([1,3,5,6]),[4,t.verifyCaptchaData({token:r.token,key:e})];case 2:return n=o.sent(),c.fire(h,n),console.log("图形验证码校验成功"),document.body.removeChild(v),document.body.removeChild(g),[3,6];case 3:return i=o.sent(),console.error("图形验证码校验失败",i),s=i.error_description||"图形验证码校验失败",I(s),E.value="",E.focus(),[4,a()];case 4:return o.sent(),[3,6];case 5:return A.textContent="确定",A.disabled=!1,A.style.cssText=d,[7];case 6:return[2]}})})},500),g.appendChild(A),document.body.appendChild(v),document.body.appendChild(g)}({oauthInstance:t,captchaState:{captchaData:s,state:f,token:v}}),[2,new Promise(function(e){console.log("等待图形验证码校验结果..."),c.on(h,function(t){e(null==t?void 0:t.data)})})]})})}},462:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.Captcha=void 0;var o=r(949),s=r(257),a=r(425),u=r(84),c=function(){function e(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=s.defaultStorage),this.config=e,this.tokenSectionName="captcha_".concat(e.clientId||e.env)}return e.prototype.isMatch=function(){var e,t,r;return(null===(r=null===(t=null===(e=this.config)||void 0===e?void 0:e.adapter)||void 0===t?void 0:t.isMatch)||void 0===r?void 0:r.call(t))||(0,a.isMp)()},e.prototype.request=function(e,t){return n(this,void 0,Promise,function(){var r,n,s,a;return i(this,function(i){switch(i.label){case 0:return t||(t={}),t.method||(t.method="GET"),r="".concat(t.method,":").concat(e),n=e,t.withCaptcha?[4,this.appendCaptchaTokenToURL(e,r,!1)]:[3,2];case 1:n=i.sent(),i.label=2;case 2:return i.trys.push([2,4,,7]),[4,this.config.request(n,t)];case 3:return s=i.sent(),[3,7];case 4:return(a=i.sent()).error!==o.ErrorType.CAPTCHA_REQUIRED&&a.error!==o.ErrorType.CAPTCHA_INVALID?[3,6]:[4,this.appendCaptchaTokenToURL(e,r,a.error===o.ErrorType.CAPTCHA_INVALID)];case 5:return e=i.sent(),[2,this.config.request(e,t)];case 6:return[2,Promise.reject(a)];case 7:return[2,s]}})})},e.prototype.getDefaultOpenURIWithCallback=function(){var e=this;return function(t){return(0,u.openURIWithCallback)(t,e.config.oauthInstance)}},e.prototype.getCaptchaToken=function(e,t){return n(this,void 0,Promise,function(){var r,n,s,a;return i(this,function(i){switch(i.label){case 0:return e?[3,2]:[4,this.findCaptchaToken()];case 1:if(r=i.sent())return[2,r];i.label=2;case 2:return[4,this.config.request(o.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:""},withCredentials:!1})];case 3:return n=i.sent(),s="".concat(n.data,"?state=").concat(encodeURIComponent(t),"&token=").concat(encodeURIComponent(n.token)),[4,this.config.openURIWithCallback(s)];case 4:return a=i.sent(),this.saveCaptchaToken(a),[2,a.captcha_token]}})})},e.prototype.appendCaptchaTokenToURL=function(e,t,r){return n(this,void 0,Promise,function(){var n;return i(this,function(i){switch(i.label){case 0:return[4,this.getCaptchaToken(r,t)];case 1:return n=i.sent(),e.indexOf("?")>0?e+="&captcha_token=".concat(n):e+="?captcha_token=".concat(n),[2,e]}})})},e.prototype.saveCaptchaToken=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return e.expires_at=new Date(Date.now()+1e3*(e.expires_in-10)),t=JSON.stringify(e),[4,this.config.storage.setItem(this.tokenSectionName,t)];case 1:return r.sent(),[2]}})})},e.prototype.findCaptchaToken=function(){return n(this,void 0,Promise,function(){var e,t;return i(this,function(r){switch(r.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=r.sent()))return[3,5];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),t.expires_at<new Date?[2,null]:[2,t.captcha_token];case 3:return r.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),[2,null];case 5:return[2,null]}})})},e}();t.Captcha=c},722:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseOAuth=t.VerificationUsage=t.AuthErrorCode=t.AUTH_STATE_CHANGED_TYPE=t.EVENTS=t.LOGIN_STATE_CHANGED_TYPE=t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.AUTH_API_PREFIX=t.weAppJwtDecodeAll=t.authModels=t.isAuthError=t.AuthErrorCategory=t.AuthError=t.Auth=void 0;var a=r(257),u=r(413),c=r(949),h=r(413);Object.defineProperty(t,"Auth",{enumerable:!0,get:function(){return h.Auth}});var l=r(308);Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return l.AuthError}}),Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return l.AuthErrorCategory}}),Object.defineProperty(t,"isAuthError",{enumerable:!0,get:function(){return l.isAuthError}}),t.authModels=s(r(538));var d=r(344);Object.defineProperty(t,"weAppJwtDecodeAll",{enumerable:!0,get:function(){return d.weAppJwtDecodeAll}});var p=r(949);Object.defineProperty(t,"AUTH_API_PREFIX",{enumerable:!0,get:function(){return p.AUTH_API_PREFIX}}),Object.defineProperty(t,"OAUTH_TYPE",{enumerable:!0,get:function(){return p.OAUTH_TYPE}}),Object.defineProperty(t,"DEFAULT_NODE_ACCESS_SCOPE",{enumerable:!0,get:function(){return p.DEFAULT_NODE_ACCESS_SCOPE}}),Object.defineProperty(t,"LOGIN_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return p.LOGIN_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"EVENTS",{enumerable:!0,get:function(){return p.EVENTS}}),Object.defineProperty(t,"AUTH_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return p.AUTH_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"AuthErrorCode",{enumerable:!0,get:function(){return p.AuthErrorCode}}),Object.defineProperty(t,"VerificationUsage",{enumerable:!0,get:function(){return p.VerificationUsage}});var f=function(){function e(e){console.log("[CloudbaseOAuth] init");var t=e.apiOrigin,r=e.getApiOrigin,i=e.apiPath,o=void 0===i?c.AUTH_API_PREFIX:i,s=e.clientId,h=e.env,l=e.storage,d=e.request,p=e.baseRequest,f=e.anonymousSignInFunc,v=e.wxCloud,g=e.adapter,y=e.onCredentialsError,m=e.headers,_=e.i18n,E=e.useWxCloud,b=e.eventBus,I=e.detectSessionInUrl,A=e.debug;if(this.detectSessionInUrl=null!=I&&I,this.oauth2client=new a.OAuth2Client({apiOrigin:t,getApiOrigin:r,apiPath:o,clientId:s,env:h,storage:l,baseRequest:p||d,anonymousSignInFunc:f,wxCloud:v,onCredentialsError:y,headers:m||{},i18n:_,useWxCloud:E,eventBus:b,debug:A}),this.authApi=new u.Auth(n(n({credentialsClient:this.oauth2client},e),{request:d?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:g})),I)this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));else try{var w=new URL(window.location.href),T=w.searchParams.get("code"),S=w.searchParams.get("state"),O=JSON.parse(sessionStorage.getItem(S)||"null");T&&S&&(null==O?void 0:O.hash)&&(w.hash=O.hash,window.history.replaceState(null,"",w.toString()),window.location.replace(w.toString()))}catch(e){}}return e.prototype.initializeSession=function(e){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(e),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))},e}();t.CloudbaseOAuth=f},877:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.Syntax=t.ErrorType=void 0;var n,i=r(949);Object.defineProperty(t,"ErrorType",{enumerable:!0,get:function(){return i.ErrorType}}),(n=t.Syntax||(t.Syntax={})).CLIENT_ID="client_id",n.CLIENT_SECRET="client_secret",n.RESPONSE_TYPE="response_type",n.SCOPE="scope",n.STATE="state",n.REDIRECT_URI="redirect_uri",n.ERROR="error",n.ERROR_DESCRIPTION="error_description",n.ERROR_URI="error_uri",n.GRANT_TYPE="grant_type",n.CODE="code",n.ACCESS_TOKEN="access_token",n.TOKEN_TYPE="token_type",n.EXPIRES_IN="expires_in",n.USERNAME="username",n.PASSWORD="password",n.REFRESH_TOKEN="refresh_token"},257:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.OAuth2Client=t.defaultStorage=t.generateRequestId=t.toResponseError=t.defaultRequest=void 0;var a=r(877),u=r(949),c=r(873),h=r(631),l=r(547),d=r(344),p=r(425),f=r(683),v="x-request-id",g="x-device-id",y="device_id";function m(){return(0,c.uuidv4)()}t.defaultRequest=function(e,t){return i(this,void 0,Promise,function(){var r,n,i,s,u;return o(this,function(o){switch(o.label){case 0:r=null,n=null,o.label=1;case 1:return o.trys.push([1,4,,5]),(i=Object.assign({},t)).method||(i.method="GET"),i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body)),[4,fetch(e,i)];case 2:return[4,o.sent().json()];case 3:return(null==(s=o.sent())?void 0:s.error)?(n=s).error_uri=new URL(e).pathname:r=s,[3,5];case 4:return u=o.sent(),n={error:a.ErrorType.UNREACHABLE,error_description:u.message,error_uri:new URL(e).pathname},[3,5];case 5:if(n)throw n;return[2,r]}})})},t.toResponseError=function(e,t){var r,n=t||{};if(e instanceof Error)r={error:n.error||a.ErrorType.LOCAL,error_description:n.error_description||e.message,error_uri:n.error_uri,details:n.details||e.stack};else{var i=e||{};r={error:n.error||i.error||a.ErrorType.LOCAL,error_description:n.error_description||i.error_description,error_uri:n.error_uri||i.error_uri,details:n.details||i.details}}return r},t.generateRequestId=m;var _=function(){function e(e){this._env=(null==e?void 0:e.env)||""}return e.prototype.getItem=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,window.localStorage.getItem("".concat(e).concat(this._env))]})})},e.prototype.removeItem=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return window.localStorage.removeItem("".concat(e).concat(this._env)),[2]})})},e.prototype.setItem=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(r){return window.localStorage.setItem("".concat(e).concat(this._env),t),[2]})})},e.prototype.getItemSync=function(e){return window.localStorage.getItem("".concat(e).concat(this._env))},e.prototype.removeItemSync=function(e){window.localStorage.removeItem("".concat(e).concat(this._env))},e.prototype.setItemSync=function(e,t){window.localStorage.setItem("".concat(e).concat(this._env),t)},e}();function E(e){var t=!0;return(null==e?void 0:e.expires_at)&&(null==e?void 0:e.access_token)&&(t=e.expires_at<new Date),t}t.defaultStorage=new _;var b=function(){function e(e){this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=e.tokenSectionName,this.storage=e.storage,this.clientId=e.clientId,this.singlePromise=new l.SinglePromise({clientId:this.clientId}),this.credentials=e.credentials||null}return e.prototype.getStorageCredentialsSync=function(){var e=null,t=this.storage.getItemSync(this.tokenSectionName);if(null!=t)try{(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at))}catch(t){this.storage.removeItem(this.tokenSectionName),e=null}return e},e.prototype.setCredentials=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return(null==e?void 0:e.expires_in)?((null==e?void 0:e.expires_at)||(e.expires_at=new Date(Date.now()+1e3*(e.expires_in-30))),this.storage?(t=JSON.stringify(e),[4,this.storage.setItem(this.tokenSectionName,t)]):[3,2]):[3,3];case 1:r.sent(),r.label=2;case 2:return this.credentials=e,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:r.sent(),r.label=5;case 5:this.credentials=null,r.label=6;case 6:return[2]}})})},e.prototype.setAccessKeyCredentials=function(e){this.accessKeyCredentials=e,e.scope===u.DEFAULT_NODE_ACCESS_SCOPE&&(this.credentials=e)},e.prototype.getCredentials=function(){return i(this,void 0,Promise,function(){var e=this;return o(this,function(t){return[2,this.singlePromise.run("getCredentials",function(){return i(e,void 0,void 0,function(){var e,t;return o(this,function(r){switch(r.label){case 0:return E(this.credentials)?[4,this.getStorageCredentials()]:[3,2];case 1:if(e=r.sent(),t=e.credentials,e.isAccessKeyCredentials)return[2,t];this.credentials=t,r.label=2;case 2:return[2,this.credentials]}})})})]})})},e.prototype.getStorageCredentials=function(){return i(this,void 0,Promise,function(){var e=this;return o(this,function(t){return[2,this.singlePromise.run("_getStorageCredentials",function(){return i(e,void 0,void 0,function(){var e,t,r;return o(this,function(n){switch(n.label){case 0:return e=null,t=!1,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(!(r=n.sent()))return[3,6];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(e=JSON.parse(r))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),e=null,[3,5];case 5:return[3,7];case 6:e=this.accessKeyCredentials||null,t=!0,n.label=7;case 7:return[2,{credentials:e,isAccessKeyCredentials:t}]}})})})]})})},e}();t.OAuth2Client=function(){function e(r){var n,i=this;this.initializePromise=null,this.lockAcquired=!1,this.pendingInLock=[],this.singlePromise=null,r.clientSecret||(r.clientSecret=""),!r.clientId&&r.env&&(r.clientId=r.env),this.apiOrigin=r.apiOrigin,this.getApiOriginFunc=r.getApiOrigin,this.apiPath=r.apiPath||u.AUTH_API_PREFIX,this.clientId=r.clientId,this.i18n=r.i18n,this.eventBus=r.eventBus,this.singlePromise=new l.SinglePromise({clientId:this.clientId}),this.retry=this.formatRetry(r.retry,e.defaultRetry),r.baseRequest?this.baseRequest=r.baseRequest:this.baseRequest=t.defaultRequest,this.tokenInURL=r.tokenInURL,this.headers=r.headers,this.storage=r.storage||t.defaultStorage,this.localCredentials=new b({tokenSectionName:"credentials_".concat(r.clientId),storage:this.storage,clientId:r.clientId}),this.clientSecret=r.clientSecret,r.clientId&&(this.basicAuth="Basic ".concat((0,d.weBtoa)("".concat(r.clientId,":").concat(this.clientSecret)))),this.wxCloud=r.wxCloud;try{(0,p.isMp)()&&(this.useWxCloud=r.useWxCloud,void 0===this.wxCloud&&r.env&&(wx.cloud.init({env:r.env}),this.wxCloud=wx.cloud))}catch(e){}this.refreshTokenFunc=r.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=r.anonymousSignInFunc,this.onCredentialsError=r.onCredentialsError,this.getInitialSession=r.getInitialSession,this.onInitialSessionObtained=r.onInitialSessionObtained,this.logDebugMessages=null!==(n=r.debug)&&void 0!==n&&n,f.langEvent.bus.on(f.langEvent.LANG_CHANGE_EVENT,function(e){var t;i.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||i.i18n})}return e.prototype.setGetInitialSession=function(e){this.getInitialSession=e},e.prototype.setOnInitialSessionObtained=function(e){this.onInitialSessionObtained=e},e.prototype.initialize=function(e){return i(this,void 0,Promise,function(){var t=this;return o(this,function(r){switch(r.label){case 0:return this.initializePromise?[4,this.initializePromise]:[3,2];case 1:case 3:case 5:return[2,r.sent()];case 2:return void 0===e?[3,4]:(this.initializePromise=e,[4,this.initializePromise]);case 4:return this.initializePromise=i(t,void 0,void 0,function(){var e=this;return o(this,function(t){switch(t.label){case 0:return[4,this._acquireLock(-1,function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,this._initialize()];case 1:return[2,e.sent()]}})})})];case 1:return[2,t.sent()]}})}),[4,this.initializePromise]}})})},e.prototype.setCredentials=function(e){return i(this,void 0,Promise,function(){var t=this;return o(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[2,this._acquireLock(-1,function(){return i(t,void 0,void 0,function(){return o(this,function(t){return[2,this.localCredentials.setCredentials(e)]})})})]}})})},e.prototype.setAccessKeyCredentials=function(e){return this.localCredentials.setAccessKeyCredentials(e)},e.prototype.getAccessToken=function(){return i(this,void 0,Promise,function(){var e,t;return o(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[4,this.getCredentials()];case 2:return(null==(e=r.sent())?void 0:e.scope)===u.DEFAULT_NODE_ACCESS_SCOPE||(null==e?void 0:e.access_token)?[2,Promise.resolve(e.access_token)]:(t={error:a.ErrorType.UNAUTHENTICATED},[2,Promise.reject(t)])}})})},e.prototype.request=function(t,r){var s,u;return i(this,void 0,Promise,function(){var i,c,h,l,d,p,f,y,_,E;return o(this,function(o){switch(o.label){case 0:return r||(r={}),i=this.formatRetry(r.retry,this.retry),r.headers=n(n({},r.headers),((E={})[null===(s=this.i18n)||void 0===s?void 0:s.LANG_HEADER_KEY]=null===(u=this.i18n)||void 0===u?void 0:u.lang,E)),this.headers&&(r.headers=n(n({},this.headers),r.headers)),r.headers[v]||(r.headers[v]=m()),r.headers[g]?[3,2]:[4,this.getDeviceId()];case 1:c=o.sent(),r.headers[g]=c,o.label=2;case 2:return(null==r?void 0:r.withBasicAuth)&&this.basicAuth&&(r.headers.Authorization=this.basicAuth),(null==r?void 0:r.withCredentials)?r.getCredentials?[4,r.getCredentials()]:[3,4]:[3,7];case 3:return l=o.sent(),[3,6];case 4:return[4,this.getCredentials()];case 5:l=o.sent(),o.label=6;case 6:return(h=l)&&(this.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+="access_token=".concat(h.access_token)):r.headers.Authorization="".concat(h.token_type," ").concat(h.access_token)),[3,8];case 7:this.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+="client_id=".concat(this.clientId)),o.label=8;case 8:t.startsWith("/")&&(d=this.getApiOriginFunc?this.getApiOriginFunc():this.apiOrigin,t="".concat(d).concat(this.apiPath).concat(t)),p=null,f=i+1,y=0,o.label=9;case 9:if(!(y<f))return[3,21];o.label=10;case 10:return o.trys.push([10,15,,18]),r.useWxCloud||this.useWxCloud?[4,this.wxCloudCallFunction(t,r)]:[3,12];case 11:return p=o.sent(),[3,14];case 12:return[4,this.baseRequest(t,r)];case 13:p=o.sent(),o.label=14;case 14:if(null==p?void 0:p.code)throw{error:p.code,error_description:p.message,error_uri:new URL(t).pathname};return[3,21];case 15:_=o.sent();try{_.requestId=_.requestId||r.headers[v]||""}catch(e){}return r.withCredentials&&_&&_.error===a.ErrorType.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,17];case 16:return o.sent(),[2,Promise.reject(_)];case 17:return y!==i&&_&&"unreachable"===_.error?[3,18]:[2,Promise.reject(_)];case 18:return[4,this.sleep(e.retryInterval)];case 19:o.sent(),o.label=20;case 20:return y++,[3,9];case 21:return[2,p]}})})},e.prototype.wxCloudCallFunction=function(e,t){var r;return i(this,void 0,Promise,function(){var i,s,u,c,l;return o(this,function(o){switch(o.label){case 0:i=null,s=null,o.label=1;case 1:o.trys.push([1,7,,8]),u="",o.label=2;case 2:return o.trys.push([2,4,,5]),[4,wx.getRendererUserAgent()];case 3:return u=o.sent(),[3,5];case 4:return o.sent(),[3,5];case 5:return[4,this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:e,method:t.method,headers:n({origin:"https://servicewechat.com","User-Agent":u},t.headers),body:t.body}})];case 6:return c=o.sent().result,(null===(r=null==c?void 0:c.body)||void 0===r?void 0:r.error_code)?(s=null==c?void 0:c.body).error_uri=(0,h.getPathName)(e):i=null==c?void 0:c.body,[3,8];case 7:return l=o.sent(),s={error:a.ErrorType.UNREACHABLE,error_description:l.message,error_uri:(0,h.getPathName)(e)},[3,8];case 8:if(s)throw s;return[2,i]}})})},e.prototype.getCredentials=function(){return i(this,void 0,Promise,function(){var e=this;return o(this,function(t){switch(t.label){case 0:return[4,this.initializePromise];case 1:return t.sent(),[2,this._acquireLock(-1,function(){return i(e,void 0,void 0,function(){return o(this,function(e){return[2,this._getCredentials()]})})})]}})})},e.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},e.prototype.getCredentialsAsync=function(){return this.getCredentials()},e.prototype.getScope=function(){var e;return i(this,void 0,Promise,function(){var t,r;return o(this,function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=n.sent())?[2,t.scope]:(r="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}})})},e.prototype.getGroups=function(){var e;return i(this,void 0,Promise,function(){var t,r;return o(this,function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=n.sent())?[2,t.groups]:(r="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}})})},e.prototype.refreshToken=function(e,t){return i(this,void 0,Promise,function(){var r=this;return o(this,function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[2,this._acquireLock(-1,function(){return i(r,void 0,void 0,function(){return o(this,function(r){return[2,this._refreshToken(e,t)]})})})]}})})},e.prototype._refreshToken=function(e,t){return i(this,void 0,Promise,function(){var r=this;return o(this,function(n){return[2,this.singlePromise.run("_refreshToken",function(){return i(r,void 0,void 0,function(){var r,n,i,s,c,h,l;return o(this,function(o){switch(o.label){case 0:if((null==e?void 0:e.scope)===u.DEFAULT_NODE_ACCESS_SCOPE)return[2,e];if(!e||!e.refresh_token)return i="no refresh token found in credentials",null===(s=this.onCredentialsError)||void 0===s||s.call(this,{msg:i}),[2,this.unAuthenticatedError(i)];o.label=1;case 1:return o.trys.push([1,4,,7]),[4,this.refreshTokenFunc(e.refresh_token,e)];case 2:return r=o.sent(),[4,this.localCredentials.setCredentials(r)];case 3:return o.sent(),null===(c=this.eventBus)||void 0===c||c.fire(u.EVENTS.AUTH_STATE_CHANGED,{event:u.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED}),[2,r];case 4:if(n=o.sent(),null==t?void 0:t.throwError)throw n;return n.error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return o.sent(),i=n.error_description,null===(h=this.onCredentialsError)||void 0===h||h.call(this,{msg:i}),[2,this.unAuthenticatedError(i)];case 6:return null===(l=this.onCredentialsError)||void 0===l||l.call(this,{msg:n.error_description}),[2,Promise.reject(n)];case 7:return[2]}})})})]})})},e.prototype.anonymousLogin=function(e){return i(this,void 0,void 0,function(){var t=this;return o(this,function(r){return[2,this.singlePromise.run("_anonymousLogin",function(){return i(t,void 0,void 0,function(){var t,r;return o(this,function(n){switch(n.label){case 0:return this.anonymousSignInFunc?[4,this.anonymousSignInFunc(e)]:[3,4];case 1:return t=n.sent(),(r=t)?[3,3]:[4,this.localCredentials.getCredentials()];case 2:r=n.sent(),n.label=3;case 3:return e=r,[3,6];case 4:return[4,this.anonymousSignIn(e)];case 5:e=n.sent(),n.label=6;case 6:return[2,e]}})})})]})})},e.prototype.checkRetry=function(t){var r=null;if(("number"!=typeof t||t<e.minRetry||t>e.maxRetry)&&(r={error:a.ErrorType.UNREACHABLE,error_description:"wrong options param: retry"}),r)throw r;return t},e.prototype.formatRetry=function(e,t){return void 0===e?t:this.checkRetry(e)},e.prototype.sleep=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,new Promise(function(t){setTimeout(function(){t()},e)})]})})},e.prototype.anonymousSignIn=function(e){return i(this,void 0,Promise,function(){var t=this;return o(this,function(r){return[2,this.singlePromise.run("_anonymous",function(){return i(t,void 0,void 0,function(){var t,r;return o(this,function(n){switch(n.label){case 0:if(!e||"anonymous"!==e.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];n.label=1;case 1:return n.trys.push([1,4,,7]),[4,this.request(u.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}})];case 2:return t=n.sent(),[4,this.localCredentials.setCredentials(t)];case 3:return n.sent(),[2,t];case 4:return(r=n.sent()).error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return n.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}})})})]})})},e.prototype.defaultRefreshTokenFunc=function(e,t){var r;return i(this,void 0,Promise,function(){var i,s,a;return o(this,function(o){switch(o.label){case 0:return void 0===e||""===e?(i="refresh token not found",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:i}),[2,this.unAuthenticatedError(i)]):(s=u.ApiUrls.AUTH_TOKEN_URL,"v2"===(null==t?void 0:t.version)&&(s=u.ApiUrlsV2.AUTH_TOKEN_URL),[4,this.request(s,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:e}})]);case 1:return a=o.sent(),[2,n(n({},a),{version:(null==t?void 0:t.version)||"v1"})]}})})},e.prototype.getDeviceId=function(){return i(this,void 0,Promise,function(){var e;return o(this,function(t){switch(t.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(y)];case 1:return"string"==typeof(e=t.sent())&&e.length>=16&&e.length<=48?[3,3]:(e=(0,c.uuidv4)(),[4,this.storage.setItem(y,e)]);case 2:t.sent(),t.label=3;case 3:return this.deviceID=e,[2,e]}})})},e.prototype.unAuthenticatedError=function(e){var t={error:a.ErrorType.UNAUTHENTICATED,error_description:e};return Promise.reject(t)},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logDebugMessages&&console.log.apply(console,s(["[OAuth2Client]"],e,!1))},e.prototype._initialize=function(){return i(this,void 0,Promise,function(){var e,t,r,n,i,s;return o(this,function(o){switch(o.label){case 0:if(o.trys.push([0,11,12,13]),!this.getInitialSession)return this._debug("#_initialize()","no getInitialSession callback set, skipping"),[2,{error:null}];this._debug("#_initialize()","calling getInitialSession callback"),o.label=1;case 1:return o.trys.push([1,9,,10]),[4,this.getInitialSession()];case 2:return s=o.sent(),e=s.data,t=s.error,(null==e?void 0:e.session)?(this._debug("#_initialize()","session obtained from getInitialSession",e.session),[4,this.localCredentials.setCredentials(null==e?void 0:e.session)]):[3,4];case 3:o.sent(),o.label=4;case 4:if(!this.onInitialSessionObtained)return[3,8];this._debug("#_initialize()","calling onInitialSessionObtained callback"),o.label=5;case 5:return o.trys.push([5,7,,8]),[4,this.onInitialSessionObtained(e,t)];case 6:return o.sent(),[3,8];case 7:return r=o.sent(),this._debug("#_initialize()","error in onInitialSessionObtained",r),[3,8];case 8:return t?(this._debug("#_initialize()","error from getInitialSession",t),[2,{error:t}]):[2,{error:null}];case 9:return n=o.sent(),this._debug("#_initialize()","exception during getInitialSession",n),[2,{error:n instanceof Error?n:new Error(String(n))}];case 10:return[3,13];case 11:return i=o.sent(),this._debug("#_initialize()","unexpected error",i),[2,{error:i instanceof Error?i:new Error(String(i))}];case 12:return this._debug("#_initialize()","end"),[7];case 13:return[2]}})})},e.prototype._acquireLock=function(e,t){return i(this,void 0,Promise,function(){var r,n,a,u,c=this;return o(this,function(h){switch(h.label){case 0:this._debug("#_acquireLock","begin",e),h.label=1;case 1:if(h.trys.push([1,,10,11]),this.lockAcquired)return r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=i(c,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,r];case 1:return e.sent(),[4,t()];case 2:return[2,e.sent()]}})}),this.pendingInLock.push(i(c,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,n];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})),[2,n];this._debug("#_acquireLock","acquiring lock for client",this.clientId),h.label=2;case 2:return h.trys.push([2,,8,9]),this.lockAcquired=!0,a=t(),this.pendingInLock.push(i(c,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,a];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})),[4,a];case 3:h.sent(),h.label=4;case 4:return this.pendingInLock.length?(u=s([],this.pendingInLock,!0),[4,Promise.all(u)]):[3,6];case 5:return h.sent(),this.pendingInLock.splice(0,u.length),[3,4];case 6:return[4,a];case 7:return[2,h.sent()];case 8:return this._debug("#_acquireLock","releasing lock for client",this.clientId),this.lockAcquired=!1,[7];case 9:return[3,11];case 10:return this._debug("#_acquireLock","end"),[7];case 11:return[2]}})})},e.prototype._getCredentials=function(){var e,t,r;return i(this,void 0,Promise,function(){var n,i,s;return o(this,function(o){switch(o.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:if((null==(n=o.sent())?void 0:n.scope)===u.DEFAULT_NODE_ACCESS_SCOPE)return[2,n];if(!n)return s="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];if(!E(n))return[3,12];if(!n.refresh_token)return[3,9];o.label=2;case 2:return o.trys.push([2,4,,8]),[4,this._refreshToken(n)];case 3:return n=o.sent(),[3,8];case 4:return i=o.sent(),"anonymous"!==n.scope?[3,6]:[4,this.anonymousLogin(n)];case 5:return n=o.sent(),[3,7];case 6:return null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:i.error_description}),[2,Promise.reject(i)];case 7:return[3,8];case 8:return[3,12];case 9:return"anonymous"!==n.scope?[3,11]:[4,this.anonymousLogin(n)];case 10:return n=o.sent(),[3,12];case 11:return s="no refresh token found in credentials",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];case 12:return[2,n]}})})},e.defaultRetry=2,e.minRetry=0,e.maxRetry=5,e.retryInterval=1e3,e}()},344:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.weAppJwtDecodeAll=t.weappJwtDecode=t.base64_url_decode=t.weAtob=t.weBtoa=void 0;var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function i(e){var r=e.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(e){return decodeURIComponent((0,t.weAtob)(e).replace(/(.)/g,function(e){var t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0".concat(t)),"%".concat(t)}))}(r)}catch(e){return(0,t.weAtob)(r)}}t.weBtoa=function(e){for(var t,n,i,o,s="",a=0,u=(e=String(e)).length%3;a<e.length;){if((n=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");s+=r.charAt((t=n<<16|i<<8|o)>>18&63)+r.charAt(t>>12&63)+r.charAt(t>>6&63)+r.charAt(63&t)}return u?s.slice(0,u-3)+"===".substring(u):s},t.weAtob=function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!n.test(e))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var i,o,s="",a=0;a<e.length;)t=r.indexOf(e.charAt(a++))<<18|r.indexOf(e.charAt(a++))<<12|(i=r.indexOf(e.charAt(a++)))<<6|(o=r.indexOf(e.charAt(a++))),s+=64===i?String.fromCharCode(t>>16&255):64===o?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return s},t.base64_url_decode=i,t.weappJwtDecode=function(e,t){if("string"!=typeof e)throw new Error("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(i(e.split(".")[r]))}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}},t.weAppJwtDecodeAll=function(e){if("string"!=typeof e)throw new Error("Invalid token specified");try{var t=e.split(".").map(function(e,t){return 2===t?e:JSON.parse(i(e))});return{claims:t[1],header:t[0],signature:t[2]}}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}}},814:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getEncryptInfo=void 0;var i=n(r(12)),o=r(631);t.getEncryptInfo=function(e){var t=void 0===e?{}:e,r=t.publicKey,n=void 0===r?"":r,s=t.payload,a=void 0===s?{}:s;if(!n)return"";try{var u=(0,o.deepClone)(a),c=new i.default;return c.setPublicKey(n),c.encryptLong("object"==typeof u?JSON.stringify(u):u)}catch(e){console.error("encrypt error:",e)}return""}},547:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SinglePromise=void 0;var i=new Map,o=function(){function e(e){this.clientId=(null==e?void 0:e.clientId)||"",i=i||new Map}return e.prototype.run=function(e,t){return r(this,void 0,Promise,function(){var o,s=this;return n(this,function(a){return e="".concat(this.clientId,"_").concat(e),(o=i.get(e))||(o=new Promise(function(o,a){r(s,void 0,void 0,function(){var r,s,u;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return n.sent(),r=t(),s=o,[4,r];case 2:return s.apply(void 0,[n.sent()]),[3,5];case 3:return u=n.sent(),a(u),[3,5];case 4:return i.delete(e),[7];case 5:return[2]}})})}),i.set(e,o)),[2,o]})})},e.prototype.runIdlePromise=function(){return Promise.resolve()},e}();t.SinglePromise=o},631:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.getPathName=t.deepClone=void 0,t.deepClone=function(e){var r=function(r){for(var n in e)e.hasOwnProperty(n)&&(r[n]=(0,t.deepClone)(e[n]));return r},n=null==e?"NullOrUndefined":Object.prototype.toString.call(e).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(n))return e.slice();switch(n){case"Object":return r(Object.create(Object.getPrototypeOf(e)));case"Array":return r([]);case"Date":return new Date(e.valueOf());case"RegExp":return new RegExp(e.source,(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":""));default:return e}},t.getPathName=function(e){var t=e.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return t&&t[2]||""}},425:function(e,t){function r(){if("undefined"==typeof globalThis)return!1;var e=globalThis.wx;if(void 0===e)return!1;if(void 0===globalThis.Page)return!1;if(!e.getDeviceInfo)return!1;if(!e.getStorageSync)return!1;if(!e.setStorageSync)return!1;if(!e.connectSocket)return!1;if(!e.request)return!1;try{if(!e.getDeviceInfo())return!1;if("qq"===e.getDeviceInfo().platform)return!1}catch(e){return!1}return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.isInMpWebView=t.isMp=void 0,t.isMp=r;var n=!1;function i(){n=n||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{r()||(n=n||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?i():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",i,!1))}catch(e){}t.isInMpWebView=function(){return n}},639:function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){if(this.params={},"string"==typeof e)this.parse(e);else if(e&&"object"==typeof e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.append(t,e[t])}return e.prototype.parse=function(e){var t=this;e.split("&").forEach(function(e){var r=e.split("=").map(decodeURIComponent),n=r[0],i=r[1];t.append(n,i)})},e.prototype.append=function(e,t){this.params[e]?this.params[e]=this.params[e].concat([t]):this.params[e]=[t]},e.prototype.get=function(e){return this.params[e]?this.params[e][0]:null},e.prototype.getAll=function(e){return this.params[e]||[]},e.prototype.delete=function(e){delete this.params[e]},e.prototype.has=function(e){return Object.prototype.hasOwnProperty.call(this.params,e)},e.prototype.set=function(e,t){this.params[e]=[t]},e.prototype.toString=function(){var e=[],t=function(t){Object.prototype.hasOwnProperty.call(r.params,t)&&r.params[t].forEach(function(r){e.push("".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(r)))})},r=this;for(var n in this.params)t(n);return e.join("&")},e}();t.default=r},873:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=void 0,t.uuidv4=function(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}},563:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(92)),c=r(962);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,i=(0,c.isArray)(e)?e:[e];r<i.length;r++){var o=i[r],s=o.isMatch,a=o.genAdapter,u=o.runtime;if(s())return{adapter:n({isMatch:s},a(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},92:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},o.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(764),c=r(962),h=r(464),l=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,i=t.timeoutMsg,o=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=i||"请求超时",r.restrictedMethods=o||["get","post","upload","download"],r}return i(t,e),t.prototype.get=function(e){return this.request(o(o({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(o(o({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(o(o({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,i=e.method,s=e.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==i?void 0:i.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(t).forEach(function(e){c.append(e,t[e])}),c.append("key",n),c.append("file",r),this.request(o(o({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(o(o({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,Promise,function(){var t,r,n,i;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(o(o({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(i=document.createElement("a")).href=r,i.setAttribute("download",n),i.style.display="none",document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(r),document.body.removeChild(i),[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.fetch=function(e){var t;return s(this,void 0,Promise,function(){var r,n,i,u,c,h,l,d,p,f,v,g,y,m=this;return a(this,function(_){switch(_.label){case 0:return r=new AbortController,n=e.url,i=e.enableAbort,u=void 0!==i&&i,c=e.stream,h=void 0!==c&&c,l=e.signal,d=e.timeout,p=e.shouldThrowOnError,f=void 0===p||p,v=null!=d?d:this.timeout,l&&(l.aborted&&r.abort(),l.addEventListener("abort",function(){return r.abort()})),g=null,u&&v&&(g=setTimeout(function(){console.warn(m.timeoutMsg),r.abort(new Error(m.timeoutMsg))},v)),[4,fetch(n,o(o({},e),{signal:r.signal})).then(function(e){return s(m,void 0,void 0,function(){var t,r,n;return a(this,function(i){switch(i.label){case 0:return clearTimeout(g),f?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[i.sent()]),i.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(g),Promise.reject(e)})];case 1:return y=_.sent(),[2,{data:h?y.body:(null===(t=y.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?y.json():y.text(),statusCode:y.status,header:y.headers,response:y}]}})})},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise(function(i){var o=e.url,s=e.headers,a=void 0===s?{}:s,u=e.data,l=e.responseType,d=e.withCredentials,p=e.body,f=e.onUploadProgress,v=(0,c.formatUrl)((0,h.getProtocol)(),o,"get"===n?u:{}),g=new XMLHttpRequest;g.open(n,v),l&&(g.responseType=l);var y,m,_=e.signal;_&&(_.aborted?g.abort():_.addEventListener("abort",function(){return g.abort()},{once:!0})),Object.keys(a).forEach(function(e){g.setRequestHeader(e,a[e])}),f&&g.upload.addEventListener("progress",f),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach(function(e){var t=e.split(": "),n=t.shift().toLowerCase(),i=t.join(": ");r[n]=i}),e.header=r,e.statusCode=g.status;try{e.data="blob"===l?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===l?g.response:g.responseText}clearTimeout(y),i(e)}},t&&r.timeout&&(y=setTimeout(function(){console.warn(r.timeoutMsg),g.abort()},r.timeout)),m=(0,c.isFormData)(u)?u:"application/x-www-form-urlencoded"===a["content-type"]?(0,c.toQueryString)(u):p||(u?JSON.stringify(u):void 0),d&&(g.withCredentials=!0),g.send(m)})},t}(u.AbstractSDKRequest);t.WebRequest=l,t.genAdapter=function(){return{type:"default",root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},464:function(e,t){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 n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},519:function(e,t){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"}},778:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,i(r(464),t),i(r(519),t),t.OATUH_LOGINTYPE="constants"},517:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var o=r(962),s=r(778),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function h(e){var t=e.err,r=e.className,n=e.methodName,i=e.sourceLink;if(!i)return null;var o,s=t.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),h=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),l=s.findIndex(function(e){return u.test(e)});if(-1!==l){var d=s.filter(function(e,t){return t>l});d.unshift(s[l].replace(h,"".concat(r,".").concat(n)).replace(c,i)),(o=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return o}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,l=void 0===a?{}:a,d=e.title,p=e.messages,f=void 0===p?[]:p;return function(e,t,a){if(s.IS_DEBUG_MODE){var p=l.className||e.constructor.name,v=l.methodName||t,g=a.value,y=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex(function(e){return u.test(e)});if(-1!==r){var n=c.exec(t[r+1]||"");e=n?n[0]:""}return e}();a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=h({err:new Error,className:p,methodName:v,sourceLink:y});try{return g.apply(this,e)}catch(e){var n=e,i=e.message,s=e.error,a=e.error_description,u={title:d||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:e}]};if(i&&/^\{.*\}$/.test(i)){var c=JSON.parse(i);u.subtitle=i,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=f.map(function(e){return{type:"info",body:e}}))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=f.map(function(e){return{type:"info",body:e}})),(0,o.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,function(){var t,r,n,s,a,u,c,l;return i(this,function(i){switch(i.label){case 0:t=h({err:new Error,className:p,methodName:v,sourceLink:y}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,g.apply(this,e)];case 2:return[2,i.sent()];case 3:throw r=i.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:d||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),c.subtitle=l,l.code&&(t?(t.code=l.code,t.message=l.msg):(r.code=l.code,r.message=l.msg),n=t||r,c.content=f.map(function(e){return{type:"info",body:e}}))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=f.map(function(e){return{type:"info",body:e}})),(0,o.printGroupLog)(c),n;case 4:return[2]}})})}}}}},260:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(517),t)},683:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.langEvent=t.AbortController=t.jwt=t.helpers=t.utils=t.events=t.cache=t.adapters=t.constants=void 0;var a=o(r(778));t.constants=a;var u=o(r(563));t.adapters=u;var c=o(r(865));t.cache=c;var h=o(r(940));t.events=h;var l=o(r(991));t.langEvent=l;var d=o(r(962));t.utils=d;var p=o(r(260));t.helpers=p;var f=s(r(829));t.AbortController=f.default;var v={decode:s(r(107)).default};t.jwt=v},829:function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){var e=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(t,r){"abort"===t&&e.listeners.push(r)}}}return e.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach(function(e){return e()}))},e}();t.default=r},865:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(764),u=r(962),c=r(778),h=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return i(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}(a.AbstractStorage),l=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,i=e.keys,o=void 0===i?{}:i;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(t.root));case"none":return new h(t.root)}}(this.persistenceTag,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.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return o(this,void 0,void 0,function(){var n;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]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return i.sent(),[3,4];case 3:return i.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return o(this,void 0,void 0,function(){var n;return s(this,function(i){switch(i.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=i.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return o(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]}})})},e}();t.CloudbaseCache=l},940:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(962),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return i(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var i=0,c=this.listeners[n]?o([],this.listeners[n],!0):[];i<c.length;i++)c[i].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var h=new c;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)}},991:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.LANG_CHANGE_EVENT=t.bus=void 0;var n=r(940);t.bus=new n.CloudbaseEventEmitter,t.LANG_CHANGE_EVENT="lang_change"},962:function(e,t,r){var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=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.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var i=r(778);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.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)})},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),i="";return Object.keys(r).forEach(function(e){""===i?!n&&(t+="?"):i+="&",i+="".concat(e,"=").concat(encodeURIComponent(r[e]))}),/^http(s)?:\/\//.test(t+=i)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),i=r.substr(r.indexOf("?")+1).match(n);return null!=i?i[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],i=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==i){for(var o=(n=i.split("&")).length-1;o>=0;o-=1)n[o].split("=")[0]===e&&n.splice(o,1);r="".concat(r,"?").concat(n.join("&"))}return r},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 r=new Promise(function(t,r){e=function(e,n){return e?r(e):t(n)}});return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,i=void 0===n?"":n,o=e.content,s=void 0===o?[]:o,a=e.printTrace,u=void 0!==a&&a,c=e.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,i):(console.group||console.error)(r,i);for(var h=0,l=s;h<l.length;h++){var d=l[h],p=d.type,f=d.body;switch(p){case"info":console.log(f);break;case"warn":console.warn(f);break;case"error":console.error(f)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var r=e.split("="),n=r[0],i=r[1];n=decodeURIComponent(n),i=decodeURIComponent(i),n&&(t[n]?Array.isArray(t[n])?t[n].push(i):t[n]=[t[n],i]:t[n]=i)}),t},t.parseCaptcha=function(e){var r={},i=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){e=i[1];var o=i[2];o&&(r=(0,t.parseQueryString)(o))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},12:function(e,t,r){var n;if(r.r(t),!globalThis.IS_MP_BUILD){var i="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;function x(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function M(e,t){return e&t}function j(e,t){return e|t}function V(e,t){return e^t}function B(e,t){return e&~t}function q(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function H(e){for(var t=0;0!=e;)e&=e-1,++t;return t}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function W(e){var t,r,n="";for(t=0;t+3<=e.length;t+=3)r=parseInt(e.substring(t,t+3),16),n+=o.charAt(r>>6)+o.charAt(63&r);for(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=o.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=o.charAt(r>>2)+o.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function G(e){var t,r="",n=0,i=0;for(t=0;t<e.length&&"="!=e.charAt(t);++t){var s=o.indexOf(e.charAt(t));s<0||(0==n?(r+=x(s>>2),i=3&s,n=1):1==n?(r+=x(i<<2|s>>4),i=15&s,n=2):2==n?(r+=x(i),r+=x(s>>2),i=3&s,n=3):(r+=x(i<<2|s>>4),r+=x(15&s),n=0))}return 1==n&&(r+=x(i<<2)),r}var s,a,u={decode:function(e){var t;if(void 0===s){var r="0123456789ABCDEF";for(s={},t=0;t<16;++t)s[r.charAt(t)]=t;for(r=r.toLowerCase(),t=10;t<16;++t)s[r.charAt(t)]=t;for(t=0;t<8;++t)s[" \f\n\r\t \u2028\u2029".charAt(t)]=-1}var n=[],i=0,o=0;for(t=0;t<e.length;++t){var a=e.charAt(t);if("="==a)break;if(-1!=(a=s[a])){if(void 0===a)throw new Error("Illegal character at offset "+t);i|=a,++o>=2?(n[n.length]=i,i=0,o=0):i<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},c={decode:function(e){var t;if(void 0===a){for(a=Object.create(null),t=0;t<64;++t)a["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)]=t;for(t=0;t<9;++t)a["= \f\n\r\t \u2028\u2029".charAt(t)]=-1}var r=[],n=0,i=0;for(t=0;t<e.length;++t){var o=e.charAt(t);if("="==o)break;if(-1!=(o=a[o])){if(void 0===o)throw new Error("Illegal character at offset "+t);n|=o,++i>=4?(r[r.length]=n>>16,r[r.length]=n>>8&255,r[r.length]=255&n,n=0,i=0):n<<=6}}switch(i){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=n>>10;break;case 3:r[r.length]=n>>16,r[r.length]=n>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(e){var t=c.re.exec(e);if(t)if(t[1])e=t[1];else{if(!t[2])throw new Error("RegExp out of sync");e=t[2]}return c.decode(e)}},h=1e13;class F{constructor(e){this.buf=[+e||0]}mulAdd(e,t){var r,n,i=this.buf,o=i.length;for(r=0;r<o;++r)(n=i[r]*e+t)<h?t=0:n-=(t=0|n/h)*h,i[r]=n;t>0&&(i[r]=t)}sub(e){var t,r,n=this.buf,i=n.length;for(t=0;t<i;++t)(r=n[t]-e)<0?(r+=h,e=1):e=0,n[t]=r;for(;0===n[n.length-1];)n.pop()}toString(e){if(10!=(e||10))throw new Error("only base 10 is supported");for(var t=this.buf,r=t[t.length-1].toString(),n=t.length-2;n>=0;--n)r+=(h+t[n]).toString().substring(1);return r}valueOf(){for(var e=this.buf,t=0,r=e.length-1;r>=0;--r)t=t*h+e[r];return t}simplify(){var e=this.buf;return 1==e.length?e[0]:this}}var l,d=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,p=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function Y(e,t){return e.length>t&&(e=e.substring(0,t)+"…"),e}class K{constructor(e,t){this.hexDigits="0123456789ABCDEF",e instanceof K?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=t)}get(e){if(void 0===e&&(e=this.pos++),e>=this.enc.length)throw new Error("Requesting byte offset "+e+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(e):this.enc[e]}hexByte(e){return this.hexDigits.charAt(e>>4&15)+this.hexDigits.charAt(15&e)}hexDump(e,t,r){for(var n="",i=e;i<t;++i)if(n+=this.hexByte(this.get(i)),!0!==r)switch(15&i){case 7:n+=" ";break;case 15:n+="\n";break;default:n+=" "}return n}isASCII(e,t){for(var r=e;r<t;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(e,t){for(var r="",n=e;n<t;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(e,t){for(var r="",n=e;n<t;){var i=this.get(n++);r+=i<128?String.fromCharCode(i):i>191&&i<224?String.fromCharCode((31&i)<<6|63&this.get(n++)):String.fromCharCode((15&i)<<12|(63&this.get(n++))<<6|63&this.get(n++))}return r}parseStringBMP(e,t){for(var r,n,i="",o=e;o<t;)r=this.get(o++),n=this.get(o++),i+=String.fromCharCode(r<<8|n);return i}parseTime(e,t,r){var n=this.parseStringISO(e,t),i=(r?d:p).exec(n);return i?(r&&(i[1]=+i[1],i[1]+=+i[1]<70?2e3:1900),n=i[1]+"-"+i[2]+"-"+i[3]+" "+i[4],i[5]&&(n+=":"+i[5],i[6]&&(n+=":"+i[6],i[7]&&(n+="."+i[7]))),i[8]&&(n+=" UTC","Z"!=i[8]&&(n+=i[8],i[9]&&(n+=":"+i[9]))),n):"Unrecognized time: "+n}parseInteger(e,t){for(var r,n=this.get(e),i=n>127,o=i?255:0,s="";n==o&&++e<t;)n=this.get(e);if(0===(r=t-e))return i?-1:0;if(r>4){for(s=n,r<<=3;!(128&(+s^o));)s=+s<<1,--r;s="("+r+" bit)\n"}i&&(n-=256);for(var a=new F(n),u=e+1;u<t;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(e,t,r){for(var n=this.get(e),i="("+((t-e-1<<3)-n)+" bit)\n",o="",s=e+1;s<t;++s){for(var a=this.get(s),u=s==t-1?n:0,c=7;c>=u;--c)o+=a>>c&1?"1":"0";if(o.length>r)return i+Y(o,r)}return i+o}parseOctetString(e,t,r){if(this.isASCII(e,t))return Y(this.parseStringISO(e,t),r);var n=t-e,i="("+n+" byte)\n";n>(r/=2)&&(t=e+r);for(var o=e;o<t;++o)i+=this.hexByte(this.get(o));return n>r&&(i+="…"),i}parseOID(e,t,r){for(var n="",i=new F,o=0,s=e;s<t;++s){var a=this.get(s);if(i.mulAdd(128,127&a),o+=7,!(128&a)){if(""===n)if((i=i.simplify())instanceof F)i.sub(80),n="2."+i.toString();else{var u=i<80?i<40?0:1:2;n=u+"."+(i-40*u)}else n+="."+i.toString();if(n.length>r)return Y(n,r);i=new F,o=0}}return o>0&&(n+=".incomplete"),n}}class z{constructor(e,t,r,n,i){if(!(n instanceof Q))throw new Error("Invalid tag value.");this.stream=e,this.header=t,this.length=r,this.tag=n,this.sub=i}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(e){if(void 0===this.tag)return null;void 0===e&&(e=1/0);var t=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(t)?"false":"true";case 2:return this.stream.parseInteger(t,t+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+r,e);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);case 6:return this.stream.parseOID(t,t+r,e);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return Y(this.stream.parseStringUTF(t,t+r),e);case 18:case 19:case 20:case 21:case 22:case 26:return Y(this.stream.parseStringISO(t,t+r),e);case 30:return Y(this.stream.parseStringBMP(t,t+r),e);case 23:case 24:return this.stream.parseTime(t,t+r,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(e){void 0===e&&(e="");var t=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(t+=" (encapsulates)"),t+="\n",null!==this.sub){e+=" ";for(var r=0,n=this.sub.length;r<n;++r)t+=this.sub[r].toPrettyString(e)}return t}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(e){var t=e.get(),r=127&t;if(r==t)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(e.pos-1));if(0===r)return null;t=0;for(var n=0;n<r;++n)t=256*t+e.get();return t}getHexStringValue(){var e=this.toHexString(),t=2*this.header,r=2*this.length;return e.substr(t,r)}static decode(e){var t;t=e instanceof K?e:new K(e,0);var r=new K(t),n=new Q(t),i=z.decodeLength(t),o=t.pos,s=o-r.pos,a=null,u=function(){var e=[];if(null!==i){for(var r=o+i;t.pos<r;)e[e.length]=z.decode(t);if(t.pos!=r)throw new Error("Content size is not correct for container starting at offset "+o)}else try{for(;;){var n=z.decode(t);if(n.tag.isEOC())break;e[e.length]=n}i=o-t.pos}catch(e){throw new Error("Exception while decoding undefined length content: "+e)}return e};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=t.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(e){a=null}if(null===a){if(null===i)throw new Error("We can't skip over an invalid tag with undefined length at offset "+o);t.pos=o+Math.abs(i)}return new z(r,s,i,n,a)}}class Q{constructor(e){var t=e.get();if(this.tagClass=t>>6,this.tagConstructed=!!(32&t),this.tagNumber=31&t,31==this.tagNumber){var r=new F;do{t=e.get(),r.mulAdd(128,127&t)}while(128&t);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var f=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],v=(1<<26)/f[f.length-1];class J{constructor(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}toString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,i=!1,o="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(i=!0,o=x(r));s>=0;)a<t?(r=(this[s]&(1<<a)-1)<<t-a,r|=this[--s]>>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=x(r));return i?o:"0"}negate(){var e=Z();return J.ZERO.subTo(this,e),e}abs(){return this.s<0?this.negate():this}compareTo(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+ie(this[this.t-1]^this.s&this.DM)}mod(e){var t=Z();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(J.ZERO)>0&&e.subTo(t,t),t}modPowInt(e,t){var r;return r=e<256||t.isEven()?new y(t):new m(t),this.exp(e,r)}clone(){var e=Z();return this.copyTo(e),e}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var e=this.t,t=[];t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n<this.DB&&(r=this[e]>>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this[e]&(1<<n)-1)<<8-n,r|=this[--e]>>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),128&r&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t}equals(e){return 0==this.compareTo(e)}min(e){return this.compareTo(e)<0?this:e}max(e){return this.compareTo(e)>0?this:e}and(e){var t=Z();return this.bitwiseTo(e,M,t),t}or(e){var t=Z();return this.bitwiseTo(e,j,t),t}xor(e){var t=Z();return this.bitwiseTo(e,V,t),t}andNot(e){var t=Z();return this.bitwiseTo(e,B,t),t}not(){for(var e=Z(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e}shiftLeft(e){var t=Z();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}shiftRight(e){var t=Z();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}getLowestSetBit(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+q(this[e]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=H(this[r]^t);return e}testBit(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)}setBit(e){return this.changeBit(e,j)}clearBit(e){return this.changeBit(e,B)}flipBit(e){return this.changeBit(e,V)}add(e){var t=Z();return this.addTo(e,t),t}subtract(e){var t=Z();return this.subTo(e,t),t}multiply(e){var t=Z();return this.multiplyTo(e,t),t}divide(e){var t=Z();return this.divRemTo(e,t,null),t}remainder(e){var t=Z();return this.divRemTo(e,null,t),t}divideAndRemainder(e){var t=Z(),r=Z();return this.divRemTo(e,t,r),[t,r]}modPow(e,t){var r,n,i=e.bitLength(),o=ne(1);if(i<=0)return o;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new y(t):t.isEven()?new _(t):new m(t);var s=[],a=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var h=Z();for(n.sqrTo(s[1],h);a<=c;)s[a]=Z(),n.mulTo(h,s[a-2],s[a]),a+=2}var l,d,p=e.t-1,f=!0,v=Z();for(i=ie(e[p])-1;p>=0;){for(i>=u?l=e[p]>>i-u&c:(l=(e[p]&(1<<i+1)-1)<<u-i,p>0&&(l|=e[p-1]>>this.DB+i-u)),a=r;!(1&l);)l>>=1,--a;if((i-=a)<0&&(i+=this.DB,--p),f)s[l].copyTo(o),f=!1;else{for(;a>1;)n.sqrTo(o,v),n.sqrTo(v,o),a-=2;a>0?n.sqrTo(o,v):(d=o,o=v,v=d),n.mulTo(v,s[l],o)}for(;p>=0&&!(e[p]&1<<i);)n.sqrTo(o,v),d=o,o=v,v=d,--i<0&&(i=this.DB-1,--p)}return n.revert(o)}modInverse(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return J.ZERO;for(var r=e.clone(),n=this.clone(),i=ne(1),o=ne(0),s=ne(0),a=ne(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(i.isEven()&&o.isEven()||(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),t&&s.subTo(i,s),a.subTo(o,a))}return 0!=n.compareTo(J.ONE)?J.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a}pow(e){return this.exp(e,new g)}gcd(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i<o&&(o=i),o>0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r}isProbablePrime(e){var t,r=this.abs();if(1==r.t&&r[0]<=f[f.length-1]){for(t=0;t<f.length;++t)if(r[0]==f[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<f.length;){for(var n=f[t],i=t+1;i<f.length&&n<v;)n*=f[i++];for(n=r.modInt(n);t<i;)if(n%f[t++]==0)return!1}return r.millerRabin(e)}copyTo(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}fromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}fromString(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,o=0;--n>=0;){var s=8==r?255&+e[n]:re(e,n);s<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<<this.DB-o)-1)<<o,this[this.t++]=s>>this.DB-o):this[this.t-1]|=s<<o,(o+=r)>=this.DB&&(o-=this.DB))}8==r&&128&+e[0]&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),i&&J.ZERO.subTo(this,this)}clamp(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t}dlShiftTo(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s}drShiftTo(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s}lShiftTo(e,t){for(var r=e%this.DB,n=this.DB-r,i=(1<<n)-1,o=Math.floor(e/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)t[a+o+1]=this[a]>>n|s,s=(this[a]&i)<<r;for(a=o-1;a>=0;--a)t[a]=0;t[o]=s,t.t=this.t+o+1,t.s=this.s,t.clamp()}rShiftTo(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<<n)-1;t[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)t[s-r-1]|=(this[s]&o)<<i,t[s-r]=this[s]>>n;n>0&&(t[this.t-r-1]|=(this.s&o)<<i),t.t=this.t-r,t.clamp()}}subTo(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]-e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e[r],t[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()}multiplyTo(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i<n.t;++i)t[i+r.t]=r.am(0,n[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&J.ZERO.subTo(t,t)}squareTo(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()}divRemTo(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=Z());var o=Z(),s=this.s,a=e.s,u=this.DB-ie(n[n.t-1]);u>0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var c=o.t,h=o[c-1];if(0!=h){var l=h*(1<<this.F1)+(c>1?o[c-2]>>this.F2:0),d=this.FV/l,p=(1<<this.F1)/l,f=1<<this.F2,v=r.t,g=v-c,y=null==t?Z():t;for(o.dlShiftTo(g,y),r.compareTo(y)>=0&&(r[r.t++]=1,r.subTo(y,r)),J.ONE.dlShiftTo(c,y),y.subTo(o,o);o.t<c;)o[o.t++]=0;for(;--g>=0;){var m=r[--v]==h?this.DM:Math.floor(r[v]*d+(r[v-1]+f)*p);if((r[v]+=o.am(0,m,r,g,0,c))<m)for(o.dlShiftTo(g,y),r.subTo(y,r);r[v]<--m;)r.subTo(y,r)}null!=t&&(r.drShiftTo(c,t),s!=a&&J.ZERO.subTo(t,t)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&&J.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(e,t){if(e>4294967295||e<1)return J.ONE;var r=Z(),n=Z(),i=t.convert(this),o=ie(e)-1;for(i.copyTo(r);--o>=0;)if(t.sqrTo(r,n),(e&1<<o)>0)t.mulTo(n,i,r);else{var s=r;r=n,n=s}return t.revert(r)}chunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}toRadix(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=ne(r),i=Z(),o=Z(),s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(e)+s}fromRadix(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,s=0,a=0;a<e.length;++a){var u=re(e,a);u<0?"-"==e.charAt(a)&&0==this.signum()&&(i=!0):(s=t*s+u,++o>=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(s,0)),i&&J.ZERO.subTo(this,this)}fromNumber(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(J.ONE.shiftLeft(e-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(J.ONE.shiftLeft(e-1),this);else{var n=[],i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(e,t,r){var n,i,o=Math.min(e.t,this.t);for(n=0;n<o;++n)r[n]=t(this[n],e[n]);if(e.t<this.t){for(i=e.s&this.DM,n=o;n<this.t;++n)r[n]=t(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=o;n<e.t;++n)r[n]=t(i,e[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()}changeBit(e,t){var r=J.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r}addTo(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]+e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e[r],t[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()}dMultiply(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}multiplyLowerTo(e,t,r){var n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(var i=r.t-this.t;n<i;++n)r[n+this.t]=this.am(0,e[n],r,n,0,this.t);for(i=Math.min(e.t,t);n<i;++n)this.am(0,e[n],r,n,0,t-n);r.clamp()}multiplyUpperTo(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r[this.t+n-t]=this.am(t-n,e[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)}modInt(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r}millerRabin(e){var t=this.subtract(J.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>f.length&&(e=f.length);for(var i=Z(),o=0;o<e;++o){i.fromInt(f[Math.floor(Math.random()*f.length)]);var s=i.modPow(n,this);if(0!=s.compareTo(J.ONE)&&0!=s.compareTo(t)){for(var a=1;a++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(J.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0}square(){var e=Z();return this.squareTo(e),e}gcda(e,t){var r=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(r.compareTo(n)<0){var i=r;r=n,n=i}var o=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)t(r);else{o<s&&(s=o),s>0&&(r.rShiftTo(s,r),n.rShiftTo(s,n));var a=()=>{(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),(o=n.getLowestSetBit())>0&&n.rShiftTo(o,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n)),r.signum()>0?setTimeout(a,0):(s>0&&n.lShiftTo(s,n),setTimeout(function(){t(n)},0))};setTimeout(a,10)}}fromNumberAsync(e,t,r,n){if("number"==typeof t)if(e<2)this.fromInt(1);else{this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(J.ONE.shiftLeft(e-1),j,this),this.isEven()&&this.dAddOffset(1,0);var i=this,o=function(){i.dAddOffset(2,0),i.bitLength()>e&&i.subTo(J.ONE.shiftLeft(e-1),i),i.isProbablePrime(t)?setTimeout(function(){n()},0):setTimeout(o,0)};setTimeout(o,0)}else{var s=[],a=7&e;s.length=1+(e>>3),t.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var g=function(){function e(){}return e.prototype.convert=function(e){return e},e.prototype.revert=function(e){return e},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},e.prototype.sqrTo=function(e,t){e.squareTo(t)},e}(),y=function(){function e(e){this.m=e}return e.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),m=function(){function e(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}return e.prototype.convert=function(e){var t=Z();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(J.ZERO)>0&&this.m.subTo(t,t),t},e.prototype.revert=function(e){var t=Z();return e.copyTo(t),this.reduce(t),t},e.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],n=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),_=function(){function e(e){this.m=e,this.r2=Z(),this.q3=Z(),J.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e)}return e.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=Z();return e.copyTo(t),this.reduce(t),t},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}();function Z(){return new J(null)}function X(e,t){return new J(e,t)}function $(e,t,r,n,i,o){for(;--o>=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i}function ee(e,t,r,n,i,o){for(var s=32767&t,a=t>>15;--o>=0;){var u=32767&this[e],c=this[e++]>>15,h=a*u+c*s;i=((u=s*u+((32767&h)<<15)+r[n]+(1073741823&i))>>>30)+(h>>>15)+a*c+(i>>>30),r[n++]=1073741823&u}return i}function te(e,t,r,n,i,o){for(var s=16383&t,a=t>>14;--o>=0;){var u=16383&this[e],c=this[e++]>>14,h=a*u+c*s;i=((u=s*u+((16383&h)<<14)+r[n]+i)>>28)+(h>>14)+a*c,r[n++]=268435455&u}return i}void 0!==i&&"Microsoft Internet Explorer"==(null==i?void 0:i.appName)?(J.prototype.am=ee,l=30):"Netscape"!=(null==i?void 0:i.appName)?(J.prototype.am=$,l=26):(J.prototype.am=te,l=28),J.prototype.DB=l,J.prototype.DM=(1<<l)-1,J.prototype.DV=1<<l,J.prototype.FV=Math.pow(2,52),J.prototype.F1=52-l,J.prototype.F2=2*l-52;var E,b,I=[];for(E="0".charCodeAt(0),b=0;b<=9;++b)I[E++]=b;for(E="a".charCodeAt(0),b=10;b<36;++b)I[E++]=b;for(E="A".charCodeAt(0),b=10;b<36;++b)I[E++]=b;function re(e,t){var r=I[e.charCodeAt(t)];return null==r?-1:r}function ne(e){var t=Z();return t.fromInt(e),t}function ie(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}J.ZERO=ne(0),J.ONE=ne(1);class oe{constructor(){this.i=0,this.j=0,this.S=[]}init(e){var t,r,n;for(t=0;t<256;++t)this.S[t]=t;for(r=0,t=0;t<256;++t)r=r+this.S[t]+e[t%e.length]&255,n=this.S[t],this.S[t]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]}}var A,w,T=null;if(null==T){T=[],w=0;var S,O,P=void 0;if("undefined"!=typeof window&&null!==(S=window)&&void 0!==S&&S.crypto&&null!==(O=window)&&void 0!==O&&O.crypto.getRandomValues){var R,C=new Uint32Array(256);for(null===(R=window)||void 0===R||R.crypto.getRandomValues(C),P=0;P<C.length;++P)T[w++]=255&C[P]}var U,N,D,L=function(e){var t,r,n;if(this.count=this.count||0,this.count>=256||w>=256){if("undefined"!=typeof window)if(null!==(t=window)&&void 0!==t&&t.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",L,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var i;null===(i=window)||void 0===i||i.detachEvent("onmousemove",L)}}else try{var o=e.x+e.y;T[w++]=255&o,this.count+=1}catch(e){}};if("undefined"!=typeof window)if(null!==(U=window)&&void 0!==U&&U.addEventListener)null===(D=window)||void 0===D||D.addEventListener("mousemove",L,!1);else if(null!==(N=window)&&void 0!==N&&N.attachEvent){var k;null===(k=window)||void 0===k||k.attachEvent("onmousemove",L)}}function se(){if(null==A){for(A=new oe;w<256;){var e=Math.floor(65536*Math.random());T[w++]=255&e}for(A.init(T),w=0;w<T.length;++w)T[w]=0;w=0}return A.next()}class ae{constructor(){}nextBytes(e){for(var t=0;t<e.length;++t)e[t]=se()}}function ue(e,t){if(t<e.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=e.length-1;n>=0&&t>0;){var i=e.charCodeAt(n--);i<128?r[--t]=i:i>127&&i<2048?(r[--t]=63&i|128,r[--t]=i>>6|192):(r[--t]=63&i|128,r[--t]=i>>6&63|128,r[--t]=i>>12|224)}r[--t]=0;for(var o=new ae,s=[];t>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);r[--t]=s[0]}return r[--t]=2,r[--t]=0,new J(r)}class ce{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(e){return e.modPowInt(this.e,this.n)}doPrivate(e){if(null==this.p||null==this.q)return e.modPow(this.d,this.n);for(var t=e.mod(this.p).modPow(this.dmp1,this.p),r=e.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(r)<0;)t=t.add(this.p);return t.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(e,t){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=X(e,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")}encrypt(e){var t=ue(e,this.n.bitLength()+7>>3);if(null==t)return null;var r=this.doPublic(t);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n}encryptLong(e){var t=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return e.length>r?(e.match(/.{1,117}/g).forEach(function(e){var r=t.encrypt(e);n+=r}),W(n)):W(this.encrypt(e))}catch(e){return!1}}decryptLong(e){var t=this,r=this.n.bitLength()+7>>3;e=G(e);try{if(e.length>r){var n="";return e.match(/.{1,256}/g).forEach(function(e){var r=t.decrypt(e);n+=r}),n}return this.decrypt(e)}catch(e){return!1}}setPrivate(e,t,r){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=X(e,16),this.e=parseInt(t,16),this.d=X(r,16)):console.error("Invalid RSA private key")}setPrivateEx(e,t,r,n,i,o,s,a){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=X(e,16),this.e=parseInt(t,16),this.d=X(r,16),this.p=X(n,16),this.q=X(i,16),this.dmp1=X(o,16),this.dmq1=X(s,16),this.coeff=X(a,16)):console.error("Invalid RSA private key")}generate(e,t){var r=new ae,n=e>>1;this.e=parseInt(t,16);for(var i=new J(t,16);;){for(;this.p=new J(e-n,1,r),0!=this.p.subtract(J.ONE).gcd(i).compareTo(J.ONE)||!this.p.isProbablePrime(10););for(;this.q=new J(n,1,r),0!=this.q.subtract(J.ONE).gcd(i).compareTo(J.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var s=this.p.subtract(J.ONE),a=this.q.subtract(J.ONE),u=s.multiply(a);if(0==u.gcd(i).compareTo(J.ONE)){this.n=this.p.multiply(this.q),this.d=i.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(e){var t=X(e,16),r=this.doPrivate(t);return null==r?null:he(r,this.n.bitLength()+7>>3)}generateAsync(e,t,r){var n=new ae,i=e>>1;this.e=parseInt(t,16);var o=new J(t,16),s=this,a=()=>{var t=()=>{if(s.p.compareTo(s.q)<=0){var e=s.p;s.p=s.q,s.q=e}var t=s.p.subtract(J.ONE),n=s.q.subtract(J.ONE),i=t.multiply(n);0==i.gcd(o).compareTo(J.ONE)?(s.n=s.p.multiply(s.q),s.d=o.modInverse(i),s.dmp1=s.d.mod(t),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout(function(){r()},0)):setTimeout(a,0)},u=()=>{s.q=Z(),s.q.fromNumberAsync(i,1,n,function(){s.q.subtract(J.ONE).gcda(o,function(e){0==e.compareTo(J.ONE)&&s.q.isProbablePrime(10)?setTimeout(t,0):setTimeout(u,0)})})},c=()=>{s.p=Z(),s.p.fromNumberAsync(e-i,1,n,function(){s.p.subtract(J.ONE).gcda(o,function(e){0==e.compareTo(J.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)})})};setTimeout(c,0)};setTimeout(a,0)}}function he(e,t){for(var r=e.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=t-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var i="";++n<r.length;){var o=255&r[n];o<128?i+=String.fromCharCode(o):o>191&&o<224?(i+=String.fromCharCode((31&o)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&o)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}class le extends ce{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),e&&("string"==typeof e?this.parseKey(e):(this.hasPrivateKeyProperty(e)||this.hasPublicKeyProperty(e))&&this.parsePropertiesFrom(e))}parseKey(e){try{var t=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(e)?u.decode(e):c.unarmor(e),i=z.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){t=i.sub[1].getHexStringValue(),this.n=X(t,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var o=i.sub[3].getHexStringValue();this.d=X(o,16);var s=i.sub[4].getHexStringValue();this.p=X(s,16);var a=i.sub[5].getHexStringValue();this.q=X(a,16);var h=i.sub[6].getHexStringValue();this.dmp1=X(h,16);var l=i.sub[7].getHexStringValue();this.dmq1=X(l,16);var d=i.sub[8].getHexStringValue();this.coeff=X(d,16)}else{if(2!==i.sub.length)return!1;var p=i.sub[1].sub[0];t=p.sub[0].getHexStringValue(),this.n=X(t,16),r=p.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(e){return!1}}hasPublicKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")}hasPrivateKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")}parsePropertiesFrom(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)}}(n=function(e){e=e||{},this.default_key_size=parseInt(e.default_key_size,10)||1024,this.default_public_exponent=e.default_public_exponent||"010001",this.log=e.log||!1,this.key=null}).prototype.setKey=function(e){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new le(e)},n.prototype.setPrivateKey=function(e){this.setKey(e)},n.prototype.setPublicKey=function(e){this.setKey(e)},n.prototype.decrypt=function(e){try{return this.getKey().decrypt(G(e))}catch(e){return!1}},n.prototype.encrypt=function(e){try{return W(this.getKey().encrypt(e))}catch(e){return!1}},n.prototype.encryptLong=function(e){try{for(var t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",n=0,i=/null$/g;i.test(r)&&(n++,t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",!(n>10)););return t}catch(e){return!1}},n.prototype.getKey=function(e){if(!this.key){if(this.key=new le,e&&"[object Function]"==={}.toString.call(e))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}t.default=n},182:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(274)),c=r(616);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,i=(0,c.isArray)(e)?e:[e];r<i.length;r++){var o=i[r],s=o.isMatch,a=o.genAdapter,u=o.runtime;if(s())return{adapter:n({isMatch:s},a(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},274:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},o.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(764),c=r(616),h=r(946),l=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,i=t.timeoutMsg,o=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=i||"请求超时",r.restrictedMethods=o||["get","post","upload","download"],r}return i(t,e),t.prototype.get=function(e){return this.request(o(o({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(o(o({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(o(o({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,i=e.method,s=e.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==i?void 0:i.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(t).forEach(function(e){c.append(e,t[e])}),c.append("key",n),c.append("file",r),this.request(o(o({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(o(o({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,function(){var t,r,n,i;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(o(o({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(i=document.createElement("a")).href=r,i.setAttribute("download",n),i.style.display="none",document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(r),document.body.removeChild(i),[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.fetch=function(e){var t;return s(this,void 0,void 0,function(){var r,n,i,u,c,h,l,d,p,f,v,g,y,m=this;return a(this,function(_){switch(_.label){case 0:return r=new AbortController,n=e.url,i=e.enableAbort,u=void 0!==i&&i,c=e.stream,h=void 0!==c&&c,l=e.signal,d=e.timeout,p=e.shouldThrowOnError,f=void 0===p||p,v=null!=d?d:this.timeout,l&&(l.aborted&&r.abort(),l.addEventListener("abort",function(){return r.abort()})),g=null,u&&v&&(g=setTimeout(function(){console.warn(m.timeoutMsg),r.abort(new Error(m.timeoutMsg))},v)),[4,fetch(n,o(o({},e),{signal:r.signal})).then(function(e){return s(m,void 0,void 0,function(){var t,r,n;return a(this,function(i){switch(i.label){case 0:return clearTimeout(g),f?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[i.sent()]),i.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(g),Promise.reject(e)})];case 1:return y=_.sent(),[2,{data:h?y.body:(null===(t=y.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?y.json():y.text(),statusCode:y.status,header:y.headers,response:y}]}})})},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise(function(i){var o=e.url,s=e.headers,a=void 0===s?{}:s,u=e.data,l=e.responseType,d=e.withCredentials,p=e.body,f=e.onUploadProgress,v=(0,c.formatUrl)((0,h.getProtocol)(),o,"get"===n?u:{}),g=new XMLHttpRequest;g.open(n,v),l&&(g.responseType=l);var y,m,_=e.signal;_&&(_.aborted?g.abort():_.addEventListener("abort",function(){return g.abort()},{once:!0})),Object.keys(a).forEach(function(e){g.setRequestHeader(e,a[e])}),f&&g.upload.addEventListener("progress",f),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach(function(e){var t=e.split(": "),n=t.shift().toLowerCase(),i=t.join(": ");r[n]=i}),e.header=r,e.statusCode=g.status;try{e.data="blob"===l?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===l?g.response:g.responseText}clearTimeout(y),i(e)}},t&&r.timeout&&(y=setTimeout(function(){console.warn(r.timeoutMsg),g.abort()},r.timeout)),m=(0,c.isFormData)(u)?u:"application/x-www-form-urlencoded"===a["content-type"]?(0,c.toQueryString)(u):p||(u?JSON.stringify(u):void 0),d&&(g.withCredentials=!0),g.send(m)})},t}(u.AbstractSDKRequest);t.WebRequest=l,t.genAdapter=function(){return{type:"default",root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},946:function(e,t){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 n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},205:function(e,t){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"}},794:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,i(r(946),t),i(r(205),t),t.OATUH_LOGINTYPE="constants"},718:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var o=r(616),s=r(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function h(e){var t=e.err,r=e.className,n=e.methodName,i=e.sourceLink;if(!i)return null;var o,s=t.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),h=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),l=s.findIndex(function(e){return u.test(e)});if(-1!==l){var d=s.filter(function(e,t){return t>l});d.unshift(s[l].replace(h,"".concat(r,".").concat(n)).replace(c,i)),(o=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return o}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,l=void 0===a?{}:a,d=e.title,p=e.messages,f=void 0===p?[]:p;return function(e,t,a){if(s.IS_DEBUG_MODE){var p=l.className||e.constructor.name,v=l.methodName||t,g=a.value,y=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex(function(e){return u.test(e)});if(-1!==r){var n=c.exec(t[r+1]||"");e=n?n[0]:""}return e}();a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=h({err:new Error,className:p,methodName:v,sourceLink:y});try{return g.apply(this,e)}catch(e){var n=e,i=e.message,s=e.error,a=e.error_description,u={title:d||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:e}]};if(i&&/^\{.*\}$/.test(i)){var c=JSON.parse(i);u.subtitle=i,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=f.map(function(e){return{type:"info",body:e}}))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=f.map(function(e){return{type:"info",body:e}})),(0,o.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,function(){var t,r,n,s,a,u,c,l;return i(this,function(i){switch(i.label){case 0:t=h({err:new Error,className:p,methodName:v,sourceLink:y}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,g.apply(this,e)];case 2:return[2,i.sent()];case 3:throw r=i.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:d||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),c.subtitle=l,l.code&&(t?(t.code=l.code,t.message=l.msg):(r.code=l.code,r.message=l.msg),n=t||r,c.content=f.map(function(e){return{type:"info",body:e}}))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=f.map(function(e){return{type:"info",body:e}})),(0,o.printGroupLog)(c),n;case 4:return[2]}})})}}}}},141:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(718),t)},197:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(764),u=r(616),c=r(794),h=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return i(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}(a.AbstractStorage),l=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,i=e.keys,o=void 0===i?{}:i;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(t.root));case"none":return new h(t.root)}}(this.persistenceTag,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.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return o(this,void 0,void 0,function(){var n;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]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return i.sent(),[3,4];case 3:return i.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return o(this,void 0,void 0,function(){var n;return s(this,function(i){switch(i.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=i.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return o(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]}})})},e}();t.CloudbaseCache=l},689:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(616),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return i(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var i=0,c=this.listeners[n]?o([],this.listeners[n],!0):[];i<c.length;i++)c[i].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var h=new c;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)}},616:function(e,t,r){var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=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.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var i=r(794);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.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)})},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),i="";return Object.keys(r).forEach(function(e){""===i?!n&&(t+="?"):i+="&",i+="".concat(e,"=").concat(encodeURIComponent(r[e]))}),/^http(s)?:\/\//.test(t+=i)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),i=r.substr(r.indexOf("?")+1).match(n);return null!=i?i[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],i=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==i){for(var o=(n=i.split("&")).length-1;o>=0;o-=1)n[o].split("=")[0]===e&&n.splice(o,1);r="".concat(r,"?").concat(n.join("&"))}return r},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 r=new Promise(function(t,r){e=function(e,n){return e?r(e):t(n)}});return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,i=void 0===n?"":n,o=e.content,s=void 0===o?[]:o,a=e.printTrace,u=void 0!==a&&a,c=e.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,i):(console.group||console.error)(r,i);for(var h=0,l=s;h<l.length;h++){var d=l[h],p=d.type,f=d.body;switch(p){case"info":console.log(f);break;case"warn":console.warn(f);break;case"error":console.error(f)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var r=e.split("="),n=r[0],i=r[1];n=decodeURIComponent(n),i=decodeURIComponent(i),n&&(t[n]?Array.isArray(t[n])?t[n].push(i):t[n]=[t[n],i]:t[n]=i)}),t},t.parseCaptcha=function(e){var r={},i=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){e=i[1];var o=i[2];o&&(r=(0,t.parseQueryString)(o))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},764:function(e){e.exports=require("@cloudbase/adapter-interface")},917:function(e){e.exports=require("@cloudbase/adapter-wx_mp")},107:function(e){e.exports=require("jwt-decode")}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e].call(o.exports,o,o.exports,i),o.exports}t=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},i.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var o=Object.create(null);i.r(o);var s={};e=e||[null,t({}),t([]),t(t)];for(var a=2&n&&r;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach(function(e){s[e]=function(){return r[e]}});return s.default=function(){return r},i.d(o,s),o},i.d=function(e,t){for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o=i(304);module.exports=o}();
|
|
2
|
+
!function(){"use strict";var e,t,r={548:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.useAuthAdapter=void 0;var s=r(19),a=function(){function e(e){var t,r;try{this.localStorage=(null==e?void 0:e.localStorage)||((null===(r=null===(t=null==e?void 0:e.adapter)||void 0===t?void 0:t.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(t){this.localStorage=(null==e?void 0:e.localStorage)||{}}}return e.prototype.getItem=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.localStorage.getItem(e)]})})},e.prototype.removeItem=function(e){return i(this,void 0,void 0,function(){return o(this,function(t){return this.localStorage.removeItem(e),[2]})})},e.prototype.setItem=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(r){return this.localStorage.setItem(e,t),[2]})})},e.prototype.getItemSync=function(e){return this.localStorage.getItem(e)},e.prototype.setItemSync=function(e,t){this.localStorage.setItem(e,t)},e.prototype.removeItemSync=function(e){this.localStorage.removeItem(e)},e}(),u=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,c=function(e,t){var r,n,i,o,s=null===(r=null==t?void 0:t.headers)||void 0===r?void 0:r["x-request-id"];return e||(e={}),((null==e?void 0:e.code)||(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.error_code))&&(e={error:e.code||e.data.error,error_description:e.data.error_description||e.message||e.code||e.data.error_code,request_id:e.requestId,error_code:null===(i=e.data)||void 0===i?void 0:i.error_code}),(null==e?void 0:e.request_id)||(e.request_id=e.request_id||s),(null==e?void 0:e.error)?(e.error_uri=(o=null==t?void 0:t.url,u.test(o)?RegExp.$1:o),e):(null==e?void 0:e.data)||{}};t.useAuthAdapter=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var r=n({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(r.storage=new a({localStorage:t.localStorage,adapter:t})),!e.captchaOptions&&(null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!e.baseRequest&&!e.request&&(null==t?void 0:t.reqClass)){var s={timeout:1e4,restrictedMethods:["get","post","upload","download","request"],auth:e.auth},u=new t.reqClass(s);r.baseRequest=function(e,t){var r,s,a,h,l;return i(this,void 0,void 0,function(){var i,d,p,f;return o(this,function(o){switch(o.label){case 0:if(i={},d=(null===(r=t.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(p=null===(a=null===(s=null==u?void 0:u[d])||void 0===s?void 0:s.bind)||void 0===a?void 0:a.call(s,u)))throw new Error("invalid 【".concat(d,"】 request method"));o.label=1;case 1:return o.trys.push([1,3,,4]),(null===(h=t.headers)||void 0===h?void 0:h["content-type"])&&!(null===(l=t.headers)||void 0===l?void 0:l["content-type"].includes("application/json"))||["string","undefined"].includes(typeof t.body)||(t.data=t.data||t.body,t.body=JSON.stringify(t.body)),[4,p(n({url:e},t))];case 2:return i=o.sent(),i=c(i,n(n({},t),{url:e})),[3,4];case 3:throw f=o.sent(),i=n(n({},null==f?void 0:f.data),f);case 4:if(null==i?void 0:i.error)throw i;return[2,i]}})})}}}catch(e){console.error("user adapter generate fail:",e)}return r}(e,e.adapter):function(e,t){var r=n({},e),u={};if((null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!s.adapterForWxMp.isMatch()||e.storage&&e.baseRequest)return r;try{var h=s.adapterForWxMp.genAdapter({}),l=h.localStorage,d=h.reqClass;if(l&&(u.storage=new a({localStorage:l,adapter:t})),d){var p=new d({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});u.request=function(e){return function(t,r){return i(this,void 0,void 0,function(){return o(this,function(i){return[2,new Promise(function(i,o){var s=Object.assign({},r);s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));var a=wx.request({url:t,data:s.body,timeout:e._timeout,method:s.method||"GET",header:s.headers,success:function(e){(e=c(e,n(n({},r),{url:t}))).error&&o(e),i(e)},fail:function(e){o({error:"unreachable",error_description:e.message})},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("request")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{a.abort()}catch(e){}}}})})]})})}}(p)}return r.captchaOptions&&(u.baseRequest=u.request,u.request=void 0),n(n({},r),u)}catch(e){console.error("adapter generate fail:",e)}return r}(e,e.adapter)}},895:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},o.apply(this,arguments)},s=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},u=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},c=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},h=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=t.AuthError=t.AuthErrorCode=t.AuthErrorCategory=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=t.Auth=t.generateAuthInstance=t.LoginState=t.User=void 0;var l=r(722),d=r(548),p=r(19),f=r(266),v=r(916);Object.defineProperty(t,"WeixinAuthProvider",{enumerable:!0,get:function(){return v.WeixinAuthProvider}}),Object.defineProperty(t,"CustomAuthProvider",{enumerable:!0,get:function(){return v.CustomAuthProvider}}),Object.defineProperty(t,"AnonymousAuthProvider",{enumerable:!0,get:function(){return v.AnonymousAuthProvider}});var g=r(683),y=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},m=t.User=function(){function e(e){var t=e.cache,r=e.oauthInstance;this.cache=t,this.oauthInstance=r,this.setUserInfo()}var t,r,n;return e.prototype.checkLocalInfo=function(){return u(this,void 0,void 0,function(){return c(this,function(e){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]})})},e.prototype.checkLocalInfoAsync=function(){return u(this,void 0,void 0,function(){var e,t,r,n;return c(this,function(i){switch(i.label){case 0:return e=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return e.uid=i.sent(),t=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return t.gender=i.sent(),this.picture=this.getLocalUserInfo("picture"),r=this,[4,this.getLocalUserInfoAsync("email")];case 3:return r.email=i.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),n=this,[4,this.getLocalUserInfoAsync("username")];case 4:return n.username=i.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}})})},e.prototype.update=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(o({},e))];case 1:return t=r.sent(),this.setLocalUserInfo(t),[2]}})})},e.prototype.updateUserBasicInfo=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(o({},e))];case 1:return t.sent(),[4,this.refresh()];case 2:return t.sent(),[2]}})})},e.prototype.updatePassword=function(e,t){return this.oauthInstance.authApi.updatePasswordByOld({old_password:t,new_password:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&(0,p.throwError)(p.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(e)];case 1:if("INVALID_ACCESS_TOKEN"===(t=r.sent()).code)throw this.setLocalUserInfo({}),t;return this.setLocalUserInfo(t),[2,t]}})})},e.prototype.getLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);return e?r[e]:r||{}},e.prototype.setLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey;this.cache.setStore(t,e),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(t)];case 1:return[2,r.sent()[e]]}})})},e.prototype.setUserInfo=function(){var e=this,t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at","open_id"].forEach(function(t){e[t]=r[t]})},s([(0,p.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(t=void 0!==l.authModels&&l.authModels.UserProfile)?t:Object]),a("design:returntype","function"==typeof(r="undefined"!=typeof Promise&&Promise)?r:Object)],e.prototype,"update",null),s([(0,p.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String,String]),a("design:returntype",void 0)],e.prototype,"updatePassword",null),s([(0,p.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype",void 0)],e.prototype,"updateUsername",null),s([(0,p.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(n="undefined"!=typeof Promise&&Promise)?n:Object)],e.prototype,"refresh",null),e}();(0,v.applyUserV1Compat)(m);var _=function(){function e(e){var t=e.envId,r=e.cache,n=e.oauthInstance;t||(0,p.throwError)(p.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new m({cache:this.cache,oauthInstance:n})}return e.prototype.checkLocalState=function(){var e;this.oauthLoginState=null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},e.prototype.checkLocalStateAsync=function(){var e;return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.getLoginState()];case 1:return t.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return t.sent(),[2]}})})},e}();t.LoginState=_;var E=function(e){function t(t){var r=e.call(this)||this;return r.listeners=new Map,r.hasListenerSetUp=!1,r.config=t,r.oauthInstance=t.oauthInstance,r.cache=t.cache,r.init(),r.setAccessKey(),r}var r,n,d,v,m,E,b,I,A,w,T,S,O,P,R,C,U,N,D,L,k;return i(t,e),t.prototype.signInAnonymously=function(e){return u(this,void 0,Promise,function(){var t,r,n,i,s;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];case 1:return a.sent(),[4,this.createLoginState()];case 2:return t=a.sent(),[4,this.getSession()];case 3:return r=a.sent().data,n=(void 0===r?{}:r).session,[2,o(o({},t),{data:{user:n.user,session:n},error:null})];case 4:return i=a.sent(),(s=new l.AuthError(i,{method:"signInAnonymously"})).category===l.AuthErrorCategory.PROVIDER_NOT_ENABLED?(console.error(s.helpMessage),console.error("[CloudBase Auth] 提示:匿名登录需要在控制台开启「匿名登录」。\n 如果您需要使用用户名密码登录,请改用 auth.signInWithPassword({ username, password })。\n 不要在匿名登录失败后自动回退到密码登录,这两种方式的使用场景不同。")):(console.warn("[CloudBase Auth] signInAnonymously 失败 [".concat(s.category,"]: ").concat(s.message)),s.loginMethodHint&&console.warn(s.loginMethodHint)),[2,{data:{user:null,session:null},error:s}];case 5:return[2]}})})},t.prototype.signUp=function(e){return u(this,void 0,Promise,function(){var t,r,n=this;return c(this,function(i){switch(i.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?(e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[4,this.oauthInstance.authApi.signUp(e)]):[3,2];case 1:return i.sent(),[2,this.createLoginState()];case 2:return i.trys.push([2,4,,5]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email,usage:l.VerificationUsage.EMAIL}:{phone_number:this.formatPhone(e.phone)})];case 3:return t=i.sent(),[2,{data:{verifyOtp:function(r){var i=r.token,s=r.messageId,a=void 0===s?t.verification_id:s;return u(n,void 0,Promise,function(){var r,n,s,u,h;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.verify({verification_id:a||t.verification_id,verification_code:String(i)})];case 1:return r=c.sent(),t.is_user?[4,this.signIn({username:e.email||this.formatPhone(e.phone),verification_token:r.verification_token})]:[3,3];case 2:return c.sent(),[3,6];case 3:return delete(n=JSON.parse(JSON.stringify(e))).email,delete n.phone,[4,this.oauthInstance.authApi.signUp(o(o(o({},n),e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}),{verification_token:r.verification_token,verification_code:i}))];case 4:return c.sent(),[4,this.createLoginState()];case 5:c.sent(),c.label=6;case 6:return[4,this.getSession()];case 7:return s=c.sent().data,[2,{data:{user:(u=(void 0===s?{}:s).session).user,session:u},error:null}];case 8:return h=c.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(h,{method:"signUp"})}];case 9:return[2]}})})}},error:null}];case 4:return r=i.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(r,{method:"signUp"})}];case 5:return[2]}})})},t.prototype.signOut=function(e){var t,r;return u(this,void 0,Promise,function(){var n,i,s;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),n=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return i=a.sent(),[4,this.cache.removeStoreAsync(n)];case 2:return a.sent(),this.setAccessKey(),null===(t=this.config.eventBus)||void 0===t||t.fire(l.EVENTS.LOGIN_STATE_CHANGED,{eventType:l.LOGIN_STATE_CHANGED_TYPE.SIGN_OUT}),null===(r=this.config.eventBus)||void 0===r||r.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT}),[2,o(o({},i),{data:{},error:null})];case 3:return s=a.sent(),[2,{data:{},error:new l.AuthError(s,{method:"signOut"})}];case 4:return[2]}})})},t.prototype.onAuthStateChange=function(e){var t=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var r=Math.random().toString(36);return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(e),{data:{subscription:{id:r,callback:e,unsubscribe:function(){var n=t.listeners.get(r);n&&(n.delete(e),0===n.size&&t.listeners.delete(r))}}}}},t.prototype.signInWithPassword=function(e){var t,r;return u(this,void 0,Promise,function(){var n,i,s,a,u,h,d,p;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),this.validateAtLeastOne(e,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),n="username"in e?e.username:void 0,i="email"in e?e.email:void 0,s="phone"in e?e.phone:void 0,a=null!==(r=null===(t=e.options)||void 0===t?void 0:t.is_encrypt)&&void 0!==r?r:e.is_encrypt,[4,this.signIn(o({username:n||i||this.formatPhone(s),password:e.password},a?{isEncrypt:!0,version:"v2"}:{}))];case 1:return c.sent(),[4,this.getSession()];case 2:return u=c.sent().data,[2,{data:{user:(h=(void 0===u?{}:u).session).user,session:h},error:null}];case 3:return d=c.sent(),(p=new l.AuthError(d,{method:"signInWithPassword"})).category===l.AuthErrorCategory.PROVIDER_NOT_ENABLED?console.error(p.helpMessage):p.category===l.AuthErrorCategory.INVALID_CREDENTIALS||p.category===l.AuthErrorCategory.USER_NOT_FOUND?console.warn(p.helpMessage):console.warn("[CloudBase Auth] signInWithPassword 失败 [".concat(p.category,"]: ").concat(p.message)),p.loginMethodHint&&console.info(p.loginMethodHint),[2,{data:{user:null,session:null},error:p}];case 4:return[2]}})})},t.prototype.signInWithIdToken=function(e){return u(this,void 0,Promise,function(){var t,r,n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(e,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:e.token})];case 1:return i.sent(),[4,this.getSession()];case 2:return t=i.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=i.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(n,{method:"signInWithIdToken"})}];case 4:return[2]}})})},t.prototype.signInWithOtp=function(e){return u(this,void 0,Promise,function(){var t,r,n,i,s,a=this;return c(this,function(h){switch(h.label){case 0:if(t=e.options,r="email"in e?e.email:void 0,n="phone"in e?e.phone:void 0,!(null==t?void 0:t.emailRedirectTo)&&(void 0===(null==t?void 0:t.shouldCreateUser)||(null==t?void 0:t.shouldCreateUser)))return[2,this.signUp(r?{email:r}:{phone:n})];h.label=1;case 1:return h.trys.push([1,3,,4]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(o(o({email_redirect_to:null==t?void 0:t.emailRedirectTo},r?{email:r,usage:l.VerificationUsage.EMAIL}:{phone_number:this.formatPhone(n)}),{target:(null==t?void 0:t.emailRedirectTo)&&(null==t?void 0:t.shouldCreateUser)?"ANY":"USER"}))];case 2:return i=h.sent(),[2,{data:{user:null,session:null,verifyOtp:function(e){var t=e.token,o=e.messageId,s=void 0===o?i.verification_id:o;return u(a,void 0,Promise,function(){return c(this,function(e){return[2,this.verifyOtp(r?{email:r,token:String(t),messageId:s}:{phone:n,token:String(t),messageId:s})]})})}},error:null}];case 3:return s=h.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(s,{method:"signInWithOtp"})}];case 4:return[2]}})})},t.prototype.verifyOAuth=function(e){return u(this,void 0,Promise,function(){var t,r,n,i,s,a,u,h,d;return c(this,function(c){switch(c.label){case 0:t={},c.label=1;case 1:return c.trys.push([1,7,,8]),r=(null==e?void 0:e.code)||g.utils.getQuery("code"),n=(null==e?void 0:e.state)||g.utils.getQuery("state"),r?n?(i=(0,f.getBrowserSession)(n),t.type=null==i?void 0:i.type,(s=(null==e?void 0:e.provider)||(null==i?void 0:i.provider)||g.utils.getQuery("provider"))?[4,this.grantProviderToken({provider_id:s,provider_redirect_uri:location.origin+location.pathname,provider_code:r})]:[2,{data:o(o({},t),{user:null,session:null,redirectUrl:null}),error:new l.AuthError({message:"Provider is required"})}]):[2,{data:{user:null,session:null,redirectUrl:null},error:new l.AuthError({message:"State is required"})}]:[2,{data:{user:null,session:null,redirectUrl:null},error:new l.AuthError({message:"Code is required"})}];case 2:return a=c.sent().provider_token,u=void 0,i.type!==l.OAUTH_TYPE.BIND_IDENTITY?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:a,provider:s,fireEvent:!0})];case 3:return u=c.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:a})];case 5:(u=c.sent()).data=o(o({},t),u.data),c.label=6;case 6:return(h=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),h.delete("state"),u.data.redirectUrl=(0,f.addUrlSearch)(void 0===(null==i?void 0:i.search)?"?".concat(h.toString()):null==i?void 0:i.search,(null==i?void 0:i.hash)||location.hash),(0,f.removeBrowserSession)(n),[2,u];case 7:return d=c.sent(),[2,{data:o(o({},t),{user:null,session:null,redirectUrl:null}),error:new l.AuthError(d,{method:"verifyOAuth"})}];case 8:return[2]}})})},t.prototype.signInWithOAuth=function(e){var t,r,n,i,o;return u(this,void 0,Promise,function(){var s,a,u,h,d,p,v,g,m;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),s=(null===(t=e.options)||void 0===t?void 0:t.redirectTo)||location.href,a=new URL(s),u=a.origin+a.pathname,h=(null===(r=e.options)||void 0===r?void 0:r.state)||"prd-".concat(e.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:e.provider,provider_redirect_uri:u,state:h})];case 1:return d=c.sent().uri,p=decodeURIComponent(d),v=p,(null===(n=e.options)||void 0===n?void 0:n.queryParams)&&(g=new URL(p),Object.entries(e.options.queryParams).forEach(function(e){var t=e[0],r=e[1];g.searchParams.set(t,r)}),v=g.toString()),(0,f.saveToBrowserSession)(h,{provider:e.provider,search:a.search,hash:a.hash,type:(null===(i=e.options)||void 0===i?void 0:i.type)||l.OAUTH_TYPE.SIGN_IN}),y()&&!(null===(o=e.options)||void 0===o?void 0:o.skipBrowserRedirect)&&window.location.assign(v),[2,{data:{url:v,provider:e.provider},error:null}];case 2:return m=c.sent(),[2,{data:{url:null,provider:null},error:new l.AuthError(m,{method:"signInWithOAuth"})}];case 3:return[2]}})})},t.prototype.getClaims=function(){return u(this,void 0,Promise,function(){var e,t;return c(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return e=r.sent().accessToken,[2,{data:(0,l.weAppJwtDecodeAll)(e),error:null}];case 2:return t=r.sent(),[2,{data:{claims:null,header:null,signature:null},error:new l.AuthError(t,{method:"getClaims"})}];case 3:return[2]}})})},t.prototype.resetPasswordForEmail=function(e,t){return u(this,void 0,Promise,function(){var r,n,i,s,a,h,d=this;return c(this,function(p){switch(p.label){case 0:return p.trys.push([0,2,,3]),this.validateParams({emailOrPhone:e},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),r=(t||{}).redirectTo,n=e.includes("@"),i=void 0,n?i={email:e,usage:l.VerificationUsage.RECOVERY}:(s=this.formatPhone(e),i={phone_number:s}),[4,this.getVerification(o(o({},i),{target:"USER"}))];case 1:return a=p.sent(),[2,{data:{updateUser:function(t){return u(d,void 0,Promise,function(){var i,o,s,u;return c(this,function(c){switch(c.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.verify({verification_id:a.verification_id,verification_code:t.nonce})];case 2:return i=c.sent(),[4,this.oauthInstance.authApi.resetPassword({email:n?e:void 0,phone_number:n?void 0:e,new_password:t.password,verification_token:i.verification_token})];case 3:return c.sent(),null===(u=this.config.eventBus)||void 0===u||u.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:n?e:void 0,phone:n?void 0:e,password:t.password})];case 4:return o=c.sent(),r&&y()&&window.location.assign(r),[2,o];case 5:return s=c.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(s,{method:"resetPasswordForEmail"})}];case 6:return[2]}})})}},error:null}];case 2:return h=p.sent(),[2,{data:{updateUser:null},error:new l.AuthError(h,{method:"resetPasswordForEmail"})}];case 3:return[2]}})})},t.prototype.resetPasswordForOld=function(e){return u(this,void 0,Promise,function(){var t,r,n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:e.old_password,new_password:e.new_password})];case 1:return i.sent(),[4,this.getSession()];case 2:return t=i.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=i.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(n,{method:"resetPasswordForOld"})}];case 4:return[2]}})})},t.prototype.verifyOtp=function(e){return u(this,void 0,Promise,function(){var t,r,n,i,o,s,a;return c(this,function(u){switch(u.label){case 0:return u.trys.push([0,6,,7]),t=e.type,r=String(e.token),n="email"in e?e.email:void 0,i="phone"in e?e.phone:void 0,this.validateParams(e,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(t)?[4,this.verify({verification_id:e.messageId,verification_code:r})]:[3,2];case 1:return u.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:e.messageId,is_user:!0},verificationCode:r,username:n||this.formatPhone(i)||"",loginType:n?"email":"phone"})];case 3:u.sent(),u.label=4;case 4:return[4,this.getSession()];case 5:return o=u.sent().data,[2,{data:{user:(s=(void 0===o?{}:o).session).user,session:s},error:null}];case 6:return a=u.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(a,{method:"verifyOtp"})}];case 7:return[2]}})})},t.prototype.getSession=function(){return u(this,void 0,Promise,function(){var e,t,r,n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=i.sent())&&"accessKey"!==e.scope?[4,this.getUser(!1)]:[2,{data:{session:null,user:null},error:null}];case 2:return t=i.sent().data,r=(void 0===t?{}:t).user,[2,{data:{session:o(o({},e),{user:r}),user:r},error:null}];case 3:return n=i.sent(),[2,{data:{session:null,user:null},error:new l.AuthError(n,{method:"getSession"})}];case 4:return[2]}})})},t.prototype.refreshSession=function(e){return u(this,void 0,Promise,function(){var t,r,n,i,s;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(t=a.sent()).refresh_token=e||t.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(t)];case 2:return r=a.sent(),[4,this.getUser(!1)];case 3:return n=a.sent().data,[2,{data:{user:i=(void 0===n?{}:n).user,session:o(o({},r),{user:i})},error:null}];case 4:return s=a.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(s,{method:"refreshSession"})}];case 5:return[2]}})})},t.prototype.getUser=function(e){return void 0===e&&(e=!0),u(this,void 0,Promise,function(){var t,r,n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(t=i.sent())&&"accessKey"!==t.scope?(r=this.convertToUser,[4,this.getCurrentUser(e)]):[2,{data:{user:null},error:null}];case 2:return[2,{data:{user:r.apply(this,[i.sent()])},error:null}];case 3:return n=i.sent(),[2,{data:{user:null},error:new l.AuthError(n,{method:"getUser"})}];case 4:return[2]}})})},t.prototype.refreshUser=function(){return u(this,void 0,Promise,function(){var e,t,r;return c(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return n.sent(),[4,this.getSession()];case 2:return e=n.sent().data,[2,{data:{user:(t=(void 0===e?{}:e).session).user,session:t},error:null}];case 3:return r=n.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(r,{method:"refreshUser"})}];case 4:return[2]}})})},t.prototype.updateUser=function(e){var t;return u(this,void 0,Promise,function(){var r,n,i,s,a,d,p,f,v,g,y,m,_,E=this;return c(this,function(b){switch(b.label){case 0:if(b.trys.push([0,8,,9]),r=["password","new_password"].find(function(t){var r=e[t];return null!=r&&""!==r}))throw new l.AuthError({message:'updateUser 不支持更新密码,检测到传入了 "'.concat(r,'" 参数。如需修改密码请使用 resetPasswordForOld(旧密码修改)、resetPasswordForEmail(验证码重置)或 reauthenticate(重新认证后改密)')});if(!Object.keys(e).some(function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]}))throw new l.AuthError({message:"At least one field must be provided for update"});return n=e.email,i=e.phone,s=h(e,["email","phone"]),d=void 0!==i,p={},(a=void 0!==n)||d?(f=void 0,a?(f={email:e.email,usage:l.VerificationUsage.REAUTHENTICATION},v="email_change"):(g=this.formatPhone(e.phone),f={phone_number:g},v="phone_change"),[4,this.getVerification(o({},f))]):[3,4];case 1:return y=b.sent(),Object.keys(s).length>0?[4,this.updateUserBasicInfo(s)]:[3,3];case 2:b.sent(),b.label=3;case 3:return p={messageId:y.verification_id,verifyOtp:function(t){return u(E,void 0,Promise,function(){var r,n,i,o;return c(this,function(s){switch(s.label){case 0:return s.trys.push([0,11,,12]),t.email&&e.email===t.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:t.token,messageId:y.verification_id})]:[3,3];case 1:return(r=s.sent()).error?[2,r]:[4,this.updateUserBasicInfo({email:e.email})];case 2:return s.sent(),[3,9];case 3:return t.phone&&e.phone===t.phone?[4,this.verifyOtp({type:"phone_change",phone:e.phone,token:t.token,messageId:y.verification_id})]:[3,6];case 4:return(r=s.sent()).error?[2,r]:[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return s.sent(),[3,9];case 6:return[4,this.verifyOtp(a?{type:v,email:e.email,token:t.token,messageId:y.verification_id}:{type:v,phone:e.phone,token:t.token,messageId:y.verification_id})];case 7:return(r=s.sent()).error?[2,r]:[4,this.updateUserBasicInfo(e)];case 8:s.sent(),s.label=9;case 9:return[4,this.getUser(!1)];case 10:return n=s.sent().data.user,null===(o=this.config.eventBus)||void 0===o||o.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:{user:n},error:null}];case 11:return i=s.sent(),[2,{data:{user:null},error:new l.AuthError(i,{method:"updateUser"})}];case 12:return[2]}})})}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:b.sent(),b.label=6;case 6:return[4,this.getUser(!1)];case 7:return m=b.sent().data.user,Object.keys(s).length>0&&(null===(t=this.config.eventBus)||void 0===t||t.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.USER_UPDATED})),[2,{data:o({user:m},p),error:null}];case 8:return _=b.sent(),[2,{data:{user:null},error:new l.AuthError(_,{method:"updateUser"})}];case 9:return[2]}})})},t.prototype.getUserIdentities=function(){var e;return u(this,void 0,Promise,function(){var t,r;return c(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return t=n.sent(),[2,{data:{identities:null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.filter(function(e){return!!e.bind})},error:null}];case 2:return r=n.sent(),[2,{data:{identities:null},error:new l.AuthError(r,{method:"getUserIdentities"})}];case 3:return[2]}})})},t.prototype.linkIdentity=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:e.provider,options:{type:l.OAUTH_TYPE.BIND_IDENTITY}})];case 1:return r.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return t=r.sent(),[2,{data:{provider:null},error:new l.AuthError(t,{method:"linkIdentity"})}];case 3:return[2]}})})},t.prototype.unlinkIdentity=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:e.provider})];case 1:return r.sent(),[2,{data:{},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new l.AuthError(t,{method:"unlinkIdentity"})}];case 3:return[2]}})})},t.prototype.reauthenticate=function(){return u(this,void 0,Promise,function(){var e,t,r,n,i=this;return c(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.getUser(!1)];case 1:return e=s.sent().data.user,this.validateAtLeastOne(e,[["email","phone"]],"You must provide either an email or phone number"),t=e.email?{email:e.email,usage:l.VerificationUsage.REAUTHENTICATION}:{phone_number:this.formatPhone(e.phone)},[4,this.getVerification(t)];case 2:return r=s.sent(),[2,{data:{updateUser:function(e){return u(i,void 0,Promise,function(){var n,i,s,a,u;return c(this,function(c){switch(c.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"}}),c.label=1;case 1:return c.trys.push([1,9,,10]),e.password?[4,this.verify({verification_id:r.verification_id,verification_code:e.nonce})]:[3,5];case 2:return n=c.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:n.verification_token})];case 3:return i=c.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:e.password,sudo_token:i.sudo_token})];case 4:return c.sent(),[3,7];case 5:return[4,this.signInWithUsername(o(o({verificationInfo:r,verificationCode:e.nonce},t),{loginType:t.email?"email":"phone"}))];case 6:c.sent(),c.label=7;case 7:return[4,this.getSession()];case 8:return s=c.sent().data,[2,{data:{user:(a=(void 0===s?{}:s).session).user,session:a},error:null}];case 9:return u=c.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(u,{method:"reauthenticate"})}];case 10:return[2]}})})}},error:null}];case 3:return n=s.sent(),[2,{data:{updateUser:null},error:new l.AuthError(n,{method:"reauthenticate"})}];case 4:return[2]}})})},t.prototype.resend=function(e){return u(this,void 0,Promise,function(){var t,r,n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),t="signup"===e.type?"ANY":"USER",r={target:t},"email"in e&&(r.email=e.email,r.usage=l.VerificationUsage.EMAIL),"phone"in e&&(r.phone_number=this.formatPhone(e.phone)),[4,this.oauthInstance.authApi.getVerification(r)];case 1:return[2,{data:{messageId:i.sent().verification_id},error:null}];case 2:return n=i.sent(),[2,{data:{messageId:null},error:new l.AuthError(n,{method:"resend"})}];case 3:return[2]}})})},t.prototype.setSession=function(e){var t;return u(this,void 0,Promise,function(){var r,n,i;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(e,{throwError:!0})];case 1:return o.sent(),[4,this.getSession()];case 2:return r=o.sent().data,n=(void 0===r?{}:r).session,null===(t=this.config.eventBus)||void 0===t||t.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,{data:{user:n.user,session:n},error:null}];case 3:return i=o.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(i,{method:"setSession"})}];case 4:return[2]}})})},t.prototype.exchangeCodeForSession=function(){return u(this,void 0,void 0,function(){return c(this,function(e){return[2]})})},t.prototype.deleteUser=function(e){return u(this,void 0,Promise,function(){var t,r;return c(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(e)];case 1:return t=n.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:t})];case 2:return n.sent(),[2,{data:{},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new l.AuthError(r,{method:"deleteUser"})}];case 4:return[2]}})})},t.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),u(this,void 0,Promise,function(){var t,r,n,i,o;return c(this,function(s){try{return t=e.config_version||"env",r=Object.keys(e.query||{}).map(function(t){return"".concat(t,"=").concat(e.query[t])}).join("&"),p.adapterForWxMp.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(r?"?".concat(r):"")}):(n=e.redirect_uri||window.location.href,i=new URL(n),o="".concat(i.origin,"/__auth/?app_id=").concat(e.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(t,"&redirect_uri=").concat(encodeURIComponent(n)).concat(r?"&".concat(r):""),window.location.href=o),[2,{data:{},error:null}]}catch(e){return[2,{data:{},error:new l.AuthError(e,{method:"toDefaultLoginPage"})}]}return[2]})})},t.prototype.signInWithCustomTicket=function(e){return u(this,void 0,Promise,function(){var t,r,n,i;return c(this,function(s){switch(s.label){case 0:e&&this.setCustomSignFunc(e),s.label=1;case 1:return s.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return s.sent(),[4,this.createLoginState()];case 3:return t=s.sent(),[4,this.getSession()];case 4:return r=s.sent().data,n=(void 0===r?{}:r).session,[2,o(o({},t),{data:{user:n.user,session:n},error:null})];case 5:return i=s.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(i,{method:"signInWithCustomTicket"})}];case 6:return[2]}})})},t.prototype.signInWithOpenId=function(e){var t=(void 0===e?{}:e).useWxCloud,r=void 0===t||t;return u(this,void 0,Promise,function(){var e,t,n,i,s,a,h=this;return c(this,function(d){switch(d.label){case 0:if(!p.adapterForWxMp.isMatch())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,t=function(t){return u(h,void 0,void 0,function(){var n,i;return c(this,function(o){switch(o.label){case 0:n=void 0,i=void 0,o.label=1;case 1:return o.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},r)];case 2:if((null==(n=o.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:n.provider_token},r)];case 3:if(null==(i=o.sent())?void 0:i.error_code)throw i;return[3,5];case 4:throw o.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(i)];case 6:return o.sent(),[2]}})})},d.label=1;case 1:return d.trys.push([1,5,,6]),[4,new Promise(function(e,r){wx.login({success:function(n){return u(h,void 0,void 0,function(){var i;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,t(n.code)];case 1:return o.sent(),e(!0),[3,3];case 2:return i=o.sent(),r(i),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})})];case 2:return d.sent(),[4,this.createLoginState()];case 3:return n=d.sent(),[4,this.getSession()];case 4:return i=d.sent().data,s=(void 0===i?{}:i).session,[2,o(o({},n),{data:{user:s.user,session:s},error:null})];case 5:return a=d.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(a,{method:"signInWithOpenId"})}];case 6:return[2]}})})},t.prototype.signInWithPhoneAuth=function(e){var t=e.phoneCode,r=void 0===t?"":t,n=e.useWxCloud,i=void 0!==n&&n;return u(this,void 0,Promise,function(){var e,t,n,s,a,u,h,d,f;return c(this,function(c){switch(c.label){case 0:return p.adapterForWxMp.isMatch()?(e=wx.getAccountInfoSync().miniProgram,t={provider_params:{provider_code_type:"phone",code:r,appid:e.appId},provider_id:e.appId},[4,wx.login()]):[2,{data:{user:null,session:null},error:new l.AuthError({message:"wx api undefined"})}];case 1:n=c.sent().code,t.provider_code=n,c.label=2;case 2:return c.trys.push([2,5,,6]),[4,this.oauthInstance.authApi.grantProviderToken(t,i)];case 3:if((s=c.sent()).error_code)throw s;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:s.provider_token},i)];case 4:if(null==(a=c.sent())?void 0:a.error_code)throw a;return[3,6];case 5:return u=c.sent(),[2,{data:{user:null,session:null},error:new l.AuthError(u,{method:"signInWithPhoneAuth"})}];case 6:return[4,this.createLoginState()];case 7:return h=c.sent(),[4,this.getSession()];case 8:return d=c.sent().data,f=(void 0===d?{}:d).session,[2,o(o({},h),{data:{user:f.user,session:f},error:null})]}})})},t.prototype.bindPhoneNumber=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.editContact(e)]})})},t.prototype.unbindProvider=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.unbindProvider(e)]})})},t.prototype.bindEmail=function(e){return this.oauthInstance.authApi.editContact(e)},t.prototype.verify=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.verify(e)]})})},t.prototype.getVerification=function(e,t){return u(this,void 0,Promise,function(){return c(this,function(r){return e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[2,this.oauthInstance.authApi.getVerification(e,t)]})})},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var e=this.hasLoginState();return e&&e.user||null}(0,p.printWarn)(p.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(e){return void 0===e&&(e=!0),u(this,void 0,Promise,function(){var t,r,n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),e?[4,this.getLoginState()]:[3,3];case 1:return(t=i.sent())?[4,t.user.refresh()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[3,5];case 4:return i.sent(),[3,5];case 5:return[4,this.getLoginState()];case 6:return(r=i.sent())?(n=r.user.getLocalUserInfo(),[4,r.user.checkLocalInfoAsync()]):[3,8];case 7:return i.sent(),[2,o(o({},r.user),n)];case 8:return[2,null]}})})},t.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return u(this,void 0,Promise,function(){var e,r,n=this;return c(this,function(i){switch(i.label){case 0:if(!p.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,r=function(r){return u(n,void 0,void 0,function(){var n,i;return c(this,function(o){switch(o.label){case 0:n=void 0,i=void 0,o.label=1;case 1:return o.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},t)];case 2:if((null==(n=o.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:n.provider_token},t)];case 3:if(null==(i=o.sent())?void 0:i.error_code)throw i;return[3,5];case 4:throw o.sent();case 5:return[2]}})})},[4,new Promise(function(e,t){wx.login({success:function(i){return u(n,void 0,void 0,function(){var n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,r(i.code)];case 1:return o.sent(),e(!0),[3,3];case 2:return n=o.sent(),t(n),[3,3];case 3:return[2]}})})},fail:function(e){var r=new Error(null==e?void 0:e.errMsg);r.code=null==e?void 0:e.errno,t(r)}})})];case 1:return i.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}})})},t.prototype.bindOpenId=function(){return u(this,void 0,Promise,function(){var e,t,r=this;return c(this,function(n){switch(n.label){case 0:if(!p.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return u(r,void 0,void 0,function(){var r;return c(this,function(n){switch(n.label){case 0:r=void 0,n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}})];case 2:if((null==(r=n.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:r.provider_token})];case 3:return n.sent(),[3,5];case 4:throw n.sent();case 5:return[2]}})})},[4,new Promise(function(e,n){wx.login({success:function(i){return u(r,void 0,void 0,function(){var r;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,t(i.code)];case 1:return o.sent(),e(!0),[3,3];case 2:return r=o.sent(),n(r),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})})];case 1:return n.sent(),[2]}})})},t.prototype.signInWithUnionId=function(){return u(this,void 0,Promise,function(){var e=this;return c(this,function(t){switch(t.label){case 0:if(!p.adapterForWxMp.isMatch())throw Error("wx api undefined");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise(function(t,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(i){return u(e,void 0,void 0,function(){var e,o,s,a,u;return c(this,function(c){switch(c.label){case 0:e=null==n?void 0:n.appId,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:i.code,provider_id:e,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return o=c.sent(),(s=o.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:e,provider_token:s})]:(r(o),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(t(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})})];case 2:return t.sent(),[3,4];case 3:throw t.sent();case 4:return[2,this.createLoginState()]}})})},t.prototype.signInWithSms=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,i=void 0===n?"":n,o=e.phoneNum,s=void 0===o?"":o,a=e.bindInfo,h=void 0===a?void 0:a;return u(this,void 0,Promise,function(){return c(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:i,bindInfo:h,username:s,loginType:"sms"})]}catch(e){throw e}return[2]})})},t.prototype.signInWithEmail=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,i=void 0===n?"":n,o=e.bindInfo,s=void 0===o?void 0:o,a=e.email,h=void 0===a?"":a;return u(this,void 0,Promise,function(){return c(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:i,bindInfo:s,username:h,loginType:"email"})]}catch(e){throw e}return[2]})})},t.prototype.setCustomSignFunc=function(e){this.oauthInstance.authApi.setCustomSignFunc(e)},t.prototype.signIn=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signIn(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.setPassword=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.setPassword(e)]})})},t.prototype.isUsernameRegistered=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,p.throwError)(p.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:e})];case 1:return[2,t.sent().exist]}})})},t.prototype.hasLoginState=function(){var e;if("async"!==this.cache.mode)return(null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync())?new _({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,p.printWarn)(p.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},t.prototype.getLoginState=function(){return u(this,void 0,Promise,function(){var e;return c(this,function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,null];case 4:return e?[2,new _({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}})})},t.prototype.getUserInfo=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.getCurrentUser()]})})},t.prototype.getWedaUserInfo=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]})})},t.prototype.updateUserBasicInfo=function(e){return u(this,void 0,void 0,function(){var t;return c(this,function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(t=r.sent())?[4,t.user.updateUserBasicInfo(e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}})})},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]})})},t.prototype.queryUser=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]})})},t.prototype.getAccessToken=function(){return u(this,void 0,Promise,function(){return c(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:e.sent(),env:this.config.env}]}})})},t.prototype.grantProviderToken=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]})})},t.prototype.patchProviderToken=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]})})},t.prototype.signInWithProvider=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.grantToken=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.grantToken(e)];case 1:return t.sent(),[2,this.createLoginState()]}})})},t.prototype.genProviderRedirectUri=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]})})},t.prototype.resetPassword=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]})})},t.prototype.deviceAuthorize=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]})})},t.prototype.sudo=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.sudo(e)]})})},t.prototype.deleteMe=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]})})},t.prototype.getProviders=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getProviders()]})})},t.prototype.loginScope=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.loginScope()]})})},t.prototype.loginGroups=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.loginGroups()]})})},t.prototype.onLoginStateChanged=function(e){var t;return u(this,void 0,void 0,function(){var r,n=this;return c(this,function(i){switch(i.label){case 0:return null===(t=this.config.eventBus)||void 0===t||t.on(l.EVENTS.LOGIN_STATE_CHANGED,function(t){return u(n,void 0,void 0,function(){var r,n,i;return c(this,function(s){switch(s.label){case 0:return(null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.eventType)===l.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR?[3,2]:[4,this.getLoginState()];case 1:return n=s.sent(),[3,3];case 2:n={},s.label=3;case 3:return r=n,e.call(this,o(o({},t),r)),[2]}})})}),[4,this.getLoginState()];case 1:return r=i.sent(),e.call(this,r),[2]}})})},t.prototype.refreshTokenForce=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]})})},t.prototype.getCredentials=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getCredentials()]})})},t.prototype.setCredentials=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(e)];case 1:return t.sent(),[2]}})})},t.prototype.getProviderSubType=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]})})},t.prototype.createCaptchaData=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]})})},t.prototype.verifyCaptchaData=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]})})},t.prototype.getMiniProgramQrCode=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]})})},t.prototype.getMiniProgramQrCodeStatus=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]})})},t.prototype.modifyPassword=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]})})},t.prototype.modifyPasswordWithoutLogin=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]})})},t.prototype.getUserBehaviorLog=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.getUserBehaviorLog(e)]})})},t.prototype.signInWithUsername=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,i=void 0===n?"":n,s=e.username,a=void 0===s?"":s,h=e.bindInfo,l=void 0===h?void 0:h,d=e.loginType,p=void 0===d?"":d;return u(this,void 0,Promise,function(){var e,t,n,s,u,h,d;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:i})];case 1:if(null==(e=c.sent())?void 0:e.error_code)throw e;return t=e.verification_token,n=this.formatPhone(a),s={phone_number:n},"email"===p&&(s={email:n=a}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:t})]:[3,5];case 2:if(null==(u=c.sent())?void 0:u.error_code)throw u;return l?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==l?void 0:l.providerToken})]:[3,4];case 3:if(null==(h=c.sent())?void 0:h.error_code)throw h;c.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(o(o({},s),{verification_token:t,provider_token:null==l?void 0:l.providerId}))];case 6:if(null==(d=c.sent())?void 0:d.error_code)throw d;c.label=7;case 7:return[2,this.createLoginState()];case 8:throw c.sent();case 9:return[2]}})})},t.prototype.createLoginState=function(e,t){var r,n;return u(this,void 0,Promise,function(){var i;return c(this,function(o){switch(o.label){case 0:return[4,(i=new _({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return o.sent(),(null==t?void 0:t.userInfo)?(i.user.setLocalUserInfo(t.userInfo),[3,5]):[3,2];case 2:return(null==t?void 0:t.asyncRefreshUser)?(i.user.refresh(e),[3,5]):[3,3];case 3:return[4,i.user.refresh(e)];case 4:o.sent(),o.label=5;case 5:return null===(r=this.config.eventBus)||void 0===r||r.fire(l.EVENTS.LOGIN_STATE_CHANGED,{eventType:l.LOGIN_STATE_CHANGED_TYPE.SIGN_IN}),null===(n=this.config.eventBus)||void 0===n||n.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,i]}})})},t.prototype.setAccessKey=function(){var e,t;return u(this,void 0,void 0,function(){var r,n;return c(this,function(i){if(r="",n="",this.config.accessKey?(r=this.config.accessKey,n="accessKey"):(null===(e=this.config.auth)||void 0===e?void 0:e.secretId)&&(null===(t=this.config.auth)||void 0===t?void 0:t.secretKey)&&(r="",n=l.DEFAULT_NODE_ACCESS_SCOPE),!n)return[2];try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:r,token_type:"Bearer",scope:n,expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]})})},t.prototype.formatPhone=function(e){return!/\s+/.test(e)&&/^\+\d{1,3}\d+/.test(e)?e.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(e)?e:"+86 ".concat(e)},t.prototype.notifyListeners=function(e,t,r){this.listeners.forEach(function(n){n.forEach(function(n){try{n(e,t,r)}catch(e){console.error("Error in auth state change callback:",e)}})})},t.prototype.setupListeners=function(){var e,t=this;null===(e=this.config.eventBus)||void 0===e||e.on(l.EVENTS.AUTH_STATE_CHANGED,function(e){return u(t,void 0,void 0,function(){var t,r,n,i,o;return c(this,function(s){switch(s.label){case 0:return t=null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.event,r=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(t,n,r),[2]}})})})},t.prototype.convertToUser=function(e){var t,r,n,i,o,s;if(!e)return null;var a=(null==e?void 0:e.email)||"",u=(null==e?void 0:e.phone_number)||"",c=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:c,aud:"authenticated",role:null===(r=null===(t=e.groups)||void 0===t?void 0:t.map)||void 0===r?void 0:r.call(t,function(e){return"string"==typeof e?e:e.id}),email:a||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:u,phone_confirmed_at:u?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(n=e.loginType)||void 0===n?void 0:n.toLowerCase())||"cloudbase",providers:[(null===(i=e.loginType)||void 0===i?void 0:i.toLowerCase())||"cloudbase"]},user_metadata:{name:null==e?void 0:e.name,picture:null==e?void 0:e.picture,username:null==e?void 0:e.username,gender:null==e?void 0:e.gender,locale:null==e?void 0:e.locale,uid:e.uid,nickName:e.nickName||(null==e?void 0:e.name),avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:null!==(o=e.hasPassword)&&void 0!==o?o:"SET"===e.password,open_id:null==e?void 0:e.open_id},identities:(null===(s=null==e?void 0:e.providers)||void 0===s?void 0:s.map(function(t){return{id:t.id||"",identity_id:t.id||"",user_id:c,identity_data:{provider_id:t.id,provider_user_id:t.provider_user_id,name:t.name},provider:t.id||"cloudbase",created_at:e.created_at,updated_at:e.updated_at,last_sign_in_at:e.last_sign_in_at}}))||[],created_at:e.created_at,updated_at:e.updated_at,is_anonymous:"anonymous"===e.name}},t.prototype.validateParams=function(e,t){for(var r=0,n=Object.entries(t);r<n.length;r++){var i=n[r],o=i[0],s=i[1];if(s.required&&(void 0===(null==e?void 0:e[o])||null===(null==e?void 0:e[o])||""===(null==e?void 0:e[o])))throw new l.AuthError({message:s.message})}},t.prototype.validateAtLeastOne=function(e,t,r){if(!t.some(function(t){return t.some(function(t){return void 0!==(null==e?void 0:e[t])&&null!==(null==e?void 0:e[t])&&""!==(null==e?void 0:e[t])})}))throw new l.AuthError({message:r})},t.prototype.init=function(){var e;return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return t.sent()&&(null===(e=this.config.eventBus)||void 0===e||e.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION})),[3,3];case 2:return t.sent(),[3,3];case 3:return[2,{error:null}]}})})},s([(0,p.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(r=void 0!==l.authModels&&l.authModels.BindPhoneRequest)?r:Object]),a("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),s([(0,p.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(n=void 0!==l.authModels&&l.authModels.UnbindProviderRequest)?n:Object]),a("design:returntype","function"==typeof(d="undefined"!=typeof Promise&&Promise)?d:Object)],t.prototype,"unbindProvider",null),s([(0,p.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(v=void 0!==l.authModels&&l.authModels.BindEmailRequest)?v:Object]),a("design:returntype",void 0)],t.prototype,"bindEmail",null),s([(0,p.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(m=void 0!==l.authModels&&l.authModels.VerifyRequest)?m:Object]),a("design:returntype","function"==typeof(E="undefined"!=typeof Promise&&Promise)?E:Object)],t.prototype,"verify",null),s([(0,p.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(b=void 0!==l.authModels&&l.authModels.GetVerificationRequest)?b:Object,Object]),a("design:returntype","function"==typeof(I="undefined"!=typeof Promise&&Promise)?I:Object)],t.prototype,"getVerification",null),s([(0,p.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(A="undefined"!=typeof Promise&&Promise)?A:Object)],t.prototype,"getCurrentUser",null),s([(0,p.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(w="undefined"!=typeof Promise&&Promise)?w:Object)],t.prototype,"signInAnonymouslyInWx",null),s([(0,p.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],t.prototype,"bindOpenId",null),s([(0,p.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(S="undefined"!=typeof Promise&&Promise)?S:Object)],t.prototype,"signInWithUnionId",null),s([(0,p.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(O="undefined"!=typeof Promise&&Promise)?O:Object)],t.prototype,"signInWithSms",null),s([(0,p.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(P="undefined"!=typeof Promise&&Promise)?P:Object)],t.prototype,"signInWithEmail",null),s([(0,p.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype","function"==typeof(R="undefined"!=typeof Promise&&Promise)?R:Object)],t.prototype,"isUsernameRegistered",null),s([(0,p.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(C="undefined"!=typeof Promise&&Promise)?C:Object)],t.prototype,"getLoginState",null),s([(0,p.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(U="undefined"!=typeof Promise&&Promise)?U:Object)],t.prototype,"getUserInfo",null),s([(0,p.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(N="undefined"!=typeof Promise&&Promise)?N:Object)],t.prototype,"getWedaUserInfo",null),s([(0,p.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(D=void 0!==l.authModels&&l.authModels.BindWithProviderRequest)?D:Object]),a("design:returntype","function"==typeof(L="undefined"!=typeof Promise&&Promise)?L:Object)],t.prototype,"bindWithProvider",null),s([(0,p.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(k="undefined"!=typeof Promise&&Promise)?k:Object)],t.prototype,"getProviderSubType",null),t}(v.AuthV1Compat);function b(e,t){var r,n,i,s,a=this,h=e.region,f=void 0===h?"ap-shanghai":h,v=e.i18n,g=e.accessKey,y=e.useWxCloud,m=(null==t?void 0:t.platform)||p.useDefaultAdapter.bind(t)(),_=m.runtime,b=m.adapter,I=t||{},A=I.env,w=I.clientId,T=I.debug,S=I.cache,O=I.app,P=I.getApiOrigin,R=(t||{}).apiOrigin;R||(R="https://".concat(A,".").concat(f,".tcb-api.tencentcloudapi.com"));var C,U={env:A,clientId:w,i18n:v,accessKey:g,useWxCloud:y,eventBus:new p.CloudbaseEventEmitter},N=new l.CloudbaseOAuth((0,d.useAuthAdapter)(o(o({},U),{apiOrigin:R,getApiOrigin:P,apiPath:(null==e?void 0:e.apiPath)||l.AUTH_API_PREFIX,storage:null==e?void 0:e.storage,baseRequest:null==e?void 0:e.baseRequest,request:null==e?void 0:e.request,anonymousSignInFunc:null==e?void 0:e.anonymousSignInFunc,captchaOptions:null==e?void 0:e.captchaOptions,wxCloud:null==e?void 0:e.wxCloud,adapter:b,onCredentialsError:(C=U.eventBus,function(e){C.fire(l.EVENTS.LOGIN_STATE_CHANGED,o(o({},e),{eventType:l.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR}))}),headers:o({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:T,auth:null===(n=null===(r=t.app)||void 0===r?void 0:r.config)||void 0===n?void 0:n.auth}))),D=new E(o(o({},U),{region:f,persistence:e.persistence,debug:T,cache:S||new p.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(A)},platformInfo:m}),runtime:_||"web",_fromApp:O,oauthInstance:N,auth:null===(s=null===(i=t.app)||void 0===i?void 0:i.config)||void 0===s?void 0:s.auth}));return N.initializeSession(function(e,t){return u(a,void 0,void 0,function(){return c(this,function(r){return e?(e.type===l.OAUTH_TYPE.SIGN_IN?t?U.eventBus.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.SIGNED_IN,info:o(o({},e),{error:t})}):e.user&&D.createLoginState({},{userInfo:e.user}):e.type===l.OAUTH_TYPE.BIND_IDENTITY&&U.eventBus.fire(l.EVENTS.AUTH_STATE_CHANGED,{event:l.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:o(o({},e),{error:t})}),[2]):[2]})})}),{authInstance:D,oauthInstance:N}}t.Auth=E,t.generateAuthInstance=b;var I="auth";function A(e,t){for(var r=[],n=0;n<=e.length;n++)r[n]=[n];for(var i=0;i<=t.length;i++)r[0][i]=i;for(n=1;n<=e.length;n++)for(i=1;i<=t.length;i++){var o=e[n-1].toLowerCase()===t[i-1].toLowerCase()?0:1;r[n][i]=Math.min(r[n-1][i]+1,r[n][i-1]+1,r[n-1][i-1]+o)}return r[e.length][t.length]}var w={name:"auth",namespace:I,entity:function(e){var t=function(e){var t,r=this;if(this.authInstance&&!e)return this.authInstance;e=e||{region:"",persistence:"local",apiPath:l.AUTH_API_PREFIX};var n=this.platform.adapter,i=e.persistence||n.primaryStorage;i&&i!==this.config.persistence&&this.updateConfig({persistence:i});var s=b(o(o({wxCloud:this.config.wxCloud,storage:this.config.storage},e),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(t=this.config.auth)||void 0===t?void 0:t.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,getApiOrigin:function(){return r.request.getBaseEndPoint(r.config.endPointMode||"CLOUD_API")},platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),a=s.authInstance,u=s.oauthInstance;return this.oauthInstance=u,this.authInstance=a,this.authInstance},r=t.call(this,e);Object.assign(t,r),Object.setPrototypeOf(t,Object.getPrototypeOf(r));var n="undefined"!=typeof Proxy?new Proxy(t,{get:function(e,t,r){var n=Reflect.get(e,t,r);if(void 0!==n||"string"!=typeof t)return n;var i=function(e,t){for(var r=null,n=1/0,i=0,o=t;i<o.length;i++){var s=o[i];if(!s.startsWith("_")&&"constructor"!==s){var a=A(e,s);a<n&&(n=a,r=s)}}return r}(t,Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)).filter(function(t){return"function"==typeof e[t]}));return i&&console.warn("[CloudBase Auth] auth.".concat(t," is not a function. Did you mean: auth.").concat(i,"() ?")),n}}):t;return this[I]=n,n}};try{cloudbase.registerComponent(w)}catch(e){}var T=r(722);Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return T.AuthErrorCategory}}),Object.defineProperty(t,"AuthErrorCode",{enumerable:!0,get:function(){return T.AuthErrorCode}}),Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return T.AuthError}}),t.registerAuth=function(e){try{e.registerComponent(w)}catch(e){console.warn(e)}}},19:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.adapterForWxMp=t.CloudbaseCache=t.CloudbaseEventEmitter=t.catchErrorsDecorator=t.COMMUNITY_SITE_URL=t.ERRORS=t.throwError=t.printWarn=void 0;var i=r(616);Object.defineProperty(t,"printWarn",{enumerable:!0,get:function(){return i.printWarn}}),Object.defineProperty(t,"throwError",{enumerable:!0,get:function(){return i.throwError}});var o=r(794);Object.defineProperty(t,"ERRORS",{enumerable:!0,get:function(){return o.ERRORS}}),Object.defineProperty(t,"COMMUNITY_SITE_URL",{enumerable:!0,get:function(){return o.COMMUNITY_SITE_URL}});var s=r(141);Object.defineProperty(t,"catchErrorsDecorator",{enumerable:!0,get:function(){return s.catchErrorsDecorator}});var a=r(689);Object.defineProperty(t,"CloudbaseEventEmitter",{enumerable:!0,get:function(){return a.CloudbaseEventEmitter}});var u=r(197);Object.defineProperty(t,"CloudbaseCache",{enumerable:!0,get:function(){return u.CloudbaseCache}});var c=r(917);Object.defineProperty(t,"adapterForWxMp",{enumerable:!0,get:function(){return n(c).default}});var h=r(182);Object.defineProperty(t,"useDefaultAdapter",{enumerable:!0,get:function(){return h.useDefaultAdapter}})},266:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.removeUrlParams=t.addUrlSearch=t.removeBrowserSession=t.getBrowserSession=t.saveToBrowserSession=void 0,t.saveToBrowserSession=function(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch(e){console.error("Failed to save to browser session:",e)}},t.getBrowserSession=function(e){try{return JSON.parse(sessionStorage.getItem(e))}catch(e){return console.error("Failed to get browser session:",e),null}},t.removeBrowserSession=function(e){try{return sessionStorage.removeItem(e),!0}catch(e){return console.error("Failed to remove browser session:",e),null}},t.addUrlSearch=function(e,t){if(void 0!==e){var r=new URL(window.location.href);return r.search=e,r.hash=t||r.hash,window.history.replaceState({},"",r.href),r.href}},t.removeUrlParams=function(e){if("undefined"!=typeof window)try{var t=new URL(window.location.href);e.forEach(function(e){t.searchParams.delete(e)}),window.history.replaceState({},"",t.href)}catch(e){console.error("Failed to remove URL params:",e)}}},916:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.applyUserV1Compat=t.AuthV1Compat=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=void 0;var s=r(722),a=r(19),u=function(){function e(e){}return e.prototype.signInWithRedirect=function(){throw new Error("[v1 兼容] WeixinAuthProvider.signInWithRedirect() 在当前版本中无法实现。 建议使用 auth.signInWithOAuth({ provider: 'providerId' }) 替代。")},e.prototype.getRedirectResult=function(e){return i(this,void 0,Promise,function(){return o(this,function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getRedirectResult() 在当前版本中无法实现。 建议使用 auth.verifyOAuth({ code, state, provider }) 替代。")})})},e.prototype.getLinkRedirectResult=function(e){return i(this,void 0,Promise,function(){return o(this,function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getLinkRedirectResult() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")})})},e}();t.WeixinAuthProvider=u;var c=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.authInstance.signInWithCustomTicket(function(){return Promise.resolve(e)})];case 1:return t.sent(),[2]}})})},e}();t.CustomAuthProvider=c;var h=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(){return i(this,void 0,Promise,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.authInstance.signInAnonymously({})];case 1:return e.sent(),[2]}})})},e}();t.AnonymousAuthProvider=h;var l=function(){function e(){}return e.prototype.weixinAuthProvider=function(e){return new u({authInstance:this,appid:e.appid,scope:e.scope})},e.prototype.customAuthProvider=function(){return new c({authInstance:this})},e.prototype.anonymousAuthProvider=function(){return new h({authInstance:this})},e.prototype.signUpWithEmailAndPassword=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signUp({email:e,password:t})];case 1:return[2,r.sent()]}})})},e.prototype.signInWithEmailAndPassword=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}})})},e.prototype.sendPasswordResetEmail=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),[4,this.getVerification({email:e})];case 1:return t.sent(),[2]}})})},e.prototype.signInWithUsernameAndPassword=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"username must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}})})},e.prototype.sendPhoneCode=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),t=this.formatPhone(e),[4,this.getVerification({phone_number:t})];case 1:return r.sent(),[2,!0]}})})},e.prototype.signUpWithPhoneCode=function(e,t,r){return i(this,void 0,Promise,function(){var i;return o(this,function(o){switch(o.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),i=this.formatPhone(e),[4,this.signUp(n({phone_number:i,verification_code:t},r?{password:r}:{}))];case 1:return o.sent(),[2,this.createLoginState()]}})})},e.prototype.signInWithPhoneCodeOrPassword=function(e){return i(this,void 0,Promise,function(){var t,r,n,i;return o(this,function(o){switch(o.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),i=this.formatPhone(t),n?[4,this.signIn({username:i,password:n})]:[3,2];case 1:return o.sent(),[3,5];case 2:return r?[4,this.signIn({username:i,verification_token:r})]:[3,4];case 3:return o.sent(),[3,5];case 4:(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode or password must be provided"),o.label=5;case 5:return[2,this.createLoginState()]}})})},e.prototype.forceResetPwdByPhoneCode=function(e){return i(this,void 0,Promise,function(){var t,r,n,i;return o(this,function(o){switch(o.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof r&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),"string"!=typeof n&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),i=this.formatPhone(t),[4,this.resetPassword({phone_number:i,new_password:n,verification_token:r})];case 1:return o.sent(),[4,this.signIn({username:i,password:n})];case 2:return o.sent(),[2,this.createLoginState()]}})})},e.prototype.shouldRefreshAccessToken=function(e){throw new Error("[v1 兼容] shouldRefreshAccessToken() 在当前版本中无法实现。 建议使用 auth.onAuthStateChange(callback) 来监听 TOKEN_REFRESHED 事件替代。")},e.prototype.onLoginStateExpired=function(e){var t=this;this.onLoginStateChanged(function(r){(null==r?void 0:r.eventType)===s.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR&&e.call(t)})},e.prototype.onAccessTokenRefreshed=function(e){var t=this;this.onAuthStateChange(function(r){r===s.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED&&e.call(t)})},e.prototype.onAnonymousConverted=function(e){var t=this;this.onAuthStateChange(function(r){r===s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&e.call(t)})},e.prototype.onLoginTypeChanged=function(e){var t=this;this.onAuthStateChange(function(r){r!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&r!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT||e.call(t)})},e}();t.AuthV1Compat=l,t.applyUserV1Compat=function(e){e.prototype.linkWithTicket=function(e){return i(this,void 0,Promise,function(){return o(this,function(e){throw new Error("[v1 兼容] User.linkWithTicket() 在当前版本中无法实现。 建议使用 auth.signInWithCustomTicket(() => Promise.resolve(ticket)) 替代。")})})},e.prototype.linkWithRedirect=function(e){throw new Error("[v1 兼容] User.linkWithRedirect() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")},e.prototype.updateEmail=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"newEmail must be a string"),[4,this.updateUserBasicInfo({email:e})];case 1:return t.sent(),[2]}})})},e.prototype.linkWithPhoneNumber=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(e){throw new Error("[v1 兼容] User.linkWithPhoneNumber() 在当前版本中无法实现。 建议使用 auth.bindPhoneNumber({ phone_number, verification_token, sudo_token }) 替代。")})})},e.prototype.updatePhoneNumber=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(e){throw new Error("[v1 兼容] User.updatePhoneNumber() 在当前版本中无法实现。 建议使用 auth.updateUser({ phone: newPhoneNumber }) 替代。")})})},e.prototype.unlink=function(e){return i(this,void 0,Promise,function(){return o(this,function(e){throw new Error("[v1 兼容] User.unlink() 在当前版本中无法实现。 建议使用 auth.unlinkIdentity({ provider: loginType }) 替代。")})})}}},304:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=void 0;var n=r(895);t.registerAuth=n.registerAuth;try{window.registerAuth=t.registerAuth}catch(e){}},413:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Auth=void 0;var u=r(949),c=r(257),h=r(462),l=r(631),d=a(r(639)),p=r(308);function f(e,t){var n;return i(this,void 0,void 0,function(){var s,a=this;return o(this,function(u){s=function(){return i(a,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return e.trys.push([0,1,,6]),[2,r(814)];case 1:e.sent(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,Promise.resolve().then(r.t.bind(r,814,23))];case 3:return[2,e.sent()];case 4:return e.sent(),[2];case 5:return[3,6];case 6:return[2]}})})};try{if(((null===(n=null==t?void 0:t.root)||void 0===n?void 0:n.globalThis)||globalThis).IS_MP_BUILD)return[2];if(e)return[2,s()]}catch(t){if(e)return[2,s()]}return[2]})})}var v=function(){function e(e){var t=e.request,r=e.credentialsClient;if(!r){var i={apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,storage:e.storage,env:e.env,baseRequest:e.baseRequest,anonymousSignInFunc:e.anonymousSignInFunc,wxCloud:e.wxCloud,onCredentialsError:e.onCredentialsError,headers:e.headers||{},i18n:e.i18n,debug:e.debug};r=new c.OAuth2Client(i)}if(!t){var o=r.request.bind(r),s=new h.Captcha(n({env:e.env,clientId:e.clientId,request:o,storage:e.storage,adapter:e.adapter,oauthInstance:this},e.captchaOptions));t=s.request.bind(s)}this.config={env:e.env,apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,request:t,credentialsClient:r,storage:e.storage||c.defaultStorage,adapter:e.adapter}}return e.parseParamsToSearch=function(e){return Object.keys(e).forEach(function(t){e[t]||delete e[t]}),new d.default(e).toString()},e.prototype.getParamsByVersion=function(e,t){var r,n=(0,l.deepClone)(e),i=(null===(r={v2:u.ApiUrlsV2}[null==n?void 0:n.version])||void 0===r?void 0:r[t])||u.ApiUrls[t];return n&&delete n.version,{params:n,url:i}},e.prototype.signIn=function(e){return i(this,void 0,Promise,function(){var t,r,i,s;return o(this,function(o){switch(o.label){case 0:return t=e.version||"v1",(r=this.getParamsByVersion(e,"AUTH_SIGN_IN_URL")).params.query&&delete r.params.query,[4,this.getEncryptParams(r.params)];case 1:return i=o.sent(),[4,this.config.request(r.url,{method:"POST",body:i})];case 2:return s=o.sent(),[4,this.config.credentialsClient.setCredentials(n(n({},s),{version:t}))];case 3:return o.sent(),[2,Promise.resolve(s)]}})})},e.prototype.signInAnonymously=function(e,t){return void 0===e&&(e={}),void 0===t&&(t=!1),i(this,void 0,Promise,function(){var r;return o(this,function(n){switch(n.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:e,useWxCloud:t})];case 1:return r=n.sent(),[4,this.config.credentialsClient.setCredentials(r)];case 2:return n.sent(),[2,Promise.resolve(r)]}})})},e.prototype.signUp=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_UP_URL,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}})})},e.prototype.signOut=function(e){return i(this,void 0,Promise,function(){var t,r,n,i;return o(this,function(o){switch(o.label){case 0:if(t={},!e)return[3,6];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.config.request(u.ApiUrls.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:e})];case 2:return t=o.sent(),[3,4];case 3:return(r=o.sent()).error!==u.ErrorType.UNAUTHENTICATED&&console.log("sign_out_error",r),[3,4];case 4:return[4,this.config.credentialsClient.setCredentials()];case 5:return o.sent(),[2,t];case 6:return[4,this.config.credentialsClient.getAccessToken()];case 7:return n=o.sent(),[4,this.config.request(u.ApiUrls.AUTH_REVOKE_URL,{method:"POST",body:{token:n}})];case 8:return i=o.sent(),[4,this.config.credentialsClient.setCredentials()];case 9:return o.sent(),[2,Promise.resolve(i)]}})})},e.prototype.revokeAllDevices=function(){return i(this,void 0,Promise,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})];case 1:return e.sent(),[2]}})})},e.prototype.revokeDevice=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){switch(t.label){case 0:return[4,this.config.request(u.ApiUrls.AUTHORIZED_DEVICES_DELETE_URL+e.device_id,{method:"DELETE",withCredentials:!0})];case 1:return t.sent(),[2]}})})},e.prototype.getVerification=function(e,t){return i(this,void 0,Promise,function(){var r,n;return o(this,function(i){switch(i.label){case 0:return r=!1,"CUR_USER"!==e.target?[3,1]:(r=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:i.sent()&&(r=!0),i.label=3;case 3:return(n=(0,l.deepClone)(e)).phone_number&&!/^\+\d{1,3}\s+\d+/.test(n.phone_number)&&(n.phone_number="+86 ".concat(n.phone_number)),[2,this.config.request(u.ApiUrls.VERIFICATION_URL,{method:"POST",body:n,withCaptcha:(null==t?void 0:t.withCaptcha)||!1,withCredentials:r})]}})})},e.prototype.verify=function(e){return i(this,void 0,Promise,function(){var t,r;return o(this,function(i){switch(i.label){case 0:return t=this.getParamsByVersion(e,"VERIFY_URL"),[4,this.config.request(t.url,{method:"POST",body:t.params})];case 1:return r=i.sent(),"v2"!==(null==e?void 0:e.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(n(n({},r),{version:"v2"}))];case 2:i.sent(),i.label=3;case 3:return[2,r]}})})},e.prototype.genProviderRedirectUri=function(t){return i(this,void 0,Promise,function(){var r,n,i,a,c;return o(this,function(o){return r=t.provider_redirect_uri,n=t.other_params,i=void 0===n?{}:n,a=s(t,["provider_redirect_uri","other_params"]),r&&!a.redirect_uri&&(a.redirect_uri=r),c="".concat(u.ApiUrls.PROVIDER_URI_URL,"?").concat(e.parseParamsToSearch(a)),Object.keys(i).forEach(function(e){var t=i[e];("sign_out_uri"!==e||(null==t?void 0:t.length)>0)&&(c+="&other_params[".concat(e,"]=").concat(encodeURIComponent(t)))}),[2,this.config.request(c,{method:"GET"})]})})},e.prototype.grantProviderToken=function(e,t){return void 0===t&&(t=!1),i(this,void 0,Promise,function(){return o(this,function(r){return[2,this.config.request(u.ApiUrls.PROVIDER_TOKEN_URL,{method:"POST",body:e,useWxCloud:t})]})})},e.prototype.patchProviderToken=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})]})})},e.prototype.signInWithProvider=function(e,t){return void 0===t&&(t=!1),i(this,void 0,Promise,function(){var r,i;return o(this,function(o){switch(o.label){case 0:return r=this.getParamsByVersion(e,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:t})];case 1:return i=o.sent(),[4,this.config.credentialsClient.setCredentials(n(n({},i),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return o.sent(),[2,Promise.resolve(i)]}})})},e.prototype.toBindIdentity=function(e){var t,r;return i(this,void 0,void 0,function(){var n,i,s,a;return o(this,function(o){switch(o.label){case 0:return(i=e.credentials)?[3,2]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 1:i=o.sent(),o.label=2;case 2:n=i,o.label=3;case 3:return o.trys.push([3,5,,6]),[4,this.bindWithProvider({provider_token:e.provider_token},n)];case 4:return o.sent(),s={data:{type:u.OAUTH_TYPE.BIND_IDENTITY,provider:e.provider},error:null},[3,6];case 5:return a=o.sent(),s={data:{type:u.OAUTH_TYPE.BIND_IDENTITY},error:new p.AuthError(a)},[3,6];case 6:return e.fireEvent&&(null===(r=null===(t=this.config.eventBus)||void 0===t?void 0:t.fire)||void 0===r||r.call(t,u.EVENTS.AUTH_STATE_CHANGED,{event:u.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:s})),[2,s]}})})},e.prototype.getInitialSession=function(){return i(this,void 0,Promise,function(){var e,t,r,i,s,a,c,h,l,d,f,v,g,y,m;return o(this,function(o){switch(o.label){case 0:e={},o.label=1;case 1:if(o.trys.push([1,12,,13]),"undefined"==typeof window||"undefined"==typeof document)return[2,{data:null,error:null}];if(t=new URLSearchParams(null===location||void 0===location?void 0:location.search),r=t.get("code"),i=t.get("state"),!r||!i)return[2,{data:null,error:null}];s=null;try{s=JSON.parse(sessionStorage.getItem(i)||"null")}catch(e){}return e={type:null==s?void 0:s.type},a=t.get("error"),c=t.get("error_description"),a||c?[2,{data:e,error:new p.AuthError({message:c||a||"Unknown error from OAuth provider"})}]:(h=(null==s?void 0:s.provider)||t.get("provider"))?(l=location.origin+location.pathname,[4,this.grantProviderToken({provider_id:h,provider_redirect_uri:l,provider_code:r})]):[2,{data:e,error:new p.AuthError({message:"Provider is required for OAuth verification"})}];case 2:return d=o.sent().provider_token,f=void 0,v=null,g=void 0,s.type!==u.OAUTH_TYPE.BIND_IDENTITY?[3,5]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 3:return f=o.sent(),[4,this.toBindIdentity({provider:h,provider_token:d,credentials:f})];case 4:return g=o.sent(),[3,11];case 5:return s.type!==u.OAUTH_TYPE.SIGN_IN?[3,11]:(g=this.getParamsByVersion({provider:h},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(g.url,{method:"POST",body:{provider_token:d}})]);case 6:f=o.sent(),o.label=7;case 7:return o.trys.push([7,9,,10]),[4,this.getUserInfo({credentials:f})];case 8:return v=o.sent(),[3,10];case 9:return y=o.sent(),console.error("get user info error",y),[3,10];case 10:g={data:n(n({},e),{session:f,user:v}),error:null},o.label=11;case 11:t.delete("code"),t.delete("state"),t.delete("provider"),this.restoreUrlState(void 0===(null==s?void 0:s.search)?"?".concat(t.toString()):s.search,(null==s?void 0:s.hash)||location.hash);try{sessionStorage.removeItem(i)}catch(e){}return[2,g];case 12:return m=o.sent(),[2,{data:e,error:new p.AuthError(m)}];case 13:return[2]}})})},e.prototype.signInCustom=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}})})},e.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),i(this,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}})})},e.prototype.bindWithProvider=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(r){return[2,this.config.request(u.ApiUrls.PROVIDER_BIND_URL,{method:"POST",body:e,withCredentials:!0,getCredentials:t?function(){return t}:void 0})]})})},e.prototype.getUserProfile=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.getUserInfo(e)]})})},e.prototype.getUserInfo=function(e){var t,r,n;return void 0===e&&(e={}),i(this,void 0,Promise,function(){var i,s,a,u,c;return o(this,function(o){switch(o.label){case 0:return i=this.getParamsByVersion(e,"USER_ME_URL"),(null===(t=i.params)||void 0===t?void 0:t.query)&&(s=new d.default(i.params.query),i.url+="?".concat(s.toString())),[4,this.config.request(i.url,{method:"GET",withCredentials:!0,getCredentials:e.credentials?function(){return e.credentials}:void 0})];case 1:if((a=o.sent()).sub&&(a.uid=a.sub),null===(r=a.providers)||void 0===r?void 0:r.length)try{"undefined"!=typeof wx&&wx.getAccountInfoSync&&(u=null===(n=wx.getAccountInfoSync().miniProgram)||void 0===n?void 0:n.appId,(null==(c=a.providers.find(function(e){return e.id===u}))?void 0:c.provider_user_id)&&(a.open_id=c.provider_user_id))}catch(e){}return[2,a]}})})},e.prototype.getWedaUserInfo=function(){return i(this,void 0,Promise,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.config.request(u.ApiUrls.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,e.sent()]}})})},e.prototype.deleteMe=function(t){return i(this,void 0,Promise,function(){var r,n;return o(this,function(i){return r=this.getParamsByVersion(t,"USER_ME_URL"),n="".concat(r.url,"?").concat(e.parseParamsToSearch(r.params)),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]})})},e.prototype.hasLoginState=function(){return i(this,void 0,Promise,function(){return o(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}})})},e.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},e.prototype.getLoginState=function(){return i(this,void 0,Promise,function(){return o(this,function(e){return[2,this.config.credentialsClient.getCredentialsAsync()]})})},e.prototype.transByProvider=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})]})})},e.prototype.grantToken=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){return t=this.getParamsByVersion(e,"AUTH_TOKEN_URL"),[2,this.config.request(t.url,{method:"POST",body:t.params})]})})},e.prototype.getProviders=function(){return i(this,void 0,Promise,function(){return o(this,function(e){return[2,this.config.request(u.ApiUrls.PROVIDER_LIST,{method:"GET",withCredentials:!0})]})})},e.prototype.unbindProvider=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})]})})},e.prototype.checkPassword=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.editContact=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})]})})},e.prototype.setPassword=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})]})})},e.prototype.updatePasswordByOld=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return[4,this.sudo({password:e.old_password})];case 1:return t=r.sent(),[2,this.setPassword({sudo_token:t.sudo_token,new_password:e.new_password})]}})})},e.prototype.sudo=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.SUDO_URL),{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.sendVerificationCodeToCurrentUser=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return e.target="CUR_USER",[2,this.config.request(u.ApiUrls.VERIFICATION_URL,{method:"POST",body:e,withCredentials:!0,withCaptcha:!0})]})})},e.prototype.changeBoundProvider=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.PROVIDER_LIST,"/").concat(e.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:e.trans_token},withCredentials:!0})]})})},e.prototype.setUserProfile=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})]})})},e.prototype.updateUserBasicInfo=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.queryUserProfile=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){return t=new d.default(e),[2,this.config.request("".concat(u.ApiUrls.USER_QUERY_URL,"?").concat(t.toString()),{method:"GET",withCredentials:!0})]})})},e.prototype.setCustomSignFunc=function(e){this.getCustomSignTicketFn=e},e.prototype.signInWithCustomTicket=function(){return i(this,void 0,Promise,function(){var e,t;return o(this,function(r){switch(r.label){case 0:return(e=this.getCustomSignTicketFn)?[4,e()]:[2,Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"})];case 1:return t=r.sent(),[2,this.signInCustom({provider_id:"custom",ticket:t})]}})})},e.prototype.resetPassword=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.AUTH_RESET_PASSWORD,{method:"POST",body:e})]})})},e.prototype.authorize=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.authorizeDevice=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.deviceAuthorize=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.AUTH_GET_DEVICE_CODE,{method:"POST",body:e})]})})},e.prototype.authorizeInfo=function(t){return i(this,void 0,Promise,function(){var r,n,i;return o(this,function(o){switch(o.label){case 0:return r="".concat(u.ApiUrls.AUTHORIZE_INFO_URL,"?").concat(e.parseParamsToSearch(t)),n=!0,i=!1,[4,this.hasLoginState()];case 1:return o.sent()&&(i=!0,n=!1),[2,this.config.request(r,{method:"GET",withBasicAuth:n,withCredentials:i})]}})})},e.prototype.checkUsername=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})]})})},e.prototype.checkIfUserExist=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){return t=new d.default(e),[2,this.config.request("".concat(u.ApiUrls.CHECK_IF_USER_EXIST,"?").concat(t.toString()),{method:"GET"})]})})},e.prototype.loginScope=function(){return i(this,void 0,Promise,function(){return o(this,function(e){return[2,this.config.credentialsClient.getScope()]})})},e.prototype.loginGroups=function(){return i(this,void 0,Promise,function(){return o(this,function(e){return[2,this.config.credentialsClient.getGroups()]})})},e.prototype.refreshTokenForce=function(e){return i(this,void 0,void 0,function(){var t;return o(this,function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return t=r.sent(),[4,this.config.credentialsClient.refreshToken(n(n({},t),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return[2,r.sent()]}})})},e.prototype.getCredentials=function(){return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.config.credentialsClient.getCredentials()]})})},e.prototype.getPublicKey=function(){return i(this,void 0,Promise,function(){return o(this,function(e){return[2,this.config.request(u.ApiUrlsV2.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]})})},e.prototype.getEncryptParams=function(e){return i(this,void 0,Promise,function(){var t,r,n,i,s,a;return o(this,function(o){switch(o.label){case 0:return t=e.isEncrypt,delete e.isEncrypt,r=(0,l.deepClone)(e),[4,f(t,this.config.adapter)];case 1:if(!(n=o.sent()))return[2,e];i="",s="",o.label=2;case 2:return o.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(a=o.sent(),i=a.public_key,s=a.public_key_thumbprint,!i||!s)throw a;return[3,5];case 4:throw o.sent();case 5:return[2,{params:n.getEncryptInfo({publicKey:i,payload:r}),public_key_thumbprint:s}]}})})},e.prototype.getProviderSubType=function(){return i(this,void 0,Promise,function(){return o(this,function(e){return[2,this.config.request(u.ApiUrls.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})]})})},e.prototype.verifyCaptchaData=function(e){var t=e.token,r=e.key;return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.config.request(u.ApiUrls.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:r},withCredentials:!1})]})})},e.prototype.createCaptchaData=function(e){var t=e.state,r=e.redirect_uri,n=void 0===r?void 0:r;return i(this,void 0,void 0,function(){return o(this,function(e){return[2,this.config.request(u.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:n},withCredentials:!1})]})})},e.prototype.getMiniProgramCode=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.GET_MINIPROGRAM_QRCODE,{method:"POST",body:e})]})})},e.prototype.getMiniProgramQrCodeStatus=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,this.config.request(u.ApiUrls.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:e})]})})},e.prototype.getUserBehaviorLog=function(e){return i(this,void 0,Promise,function(){var t,r;return o(this,function(n){return t={LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"},r="".concat(u.ApiUrls.GET_USER_BEHAVIOR_LOG,"?").concat(t[e.type],"&limit=").concat(e.limit).concat(e.page_token?"&page_token=".concat(e.page_token):""),[2,this.config.request(r,{method:"GET",withCredentials:!0})]})})},e.prototype.modifyPassword=function(e){return i(this,void 0,Promise,function(){var t,r,n,i,s,a;return o(this,function(o){switch(o.label){case 0:return t="",r="",[4,f(!0,this.config.adapter)];case 1:if(!(n=o.sent()))throw new Error("do not support encrypt, a encrypt util required.");o.label=2;case 2:return o.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(i=o.sent(),t=i.public_key,r=i.public_key_thumbprint,!t||!r)throw i;return[3,5];case 4:throw o.sent();case 5:return s=e.password?n.getEncryptInfo({publicKey:t,payload:e.password}):"",a=n.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(u.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:e.user_id,encrypt_password:s,encrypt_new_password:a,public_key_thumbprint:r}})]}})})},e.prototype.modifyPasswordWithoutLogin=function(e){return i(this,void 0,Promise,function(){var t,r,n,i,s,a;return o(this,function(o){switch(o.label){case 0:return t="",r="",[4,f(!0,this.config.adapter)];case 1:if(!(n=o.sent()))throw new Error("do not support encrypt, a encrypt util required.");o.label=2;case 2:return o.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(i=o.sent(),t=i.public_key,r=i.public_key_thumbprint,!t||!r)throw i;return[3,5];case 4:throw o.sent();case 5:return s=e.password?n.getEncryptInfo({publicKey:t,payload:e.password}):"",a=n.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(u.ApiUrlsV2.AUTH_RESET_PASSWORD,{method:"POST",body:{username:e.username,password:s,new_password:a,public_key_thumbprint:r}})]}})})},e.prototype.restoreUrlState=function(e,t){if(void 0!==e)try{var r=new URL(window.location.href);r.search=e,r.hash=t||"",window.history.replaceState(null,"",r.toString()),window.location.replace(r.toString())}catch(e){}},e}();t.Auth=v},308:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.isAuthError=t.AuthError=t.AuthErrorCategory=void 0;var o,s=r(949);!function(e){e.PROVIDER_NOT_ENABLED="PROVIDER_NOT_ENABLED",e.INVALID_CREDENTIALS="INVALID_CREDENTIALS",e.USER_NOT_FOUND="USER_NOT_FOUND",e.USER_STATUS_ABNORMAL="USER_STATUS_ABNORMAL",e.SERVICE_ERROR="SERVICE_ERROR",e.INVALID_PARAMS="INVALID_PARAMS",e.AUTH_METHOD_MISMATCH="AUTH_METHOD_MISMATCH",e.RATE_LIMITED="RATE_LIMITED",e.CAPTCHA_REQUIRED="CAPTCHA_REQUIRED",e.CAPTCHA_INVALID="CAPTCHA_INVALID",e.MFA_REQUIRED="MFA_REQUIRED",e.PRECONDITION_FAILED="PRECONDITION_FAILED",e.VERIFICATION_FAILED="VERIFICATION_FAILED",e.UNKNOWN="UNKNOWN"}(o=t.AuthErrorCategory||(t.AuthErrorCategory={}));var a="https://tcb.cloud.tencent.com/dev?envId=#/identity/login-manage",u="https://docs.cloudbase.net/api-reference/webv3/initialization",c=function(e){function t(t,r){var n,i=this,c=t.error_description||t.message;return(i=e.call(this,c)||this).__isAuthError=!0,i.name="AuthError",i.status=t.error,i.code=String(t.error||t.error_code||"unknown").toLowerCase(),i.errorCode="number"==typeof t.error_code?t.error_code:"string"==typeof t.error_code&&parseInt(t.error_code,10)||void 0,i.requestId=t.requestId,i.category=function(e,t,r){if(!e&&!t&&!r)return o.UNKNOWN;try{var n=(e||"").toLowerCase(),i="string"==typeof r?parseInt(r,10):r;return i===s.AuthErrorCode.CAPTCHA_REQUIRED||t===s.ErrorType.CAPTCHA_REQUIRED?o.CAPTCHA_REQUIRED:i===s.AuthErrorCode.CAPTCHA_INVALID||t===s.ErrorType.CAPTCHA_INVALID?o.CAPTCHA_INVALID:i===s.AuthErrorCode.MFA_PHONE_REQUIRED||t===s.ErrorType.MFA_PHONE_REQUIRED?o.MFA_REQUIRED:i===s.AuthErrorCode.LOGIN_TYPE_DISABLED||t===s.ErrorType.LOGIN_TYPE_DISABLED?o.PROVIDER_NOT_ENABLED:i===s.AuthErrorCode.RESOURCE_EXHAUSTED||t===s.ErrorType.RESOURCE_EXHAUSTED?o.RATE_LIMITED:i===s.AuthErrorCode.INTERNAL||i===s.AuthErrorCode.UNAVAILABLE||i===s.AuthErrorCode.UNIMPLEMENTED||i===s.AuthErrorCode.ABORTED?o.SERVICE_ERROR:i===s.AuthErrorCode.NOT_FOUND?o.USER_NOT_FOUND:i===s.AuthErrorCode.UNAUTHENTICATED?o.INVALID_CREDENTIALS:i===s.AuthErrorCode.INVALID_ARGUMENT&&(n.includes("验证码")||n.includes("verification")||n.includes("verification_code")||n.includes("verification_id")||n.includes("does not match")||n.includes("token expired")||n.includes("token error")||n.includes("过期"))?o.VERIFICATION_FAILED:t===s.ErrorType.PROVIDER_NOT_ENABLED||t===s.ErrorType.LOGIN_METHOD_DISABLED||n.includes("身份源")||n.includes("开启")||n.includes("identity provider")||n.includes("provider not enabled")||n.includes("login method")||n.includes("登录方式")||n.includes("not enabled")||n.includes("未开启")||n.includes("未启用")||n.includes("请联系开发者")||n.includes("anonymous login is not enabled")||n.includes("匿名登录未开启")?o.PROVIDER_NOT_ENABLED:t===s.ErrorType.FAILED_PRECONDITION||i===s.AuthErrorCode.FAILED_PRECONDITION&&!n.includes("请联系开发者")?n.includes("不存在")||n.includes("not found")||n.includes("未注册")?o.USER_NOT_FOUND:o.PRECONDITION_FAILED:t===s.ErrorType.INVALID_PASSWORD||t===s.ErrorType.INVALID_GRANT||t===s.ErrorType.INVALID_VERIFICATION_CODE||t===s.ErrorType.INVALID_USERNAME_OR_PASSWORD||t===s.ErrorType.INVALID_CREDENTIALS||t===s.ErrorType.WRONG_PASSWORD||t===s.ErrorType.UNAUTHENTICATED||t===s.ErrorType.INVALID_TWO_FACTOR||t===s.ErrorType.INVALID_TWO_FACTOR_RECOVERY||t===s.ErrorType.PASSWORD_NOT_SET||n.includes("密码不正确")||n.includes("password")||n.includes("invalid_password")||n.includes("凭据")||n.includes("credentials")||n.includes("验证码")||n.includes("verification")||n.includes("invalid_verification_code")||n.includes("invalid_username_or_password")||n.includes("username or password")||n.includes("用户名或密码")||n.includes("wrong password")||n.includes("incorrect password")?o.INVALID_CREDENTIALS:t===s.ErrorType.NOT_FOUND||t===s.ErrorType.USER_NOT_FOUND||n.includes("用户不存在")||n.includes("not found")||n.includes("user not found")||n.includes("no such user")||n.includes("user does not exist")?o.USER_NOT_FOUND:t===s.ErrorType.USER_BLOCKED||t===s.ErrorType.USER_PENDING||t===s.ErrorType.UNDER_REVIEW||t===s.ErrorType.INVALID_STATUS||n.includes("被封禁")||n.includes("blocked")||n.includes("pending")||n.includes("审核")||n.includes("review")||n.includes("locked")||n.includes("已锁定")?o.USER_STATUS_ABNORMAL:t===s.ErrorType.SERVER_ERROR||t===s.ErrorType.UNAVAILABLE||t===s.ErrorType.TEMPORARILY_UNAVAILABLE||t===s.ErrorType.INTERNAL||t===s.ErrorType.UNREACHABLE||t===s.ErrorType.DEADLINE_EXCEEDED||t===s.ErrorType.DATA_LOSS||t===s.ErrorType.ABORTED||n.includes("network")||n.includes("timeout")||n.includes("timed out")||n.includes("超时")||n.includes("smtp is not set")||n.includes("sms sender does not config")?o.SERVICE_ERROR:t===s.ErrorType.INVALID_ARGUMENT||t===s.ErrorType.INVALID_REQUEST||t===s.ErrorType.INVALID_SCOPE||t===s.ErrorType.INVALID_REQUEST_URI||t===s.ErrorType.INVALID_REQUEST_OBJECT||i===s.AuthErrorCode.INVALID_ARGUMENT?o.INVALID_PARAMS:t===s.ErrorType.PERMISSION_DENIED||t===s.ErrorType.ACCESS_DENIED||t===s.ErrorType.UNAUTHORIZED_CLIENT?o.PROVIDER_NOT_ENABLED:o.UNKNOWN}catch(e){return t}}(c,i.status,i.errorCode),i.helpMessage=function(e,t){var r=(null==t?void 0:t.method)||"signIn",n={signInWithPassword:"「用户名密码登录」",signInAnonymously:"「匿名登录」",signInWithOtp:"「短信验证码登录」或「邮箱验证码登录」",signUp:"「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"对应的第三方身份源",signInWithIdToken:"对应的第三方身份源",signInWithOpenId:"「微信小程序 OpenID 登录」",signInWithPhoneAuth:"「微信小程序手机号授权登录」",signInWithCustomTicket:"「自定义登录」",getVerification:"「短信验证码登录」或「邮箱验证码登录」",verify:"「短信验证码登录」或「邮箱验证码登录」",verifyOtp:"「短信验证码登录」或「邮箱验证码登录」",resetPasswordForEmail:"「邮箱验证码登录」",reauthenticate:"「短信验证码登录」或「邮箱验证码登录」"}[r]||"对应的登录方式";switch(e){case o.PROVIDER_NOT_ENABLED:return"[CloudBase Auth] 登录方式未开启\n\n"+" 当前调用的 ".concat(r,"() 所需的登录方式尚未在云开发控制台启用。\n")+" 需要开启的登录方式:".concat(n,"\n")+"\n 请按以下步骤开启:\n"+" 1. 打开云开发控制台:".concat(a,"\n")+" 2. 选择对应的云开发环境\n 3. 进入「登录授权」页面,在「登录方式」或「身份源列表」中开启所需的登录方式\n\n 各登录方法与所需登录方式的对应关系:\n - signInWithPassword → 「用户名密码登录」\n - signInAnonymously → 「匿名登录」\n - signInWithOtp/signUp → 「短信验证码登录」或「邮箱验证码登录」\n - signInWithOAuth/signInWithIdToken → 对应的第三方身份源\n\n 如使用 CLI/MCP 工具,可通过 auth 工具查询和配置身份源状态。\n"+" 更多帮助请参考文档:".concat(u);case o.INVALID_CREDENTIALS:return"[CloudBase Auth] 凭据验证失败\n\n"+" 调用 ".concat(r,"() 时凭据校验未通过。\n")+"\n 请按优先级逐项排查:\n 1. 确认用户名/邮箱/手机号是否拼写正确、格式完整\n 2. 确认密码是否正确(注意大小写、特殊字符、前后空格)\n 3. 确认用户账号确实存在(可通过 auth.isUsernameRegistered() 检查)\n 4. 确认凭据参数来源可靠(环境变量、配置文件中的值是否已正确设置)\n 5. 如使用加密登录(is_encrypt: true),请确认公钥版本正确\n\n 如忘记密码,可通过 auth.resetPasswordForEmail() 重置密码。\n\n 提示:如果是 AI agent / 自动化测试场景,请确认 ENV_ID、USERNAME、PASSWORD\n 等环境变量已正确传入,且对应用户已在目标环境中注册。";case o.USER_NOT_FOUND:return"[CloudBase Auth] 用户不存在\n\n 请检查以下项目:\n 1. 确认用户名/邮箱/手机号是否正确\n 2. 确认是在正确的云开发环境(envId)下操作\n 3. 如果是新用户,请先通过 auth.signUp() 注册\n"+" 4. 也可在云开发控制台手动创建用户:".concat(a,"\n")+"\n 提示:不同环境(开发/测试/生产)的用户库是隔离的,请确认 envId 正确。";case o.USER_STATUS_ABNORMAL:return"[CloudBase Auth] 用户状态异常\n\n 当前用户账号可能处于以下状态之一:\n - 账号已被封禁\n - 账号正在审核中\n - 账号已被锁定(多次密码错误)\n\n"+" 请联系管理员在云开发控制台检查用户状态:".concat(a);case o.SERVICE_ERROR:return"[CloudBase Auth] 服务异常\n\n 请检查以下项目:\n 1. 网络连接是否正常\n 2. 云开发环境是否正常运行\n 3. 稍后重试,如持续失败请联系技术支持\n\n 提示:如果是超时错误,请检查网络环境和请求频率。\n 常见服务端错误:smtp 未配置、短信服务未配置、wedaapis 未设置等。";case o.INVALID_PARAMS:return"[CloudBase Auth] 参数错误\n\n 请检查传入的参数是否符合要求:\n - 不能同时输入手机号和邮箱\n - 手机号格式需正确(如 +86 开头)\n - 必须提供手机号或邮箱\n\n"+" 参考 API 文档确认各参数的格式和约束:".concat(u);case o.AUTH_METHOD_MISMATCH:return"[CloudBase Auth] 登录方式不匹配\n\n"+" 调用 ".concat(r,"() 时遇到错误,可能原因:\n")+" - 匿名登录失败后尝试了用户名密码登录,但凭据不正确或用户不存在\n - 应使用匿名登录但传入了密码参数\n - 应使用密码登录但未传入正确的凭据\n\n 建议:\n 1. 明确当前场景需要的登录方式:\n - 无需用户注册 → auth.signInAnonymously()\n - 有用户名和密码 → auth.signInWithPassword({ username, password })\n - 第三方平台 → auth.signInWithOAuth({ provider })\n 2. 不要在同一流程中混合使用不同的登录方式\n 3. 每种登录方式需要在控制台开启对应的身份源\n"+" 4. 控制台地址:".concat(a);case o.RATE_LIMITED:return"[CloudBase Auth] 发送频率受限\n\n 验证码发送过于频繁,已触发频率限制。\n\n 限制规则:\n - 手机号:每分钟最多 1 条,每天有上限\n - 邮箱:每分钟有上限,每天有上限(默认 50 条)\n\n 建议:\n 1. 检查 error.retryAfter 获取建议等待时间\n 2. 在 UI 中显示倒计时,防止用户重复点击\n 3. 如业务需要更高频率,请联系技术支持调整限额";case o.CAPTCHA_REQUIRED:return"[CloudBase Auth] 需要滑块验证码\n\n 当前操作触发了风控策略,需要完成滑块验证。\n\n 处理方式:\n 1. 调用滑块验证码 SDK 展示验证组件\n 2. 用户完成验证后,将 captcha_token 附带到请求中重新发送\n 3. 可通过 getVerification 的 options.withCaptcha 参数自动携带验证码";case o.CAPTCHA_INVALID:return"[CloudBase Auth] 滑块验证码校验失败\n\n 提交的验证码 token 校验未通过(可能已过期或 client_id 不匹配)。\n\n 处理方式:\n 1. 刷新滑块验证码,让用户重新验证\n 2. 确认 captcha 组件初始化的 client_id 与认证配置一致";case o.MFA_REQUIRED:return"[CloudBase Auth] 需要 MFA 验证\n\n 当前操作要求用户绑定手机号进行多因素认证 (MFA)。\n\n 处理方式:\n 1. 引导用户进入手机号绑定流程\n 2. 绑定完成后重新执行原操作\n 3. error 中可能包含 MFA 详情信息";case o.PRECONDITION_FAILED:return"[CloudBase Auth] 前置条件不满足\n\n 当前操作的前置条件不满足,常见原因:\n - 该手机号/邮箱已被其他账号绑定\n - 目标用户不存在或已存在(与 target 参数冲突)\n - 当前邮箱/手机号未注册用户\n\n 请根据 error.message 中的具体描述处理。";case o.VERIFICATION_FAILED:return'[CloudBase Auth] 验证码校验失败\n\n 验证码验证未通过,常见原因:\n - 验证码已过期(通常有效期为几分钟)\n - 验证码输入不正确\n - verification_id 无效或已被使用\n - 验证码不属于当前项目(project id does not match)\n\n 处理方式:\n 1. 提示用户"验证码已过期或不正确,请重新获取"\n 2. 调用 getVerification() 重新发送验证码\n 3. 确保 verification_id 与最新发送的验证码对应\n\n 注意:每次重新发送验证码后,之前的 verification_id 即失效。';default:return"[CloudBase Auth] 操作失败\n\n 如果问题持续存在,建议:\n"+" 1. 检查云开发控制台的认证配置:".concat(a,"\n")+" 2. 到官方问答社区提问:https://cnb.cool/tencent/cloud/cloudbase/community/-/issues\n"+" 3. 查阅文档:".concat(u)}}(i.category,r),i.loginMethodHint=(n=null==r?void 0:r.method)&&{signInWithPassword:"当前使用「用户名密码登录」,需确保:\n ✓ 控制台已开启「用户名密码登录」\n ✓ 用户已注册且凭据正确\n 如果不需要用户系统,建议改用 auth.signInAnonymously()",signInAnonymously:"当前使用「匿名登录」,需确保:\n ✓ 控制台已开启「匿名登录」\n 注意:匿名用户无需用户名密码,适用于快速体验或临时访问场景",signInWithOtp:"当前使用「OTP 验证码登录」,需确保:\n ✓ 控制台已开启「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"当前使用「第三方 OAuth 登录」,需确保:\n ✓ 控制台已配置并开启对应的第三方身份源"}[n]||"",i.category===o.RATE_LIMITED&&(i.retryAfter=t.retry_after||t.retryAfter||void 0),i}return i(t,e),t.prototype.toJSON=function(){return{name:this.name,message:this.message,code:this.code,errorCode:this.errorCode,status:this.status,requestId:this.requestId,category:this.category,retryAfter:this.retryAfter}},t}(Error);t.AuthError=c,t.isAuthError=function(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}},949:function(e,t){var r,n,i,o,s,a;Object.defineProperty(t,"__esModule",{value:!0}),t.VerificationUsage=t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.EVENTS=t.AUTH_STATE_CHANGED_TYPE=t.LOGIN_STATE_CHANGED_TYPE=t.AuthErrorCode=t.ErrorType=t.VerificationUsages=t.ApiUrlsV2=t.ApiUrls=t.AUTH_API_PREFIX=void 0,t.AUTH_API_PREFIX="/auth",(a=t.ApiUrls||(t.ApiUrls={})).AUTH_SIGN_UP_URL="/v1/signup",a.AUTH_TOKEN_URL="/v1/token",a.AUTH_REVOKE_URL="/v1/revoke",a.WEDA_USER_URL="/v1/plugin/weda/userinfo",a.AUTH_RESET_PASSWORD="/v1/reset",a.AUTH_GET_DEVICE_CODE="/v1/device/code",a.CHECK_USERNAME="/v1/checkUsername",a.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",a.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",a.AUTH_SIGN_IN_URL="/v1/signin",a.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",a.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",a.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",a.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",a.PROVIDER_TOKEN_URL="/v1/provider/token",a.PROVIDER_URI_URL="/v1/provider/uri",a.USER_ME_URL="/v1/user/me",a.AUTH_SIGNOUT_URL="/v1/user/signout",a.USER_QUERY_URL="/v1/user/query",a.USER_PRIFILE_URL="/v1/user/profile",a.USER_BASIC_EDIT_URL="/v1/user/basic/edit",a.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",a.PROVIDER_LIST="/v1/user/provider",a.PROVIDER_BIND_URL="/v1/user/provider/bind",a.PROVIDER_UNBIND_URL="/v1/user/provider",a.CHECK_PWD_URL="/v1/user/sudo",a.SUDO_URL="/v1/user/sudo",a.BIND_CONTACT_URL="/v1/user/contact",a.AUTH_SET_PASSWORD="/v1/user/password",a.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",a.AUTHORIZE_URL="/v1/user/authorize",a.AUTHORIZE_INFO_URL="/v1/user/authorize/info",a.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",a.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",a.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",a.VERIFICATION_URL="/v1/verification",a.VERIFY_URL="/v1/verification/verify",a.CAPTCHA_DATA_URL="/v1/captcha/data",a.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",a.GET_CAPTCHA_URL="/v1/captcha/init",a.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",a.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status",(s=t.ApiUrlsV2||(t.ApiUrlsV2={})).AUTH_SIGN_IN_URL="/v2/signin/username",s.AUTH_TOKEN_URL="/v2/token",s.USER_ME_URL="/v2/user/me",s.VERIFY_URL="/v2/signin/verificationcode",s.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",s.AUTH_PUBLIC_KEY="/v2/signin/publichkey",s.AUTH_RESET_PASSWORD="/v2/signin/password/update",(o=t.VerificationUsages||(t.VerificationUsages={})).REGISTER="REGISTER",o.SIGN_IN="SIGN_IN",o.PASSWORD_RESET="PASSWORD_RESET",o.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",o.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE",(i=t.ErrorType||(t.ErrorType={})).UNREACHABLE="unreachable",i.LOCAL="local",i.CANCELLED="cancelled",i.UNKNOWN="unknown",i.UNAUTHENTICATED="unauthenticated",i.RESOURCE_EXHAUSTED="resource_exhausted",i.FAILED_PRECONDITION="failed_precondition",i.INVALID_ARGUMENT="invalid_argument",i.DEADLINE_EXCEEDED="deadline_exceeded",i.NOT_FOUND="not_found",i.ALREADY_EXISTS="already_exists",i.PERMISSION_DENIED="permission_denied",i.ABORTED="aborted",i.OUT_OF_RANGE="out_of_range",i.UNIMPLEMENTED="unimplemented",i.INTERNAL="internal",i.UNAVAILABLE="unavailable",i.DATA_LOSS="data_loss",i.INVALID_PASSWORD="invalid_password",i.PASSWORD_NOT_SET="password_not_set",i.INVALID_STATUS="invalid_status",i.USER_PENDING="user_pending",i.USER_BLOCKED="user_blocked",i.INVALID_VERIFICATION_CODE="invalid_verification_code",i.TWO_FACTOR_REQUIRED="two_factor_required",i.INVALID_TWO_FACTOR="invalid_two_factor",i.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",i.UNDER_REVIEW="under_review",i.INVALID_REQUEST="invalid_request",i.UNAUTHORIZED_CLIENT="unauthorized_client",i.ACCESS_DENIED="access_denied",i.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",i.INVALID_SCOPE="invalid_scope",i.INVALID_GRANT="invalid_grant",i.SERVER_ERROR="server_error",i.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",i.INTERACTION_REQUIRED="interaction_required",i.LOGIN_REQUIRED="login_required",i.ACCOUNT_SELECTION_REQUIRED="account_selection_required",i.CONSENT_REQUIRED="consent_required",i.INVALID_REQUEST_URI="invalid_request_uri",i.INVALID_REQUEST_OBJECT="invalid_request_object",i.REQUEST_NOT_SUPPORTED="request_not_supported",i.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",i.REGISTRATION_NOT_SUPPORTED="registration_not_supported",i.CAPTCHA_REQUIRED="captcha_required",i.CAPTCHA_INVALID="captcha_invalid",i.PROVIDER_NOT_ENABLED="provider_not_enabled",i.LOGIN_METHOD_DISABLED="login_method_disabled",i.INVALID_USERNAME_OR_PASSWORD="invalid_username_or_password",i.INVALID_CREDENTIALS="invalid_credentials",i.WRONG_PASSWORD="wrong_password",i.USER_NOT_FOUND="user_not_found",i.MFA_PHONE_REQUIRED="mfa_phone_required",i.LOGIN_TYPE_DISABLED="login_type_disabled",i.PROVIDER_ERROR="provider_error",(n=t.AuthErrorCode||(t.AuthErrorCode={}))[n.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",n[n.NOT_FOUND=5]="NOT_FOUND",n[n.PERMISSION_DENIED=7]="PERMISSION_DENIED",n[n.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",n[n.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",n[n.ABORTED=10]="ABORTED",n[n.UNIMPLEMENTED=12]="UNIMPLEMENTED",n[n.INTERNAL=13]="INTERNAL",n[n.UNAVAILABLE=14]="UNAVAILABLE",n[n.UNAUTHENTICATED=16]="UNAUTHENTICATED",n[n.CAPTCHA_REQUIRED=4001]="CAPTCHA_REQUIRED",n[n.CAPTCHA_INVALID=4002]="CAPTCHA_INVALID",n[n.PROVIDER_ERROR=4019]="PROVIDER_ERROR",n[n.UNAUTHORIZED_CLIENT=4022]="UNAUTHORIZED_CLIENT",n[n.MFA_PHONE_REQUIRED=4042]="MFA_PHONE_REQUIRED",n[n.LOGIN_TYPE_DISABLED=4045]="LOGIN_TYPE_DISABLED",t.LOGIN_STATE_CHANGED_TYPE={SIGN_OUT:"sign_out",SIGN_IN:"sign_in",CREDENTIALS_ERROR:"credentials_error"},t.AUTH_STATE_CHANGED_TYPE={SIGNED_OUT:"SIGNED_OUT",SIGNED_IN:"SIGNED_IN",INITIAL_SESSION:"INITIAL_SESSION",PASSWORD_RECOVERY:"PASSWORD_RECOVERY",TOKEN_REFRESHED:"TOKEN_REFRESHED",USER_UPDATED:"USER_UPDATED",BIND_IDENTITY:"BIND_IDENTITY"},t.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",AUTH_STATE_CHANGED:"authStateChanged"},t.OAUTH_TYPE={SIGN_IN:"sign_in",BIND_IDENTITY:"bind_identity"},t.DEFAULT_NODE_ACCESS_SCOPE="node-sdk-scope",(r=t.VerificationUsage||(t.VerificationUsage={})).EMAIL="email",r.RECOVERY="recovery",r.REAUTHENTICATION="reauthentication"},538:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},84:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.openURIWithCallback=void 0;var s=r(689),a=r(616),u=function(e,t){var r;return function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];clearTimeout(r),r=setTimeout(function(){return e.apply(null,n)},t)}},c=new s.CloudbaseEventEmitter,h="resolveCaptchaData",l="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",d="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",p="background:#6c757d;cursor:not-allowed";t.openURIWithCallback=function(e,t){return i(void 0,void 0,Promise,function(){var r,s,f,v;return o(this,function(g){return r=(0,a.parseCaptcha)(e),s=r.captchaData,f=r.state,v=r.token,function(e){var t=e.oauthInstance,r=e.captchaState,s="captcha-image",a=function(){return i(void 0,void 0,void 0,function(){var e,i;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,t.createCaptchaData({state:r.state})];case 1:return e=o.sent(),r=n(n({},r),{captchaData:e.data,token:e.token}),document.getElementById(s).src=e.data,[3,3];case 2:return i=o.sent(),console.error("刷新图形验证码失败",i),[3,3];case 3:return[2]}})})},f=function(e,t,r){var n=document.createElement(e);return t&&(n.style.cssText=t),r&&(n.textContent=r),n},v=f("div","position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999"),g=f("div","position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:320px;padding:20px;background:#fff;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.2);z-index:1000");g.appendChild(f("p","margin-bottom:15px","请输入你看到的字符:"));var y=f("div","display:flex;align-items:center;justify-content:space-between;margin-bottom:15px"),m=f("img","width:100%;height:auto;border:1px solid #eee");m.id=s,m.src=r.captchaData,y.appendChild(m);var _=f("button",l,"刷新");_.onclick=u(function(){return i(void 0,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:_.textContent="加载中...",_.disabled=!0,_.style.cssText="".concat(l,";").concat(p),e.label=1;case 1:return e.trys.push([1,,3,4]),[4,a()];case 2:return e.sent(),[3,4];case 3:return _.textContent="刷新",_.disabled=!1,_.style.cssText=l,[7];case 4:return[2]}})})},500),y.appendChild(_),g.appendChild(y);var E=f("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");E.type="text",E.placeholder="输入字符",E.maxLength=4,g.appendChild(E);var b=f("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");g.appendChild(b);var I=function(e){b.textContent=e,b.style.display="block"},A=f("button",d,"确定");A.onclick=u(function(){return i(void 0,void 0,void 0,function(){var e,n,i,s;return o(this,function(o){switch(o.label){case 0:if(!(e=E.value.trim()))return I("请输入字符"),[2];b.style.display="none",A.textContent="验证中...",A.disabled=!0,A.style.cssText="".concat(d,";").concat(p),o.label=1;case 1:return o.trys.push([1,3,5,6]),[4,t.verifyCaptchaData({token:r.token,key:e})];case 2:return n=o.sent(),c.fire(h,n),console.log("图形验证码校验成功"),document.body.removeChild(v),document.body.removeChild(g),[3,6];case 3:return i=o.sent(),console.error("图形验证码校验失败",i),s=i.error_description||"图形验证码校验失败",I(s),E.value="",E.focus(),[4,a()];case 4:return o.sent(),[3,6];case 5:return A.textContent="确定",A.disabled=!1,A.style.cssText=d,[7];case 6:return[2]}})})},500),g.appendChild(A),document.body.appendChild(v),document.body.appendChild(g)}({oauthInstance:t,captchaState:{captchaData:s,state:f,token:v}}),[2,new Promise(function(e){console.log("等待图形验证码校验结果..."),c.on(h,function(t){e(null==t?void 0:t.data)})})]})})}},462:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.Captcha=void 0;var o=r(949),s=r(257),a=r(425),u=r(84),c=function(){function e(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=s.defaultStorage),this.config=e,this.tokenSectionName="captcha_".concat(e.clientId||e.env)}return e.prototype.isMatch=function(){var e,t,r;return(null===(r=null===(t=null===(e=this.config)||void 0===e?void 0:e.adapter)||void 0===t?void 0:t.isMatch)||void 0===r?void 0:r.call(t))||(0,a.isMp)()},e.prototype.request=function(e,t){return n(this,void 0,Promise,function(){var r,n,s,a;return i(this,function(i){switch(i.label){case 0:return t||(t={}),t.method||(t.method="GET"),r="".concat(t.method,":").concat(e),n=e,t.withCaptcha?[4,this.appendCaptchaTokenToURL(e,r,!1)]:[3,2];case 1:n=i.sent(),i.label=2;case 2:return i.trys.push([2,4,,7]),[4,this.config.request(n,t)];case 3:return s=i.sent(),[3,7];case 4:return(a=i.sent()).error!==o.ErrorType.CAPTCHA_REQUIRED&&a.error!==o.ErrorType.CAPTCHA_INVALID?[3,6]:[4,this.appendCaptchaTokenToURL(e,r,a.error===o.ErrorType.CAPTCHA_INVALID)];case 5:return e=i.sent(),[2,this.config.request(e,t)];case 6:return[2,Promise.reject(a)];case 7:return[2,s]}})})},e.prototype.getDefaultOpenURIWithCallback=function(){var e=this;return function(t){return(0,u.openURIWithCallback)(t,e.config.oauthInstance)}},e.prototype.getCaptchaToken=function(e,t){return n(this,void 0,Promise,function(){var r,n,s,a;return i(this,function(i){switch(i.label){case 0:return e?[3,2]:[4,this.findCaptchaToken()];case 1:if(r=i.sent())return[2,r];i.label=2;case 2:return[4,this.config.request(o.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:""},withCredentials:!1})];case 3:return n=i.sent(),s="".concat(n.data,"?state=").concat(encodeURIComponent(t),"&token=").concat(encodeURIComponent(n.token)),[4,this.config.openURIWithCallback(s)];case 4:return a=i.sent(),this.saveCaptchaToken(a),[2,a.captcha_token]}})})},e.prototype.appendCaptchaTokenToURL=function(e,t,r){return n(this,void 0,Promise,function(){var n;return i(this,function(i){switch(i.label){case 0:return[4,this.getCaptchaToken(r,t)];case 1:return n=i.sent(),e.indexOf("?")>0?e+="&captcha_token=".concat(n):e+="?captcha_token=".concat(n),[2,e]}})})},e.prototype.saveCaptchaToken=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return e.expires_at=new Date(Date.now()+1e3*(e.expires_in-10)),t=JSON.stringify(e),[4,this.config.storage.setItem(this.tokenSectionName,t)];case 1:return r.sent(),[2]}})})},e.prototype.findCaptchaToken=function(){return n(this,void 0,Promise,function(){var e,t;return i(this,function(r){switch(r.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=r.sent()))return[3,5];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),t.expires_at<new Date?[2,null]:[2,t.captcha_token];case 3:return r.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),[2,null];case 5:return[2,null]}})})},e}();t.Captcha=c},722:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseOAuth=t.VerificationUsage=t.AuthErrorCode=t.AUTH_STATE_CHANGED_TYPE=t.EVENTS=t.LOGIN_STATE_CHANGED_TYPE=t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.AUTH_API_PREFIX=t.weAppJwtDecodeAll=t.authModels=t.isAuthError=t.AuthErrorCategory=t.AuthError=t.Auth=void 0;var a=r(257),u=r(413),c=r(949),h=r(413);Object.defineProperty(t,"Auth",{enumerable:!0,get:function(){return h.Auth}});var l=r(308);Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return l.AuthError}}),Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return l.AuthErrorCategory}}),Object.defineProperty(t,"isAuthError",{enumerable:!0,get:function(){return l.isAuthError}}),t.authModels=s(r(538));var d=r(344);Object.defineProperty(t,"weAppJwtDecodeAll",{enumerable:!0,get:function(){return d.weAppJwtDecodeAll}});var p=r(949);Object.defineProperty(t,"AUTH_API_PREFIX",{enumerable:!0,get:function(){return p.AUTH_API_PREFIX}}),Object.defineProperty(t,"OAUTH_TYPE",{enumerable:!0,get:function(){return p.OAUTH_TYPE}}),Object.defineProperty(t,"DEFAULT_NODE_ACCESS_SCOPE",{enumerable:!0,get:function(){return p.DEFAULT_NODE_ACCESS_SCOPE}}),Object.defineProperty(t,"LOGIN_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return p.LOGIN_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"EVENTS",{enumerable:!0,get:function(){return p.EVENTS}}),Object.defineProperty(t,"AUTH_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return p.AUTH_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"AuthErrorCode",{enumerable:!0,get:function(){return p.AuthErrorCode}}),Object.defineProperty(t,"VerificationUsage",{enumerable:!0,get:function(){return p.VerificationUsage}});var f=function(){function e(e){var t=e.apiOrigin,r=e.getApiOrigin,i=e.apiPath,o=void 0===i?c.AUTH_API_PREFIX:i,s=e.clientId,h=e.env,l=e.storage,d=e.request,p=e.baseRequest,f=e.anonymousSignInFunc,v=e.wxCloud,g=e.adapter,y=e.onCredentialsError,m=e.headers,_=e.i18n,E=e.useWxCloud,b=e.eventBus,I=e.detectSessionInUrl,A=e.debug;if(this.detectSessionInUrl=null!=I&&I,this.oauth2client=new a.OAuth2Client({apiOrigin:t,getApiOrigin:r,apiPath:o,clientId:s,env:h,storage:l,baseRequest:p||d,anonymousSignInFunc:f,wxCloud:v,onCredentialsError:y,headers:m||{},i18n:_,useWxCloud:E,eventBus:b,debug:A}),this.authApi=new u.Auth(n(n({credentialsClient:this.oauth2client},e),{request:d?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:g})),I)this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));else try{var w=new URL(window.location.href),T=w.searchParams.get("code"),S=w.searchParams.get("state"),O=JSON.parse(sessionStorage.getItem(S)||"null");T&&S&&(null==O?void 0:O.hash)&&(w.hash=O.hash,window.history.replaceState(null,"",w.toString()),window.location.replace(w.toString()))}catch(e){}}return e.prototype.initializeSession=function(e){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(e),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))},e}();t.CloudbaseOAuth=f},877:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.Syntax=t.ErrorType=void 0;var n,i=r(949);Object.defineProperty(t,"ErrorType",{enumerable:!0,get:function(){return i.ErrorType}}),(n=t.Syntax||(t.Syntax={})).CLIENT_ID="client_id",n.CLIENT_SECRET="client_secret",n.RESPONSE_TYPE="response_type",n.SCOPE="scope",n.STATE="state",n.REDIRECT_URI="redirect_uri",n.ERROR="error",n.ERROR_DESCRIPTION="error_description",n.ERROR_URI="error_uri",n.GRANT_TYPE="grant_type",n.CODE="code",n.ACCESS_TOKEN="access_token",n.TOKEN_TYPE="token_type",n.EXPIRES_IN="expires_in",n.USERNAME="username",n.PASSWORD="password",n.REFRESH_TOKEN="refresh_token"},257:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.OAuth2Client=t.defaultStorage=t.generateRequestId=t.toResponseError=t.defaultRequest=void 0;var a=r(877),u=r(949),c=r(873),h=r(631),l=r(547),d=r(344),p=r(425),f=r(683),v="x-request-id",g="x-device-id",y="device_id";function m(){return(0,c.uuidv4)()}t.defaultRequest=function(e,t){return i(this,void 0,Promise,function(){var r,n,i,s,u;return o(this,function(o){switch(o.label){case 0:r=null,n=null,o.label=1;case 1:return o.trys.push([1,4,,5]),(i=Object.assign({},t)).method||(i.method="GET"),i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body)),[4,fetch(e,i)];case 2:return[4,o.sent().json()];case 3:return(null==(s=o.sent())?void 0:s.error)?(n=s).error_uri=new URL(e).pathname:r=s,[3,5];case 4:return u=o.sent(),n={error:a.ErrorType.UNREACHABLE,error_description:u.message,error_uri:new URL(e).pathname},[3,5];case 5:if(n)throw n;return[2,r]}})})},t.toResponseError=function(e,t){var r,n=t||{};if(e instanceof Error)r={error:n.error||a.ErrorType.LOCAL,error_description:n.error_description||e.message,error_uri:n.error_uri,details:n.details||e.stack};else{var i=e||{};r={error:n.error||i.error||a.ErrorType.LOCAL,error_description:n.error_description||i.error_description,error_uri:n.error_uri||i.error_uri,details:n.details||i.details}}return r},t.generateRequestId=m;var _=function(){function e(e){this._env=(null==e?void 0:e.env)||""}return e.prototype.getItem=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,window.localStorage.getItem("".concat(e).concat(this._env))]})})},e.prototype.removeItem=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return window.localStorage.removeItem("".concat(e).concat(this._env)),[2]})})},e.prototype.setItem=function(e,t){return i(this,void 0,Promise,function(){return o(this,function(r){return window.localStorage.setItem("".concat(e).concat(this._env),t),[2]})})},e.prototype.getItemSync=function(e){return window.localStorage.getItem("".concat(e).concat(this._env))},e.prototype.removeItemSync=function(e){window.localStorage.removeItem("".concat(e).concat(this._env))},e.prototype.setItemSync=function(e,t){window.localStorage.setItem("".concat(e).concat(this._env),t)},e}();function E(e){var t=!0;return(null==e?void 0:e.expires_at)&&(null==e?void 0:e.access_token)&&(t=e.expires_at<new Date),t}t.defaultStorage=new _;var b=function(){function e(e){this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=e.tokenSectionName,this.storage=e.storage,this.clientId=e.clientId,this.singlePromise=new l.SinglePromise({clientId:this.clientId}),this.credentials=e.credentials||null}return e.prototype.getStorageCredentialsSync=function(){var e=null,t=this.storage.getItemSync(this.tokenSectionName);if(null!=t)try{(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at))}catch(t){this.storage.removeItem(this.tokenSectionName),e=null}return e},e.prototype.setCredentials=function(e){return i(this,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return(null==e?void 0:e.expires_in)?((null==e?void 0:e.expires_at)||(e.expires_at=new Date(Date.now()+1e3*(e.expires_in-30))),this.storage?(t=JSON.stringify(e),[4,this.storage.setItem(this.tokenSectionName,t)]):[3,2]):[3,3];case 1:r.sent(),r.label=2;case 2:return this.credentials=e,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:r.sent(),r.label=5;case 5:this.credentials=null,r.label=6;case 6:return[2]}})})},e.prototype.setAccessKeyCredentials=function(e){this.accessKeyCredentials=e,e.scope===u.DEFAULT_NODE_ACCESS_SCOPE&&(this.credentials=e)},e.prototype.getCredentials=function(){return i(this,void 0,Promise,function(){var e=this;return o(this,function(t){return[2,this.singlePromise.run("getCredentials",function(){return i(e,void 0,void 0,function(){var e,t;return o(this,function(r){switch(r.label){case 0:return E(this.credentials)?[4,this.getStorageCredentials()]:[3,2];case 1:if(e=r.sent(),t=e.credentials,e.isAccessKeyCredentials)return[2,t];this.credentials=t,r.label=2;case 2:return[2,this.credentials]}})})})]})})},e.prototype.getStorageCredentials=function(){return i(this,void 0,Promise,function(){var e=this;return o(this,function(t){return[2,this.singlePromise.run("_getStorageCredentials",function(){return i(e,void 0,void 0,function(){var e,t,r;return o(this,function(n){switch(n.label){case 0:return e=null,t=!1,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(!(r=n.sent()))return[3,6];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(e=JSON.parse(r))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),e=null,[3,5];case 5:return[3,7];case 6:e=this.accessKeyCredentials||null,t=!0,n.label=7;case 7:return[2,{credentials:e,isAccessKeyCredentials:t}]}})})})]})})},e}();t.OAuth2Client=function(){function e(r){var n,i=this;this.initializePromise=null,this.lockAcquired=!1,this.pendingInLock=[],this.singlePromise=null,r.clientSecret||(r.clientSecret=""),!r.clientId&&r.env&&(r.clientId=r.env),this.apiOrigin=r.apiOrigin,this.getApiOriginFunc=r.getApiOrigin,this.apiPath=r.apiPath||u.AUTH_API_PREFIX,this.clientId=r.clientId,this.i18n=r.i18n,this.eventBus=r.eventBus,this.singlePromise=new l.SinglePromise({clientId:this.clientId}),this.retry=this.formatRetry(r.retry,e.defaultRetry),r.baseRequest?this.baseRequest=r.baseRequest:this.baseRequest=t.defaultRequest,this.tokenInURL=r.tokenInURL,this.headers=r.headers,this.storage=r.storage||t.defaultStorage,this.localCredentials=new b({tokenSectionName:"credentials_".concat(r.clientId),storage:this.storage,clientId:r.clientId}),this.clientSecret=r.clientSecret,r.clientId&&(this.basicAuth="Basic ".concat((0,d.weBtoa)("".concat(r.clientId,":").concat(this.clientSecret)))),this.wxCloud=r.wxCloud;try{(0,p.isMp)()&&(this.useWxCloud=r.useWxCloud,void 0===this.wxCloud&&r.env&&(wx.cloud.init({env:r.env}),this.wxCloud=wx.cloud))}catch(e){}this.refreshTokenFunc=r.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=r.anonymousSignInFunc,this.onCredentialsError=r.onCredentialsError,this.getInitialSession=r.getInitialSession,this.onInitialSessionObtained=r.onInitialSessionObtained,this.logDebugMessages=null!==(n=r.debug)&&void 0!==n&&n,f.langEvent.bus.on(f.langEvent.LANG_CHANGE_EVENT,function(e){var t;i.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||i.i18n})}return e.prototype.setGetInitialSession=function(e){this.getInitialSession=e},e.prototype.setOnInitialSessionObtained=function(e){this.onInitialSessionObtained=e},e.prototype.initialize=function(e){return i(this,void 0,Promise,function(){var t=this;return o(this,function(r){switch(r.label){case 0:return this.initializePromise?[4,this.initializePromise]:[3,2];case 1:case 3:case 5:return[2,r.sent()];case 2:return void 0===e?[3,4]:(this.initializePromise=e,[4,this.initializePromise]);case 4:return this.initializePromise=i(t,void 0,void 0,function(){var e=this;return o(this,function(t){switch(t.label){case 0:return[4,this._acquireLock(-1,function(){return i(e,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,this._initialize()];case 1:return[2,e.sent()]}})})})];case 1:return[2,t.sent()]}})}),[4,this.initializePromise]}})})},e.prototype.setCredentials=function(e){return i(this,void 0,Promise,function(){var t=this;return o(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[2,this._acquireLock(-1,function(){return i(t,void 0,void 0,function(){return o(this,function(t){return[2,this.localCredentials.setCredentials(e)]})})})]}})})},e.prototype.setAccessKeyCredentials=function(e){return this.localCredentials.setAccessKeyCredentials(e)},e.prototype.getAccessToken=function(){return i(this,void 0,Promise,function(){var e,t;return o(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[4,this.getCredentials()];case 2:return(null==(e=r.sent())?void 0:e.scope)===u.DEFAULT_NODE_ACCESS_SCOPE||(null==e?void 0:e.access_token)?[2,Promise.resolve(e.access_token)]:(t={error:a.ErrorType.UNAUTHENTICATED},[2,Promise.reject(t)])}})})},e.prototype.request=function(t,r){var s,u;return i(this,void 0,Promise,function(){var i,c,h,l,d,p,f,y,_,E;return o(this,function(o){switch(o.label){case 0:return r||(r={}),i=this.formatRetry(r.retry,this.retry),r.headers=n(n({},r.headers),((E={})[null===(s=this.i18n)||void 0===s?void 0:s.LANG_HEADER_KEY]=null===(u=this.i18n)||void 0===u?void 0:u.lang,E)),this.headers&&(r.headers=n(n({},this.headers),r.headers)),r.headers[v]||(r.headers[v]=m()),r.headers[g]?[3,2]:[4,this.getDeviceId()];case 1:c=o.sent(),r.headers[g]=c,o.label=2;case 2:return(null==r?void 0:r.withBasicAuth)&&this.basicAuth&&(r.headers.Authorization=this.basicAuth),(null==r?void 0:r.withCredentials)?r.getCredentials?[4,r.getCredentials()]:[3,4]:[3,7];case 3:return l=o.sent(),[3,6];case 4:return[4,this.getCredentials()];case 5:l=o.sent(),o.label=6;case 6:return(h=l)&&(this.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+="access_token=".concat(h.access_token)):r.headers.Authorization="".concat(h.token_type," ").concat(h.access_token)),[3,8];case 7:this.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+="client_id=".concat(this.clientId)),o.label=8;case 8:t.startsWith("/")&&(d=this.getApiOriginFunc?this.getApiOriginFunc():this.apiOrigin,t="".concat(d).concat(this.apiPath).concat(t)),p=null,f=i+1,y=0,o.label=9;case 9:if(!(y<f))return[3,21];o.label=10;case 10:return o.trys.push([10,15,,18]),r.useWxCloud||this.useWxCloud?[4,this.wxCloudCallFunction(t,r)]:[3,12];case 11:return p=o.sent(),[3,14];case 12:return[4,this.baseRequest(t,r)];case 13:p=o.sent(),o.label=14;case 14:if(null==p?void 0:p.code)throw{error:p.code,error_description:p.message,error_uri:new URL(t).pathname};return[3,21];case 15:_=o.sent();try{_.requestId=_.requestId||r.headers[v]||""}catch(e){}return r.withCredentials&&_&&_.error===a.ErrorType.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,17];case 16:return o.sent(),[2,Promise.reject(_)];case 17:return y!==i&&_&&"unreachable"===_.error?[3,18]:[2,Promise.reject(_)];case 18:return[4,this.sleep(e.retryInterval)];case 19:o.sent(),o.label=20;case 20:return y++,[3,9];case 21:return[2,p]}})})},e.prototype.wxCloudCallFunction=function(e,t){var r;return i(this,void 0,Promise,function(){var i,s,u,c,l;return o(this,function(o){switch(o.label){case 0:i=null,s=null,o.label=1;case 1:o.trys.push([1,7,,8]),u="",o.label=2;case 2:return o.trys.push([2,4,,5]),[4,wx.getRendererUserAgent()];case 3:return u=o.sent(),[3,5];case 4:return o.sent(),[3,5];case 5:return[4,this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:e,method:t.method,headers:n({origin:"https://servicewechat.com","User-Agent":u},t.headers),body:t.body}})];case 6:return c=o.sent().result,(null===(r=null==c?void 0:c.body)||void 0===r?void 0:r.error_code)?(s=null==c?void 0:c.body).error_uri=(0,h.getPathName)(e):i=null==c?void 0:c.body,[3,8];case 7:return l=o.sent(),s={error:a.ErrorType.UNREACHABLE,error_description:l.message,error_uri:(0,h.getPathName)(e)},[3,8];case 8:if(s)throw s;return[2,i]}})})},e.prototype.getCredentials=function(){return i(this,void 0,Promise,function(){var e=this;return o(this,function(t){switch(t.label){case 0:return[4,this.initializePromise];case 1:return t.sent(),[2,this._acquireLock(-1,function(){return i(e,void 0,void 0,function(){return o(this,function(e){return[2,this._getCredentials()]})})})]}})})},e.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},e.prototype.getCredentialsAsync=function(){return this.getCredentials()},e.prototype.getScope=function(){var e;return i(this,void 0,Promise,function(){var t,r;return o(this,function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=n.sent())?[2,t.scope]:(r="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}})})},e.prototype.getGroups=function(){var e;return i(this,void 0,Promise,function(){var t,r;return o(this,function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=n.sent())?[2,t.groups]:(r="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}})})},e.prototype.refreshToken=function(e,t){return i(this,void 0,Promise,function(){var r=this;return o(this,function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[2,this._acquireLock(-1,function(){return i(r,void 0,void 0,function(){return o(this,function(r){return[2,this._refreshToken(e,t)]})})})]}})})},e.prototype._refreshToken=function(e,t){return i(this,void 0,Promise,function(){var r=this;return o(this,function(n){return[2,this.singlePromise.run("_refreshToken",function(){return i(r,void 0,void 0,function(){var r,n,i,s,c,h,l;return o(this,function(o){switch(o.label){case 0:if((null==e?void 0:e.scope)===u.DEFAULT_NODE_ACCESS_SCOPE)return[2,e];if(!e||!e.refresh_token)return i="no refresh token found in credentials",null===(s=this.onCredentialsError)||void 0===s||s.call(this,{msg:i}),[2,this.unAuthenticatedError(i)];o.label=1;case 1:return o.trys.push([1,4,,7]),[4,this.refreshTokenFunc(e.refresh_token,e)];case 2:return r=o.sent(),[4,this.localCredentials.setCredentials(r)];case 3:return o.sent(),null===(c=this.eventBus)||void 0===c||c.fire(u.EVENTS.AUTH_STATE_CHANGED,{event:u.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED}),[2,r];case 4:if(n=o.sent(),null==t?void 0:t.throwError)throw n;return n.error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return o.sent(),i=n.error_description,null===(h=this.onCredentialsError)||void 0===h||h.call(this,{msg:i}),[2,this.unAuthenticatedError(i)];case 6:return null===(l=this.onCredentialsError)||void 0===l||l.call(this,{msg:n.error_description}),[2,Promise.reject(n)];case 7:return[2]}})})})]})})},e.prototype.anonymousLogin=function(e){return i(this,void 0,void 0,function(){var t=this;return o(this,function(r){return[2,this.singlePromise.run("_anonymousLogin",function(){return i(t,void 0,void 0,function(){var t,r;return o(this,function(n){switch(n.label){case 0:return this.anonymousSignInFunc?[4,this.anonymousSignInFunc(e)]:[3,4];case 1:return t=n.sent(),(r=t)?[3,3]:[4,this.localCredentials.getCredentials()];case 2:r=n.sent(),n.label=3;case 3:return e=r,[3,6];case 4:return[4,this.anonymousSignIn(e)];case 5:e=n.sent(),n.label=6;case 6:return[2,e]}})})})]})})},e.prototype.checkRetry=function(t){var r=null;if(("number"!=typeof t||t<e.minRetry||t>e.maxRetry)&&(r={error:a.ErrorType.UNREACHABLE,error_description:"wrong options param: retry"}),r)throw r;return t},e.prototype.formatRetry=function(e,t){return void 0===e?t:this.checkRetry(e)},e.prototype.sleep=function(e){return i(this,void 0,Promise,function(){return o(this,function(t){return[2,new Promise(function(t){setTimeout(function(){t()},e)})]})})},e.prototype.anonymousSignIn=function(e){return i(this,void 0,Promise,function(){var t=this;return o(this,function(r){return[2,this.singlePromise.run("_anonymous",function(){return i(t,void 0,void 0,function(){var t,r;return o(this,function(n){switch(n.label){case 0:if(!e||"anonymous"!==e.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];n.label=1;case 1:return n.trys.push([1,4,,7]),[4,this.request(u.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}})];case 2:return t=n.sent(),[4,this.localCredentials.setCredentials(t)];case 3:return n.sent(),[2,t];case 4:return(r=n.sent()).error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return n.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}})})})]})})},e.prototype.defaultRefreshTokenFunc=function(e,t){var r;return i(this,void 0,Promise,function(){var i,s,a;return o(this,function(o){switch(o.label){case 0:return void 0===e||""===e?(i="refresh token not found",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:i}),[2,this.unAuthenticatedError(i)]):(s=u.ApiUrls.AUTH_TOKEN_URL,"v2"===(null==t?void 0:t.version)&&(s=u.ApiUrlsV2.AUTH_TOKEN_URL),[4,this.request(s,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:e}})]);case 1:return a=o.sent(),[2,n(n({},a),{version:(null==t?void 0:t.version)||"v1"})]}})})},e.prototype.getDeviceId=function(){return i(this,void 0,Promise,function(){var e;return o(this,function(t){switch(t.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(y)];case 1:return"string"==typeof(e=t.sent())&&e.length>=16&&e.length<=48?[3,3]:(e=(0,c.uuidv4)(),[4,this.storage.setItem(y,e)]);case 2:t.sent(),t.label=3;case 3:return this.deviceID=e,[2,e]}})})},e.prototype.unAuthenticatedError=function(e){var t={error:a.ErrorType.UNAUTHENTICATED,error_description:e};return Promise.reject(t)},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logDebugMessages&&console.log.apply(console,s(["[OAuth2Client]"],e,!1))},e.prototype._initialize=function(){return i(this,void 0,Promise,function(){var e,t,r,n,i,s;return o(this,function(o){switch(o.label){case 0:if(o.trys.push([0,11,12,13]),!this.getInitialSession)return this._debug("#_initialize()","no getInitialSession callback set, skipping"),[2,{error:null}];this._debug("#_initialize()","calling getInitialSession callback"),o.label=1;case 1:return o.trys.push([1,9,,10]),[4,this.getInitialSession()];case 2:return s=o.sent(),e=s.data,t=s.error,(null==e?void 0:e.session)?(this._debug("#_initialize()","session obtained from getInitialSession",e.session),[4,this.localCredentials.setCredentials(null==e?void 0:e.session)]):[3,4];case 3:o.sent(),o.label=4;case 4:if(!this.onInitialSessionObtained)return[3,8];this._debug("#_initialize()","calling onInitialSessionObtained callback"),o.label=5;case 5:return o.trys.push([5,7,,8]),[4,this.onInitialSessionObtained(e,t)];case 6:return o.sent(),[3,8];case 7:return r=o.sent(),this._debug("#_initialize()","error in onInitialSessionObtained",r),[3,8];case 8:return t?(this._debug("#_initialize()","error from getInitialSession",t),[2,{error:t}]):[2,{error:null}];case 9:return n=o.sent(),this._debug("#_initialize()","exception during getInitialSession",n),[2,{error:n instanceof Error?n:new Error(String(n))}];case 10:return[3,13];case 11:return i=o.sent(),this._debug("#_initialize()","unexpected error",i),[2,{error:i instanceof Error?i:new Error(String(i))}];case 12:return this._debug("#_initialize()","end"),[7];case 13:return[2]}})})},e.prototype._acquireLock=function(e,t){return i(this,void 0,Promise,function(){var r,n,a,u,c=this;return o(this,function(h){switch(h.label){case 0:this._debug("#_acquireLock","begin",e),h.label=1;case 1:if(h.trys.push([1,,10,11]),this.lockAcquired)return r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=i(c,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,r];case 1:return e.sent(),[4,t()];case 2:return[2,e.sent()]}})}),this.pendingInLock.push(i(c,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,n];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})),[2,n];this._debug("#_acquireLock","acquiring lock for client",this.clientId),h.label=2;case 2:return h.trys.push([2,,8,9]),this.lockAcquired=!0,a=t(),this.pendingInLock.push(i(c,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,a];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})),[4,a];case 3:h.sent(),h.label=4;case 4:return this.pendingInLock.length?(u=s([],this.pendingInLock,!0),[4,Promise.all(u)]):[3,6];case 5:return h.sent(),this.pendingInLock.splice(0,u.length),[3,4];case 6:return[4,a];case 7:return[2,h.sent()];case 8:return this._debug("#_acquireLock","releasing lock for client",this.clientId),this.lockAcquired=!1,[7];case 9:return[3,11];case 10:return this._debug("#_acquireLock","end"),[7];case 11:return[2]}})})},e.prototype._getCredentials=function(){var e,t,r;return i(this,void 0,Promise,function(){var n,i,s;return o(this,function(o){switch(o.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:if((null==(n=o.sent())?void 0:n.scope)===u.DEFAULT_NODE_ACCESS_SCOPE)return[2,n];if(!n)return s="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];if(!E(n))return[3,12];if(!n.refresh_token)return[3,9];o.label=2;case 2:return o.trys.push([2,4,,8]),[4,this._refreshToken(n)];case 3:return n=o.sent(),[3,8];case 4:return i=o.sent(),"anonymous"!==n.scope?[3,6]:[4,this.anonymousLogin(n)];case 5:return n=o.sent(),[3,7];case 6:return null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:i.error_description}),[2,Promise.reject(i)];case 7:return[3,8];case 8:return[3,12];case 9:return"anonymous"!==n.scope?[3,11]:[4,this.anonymousLogin(n)];case 10:return n=o.sent(),[3,12];case 11:return s="no refresh token found in credentials",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];case 12:return[2,n]}})})},e.defaultRetry=2,e.minRetry=0,e.maxRetry=5,e.retryInterval=1e3,e}()},344:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.weAppJwtDecodeAll=t.weappJwtDecode=t.base64_url_decode=t.weAtob=t.weBtoa=void 0;var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function i(e){var r=e.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(e){return decodeURIComponent((0,t.weAtob)(e).replace(/(.)/g,function(e){var t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0".concat(t)),"%".concat(t)}))}(r)}catch(e){return(0,t.weAtob)(r)}}t.weBtoa=function(e){for(var t,n,i,o,s="",a=0,u=(e=String(e)).length%3;a<e.length;){if((n=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");s+=r.charAt((t=n<<16|i<<8|o)>>18&63)+r.charAt(t>>12&63)+r.charAt(t>>6&63)+r.charAt(63&t)}return u?s.slice(0,u-3)+"===".substring(u):s},t.weAtob=function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!n.test(e))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var i,o,s="",a=0;a<e.length;)t=r.indexOf(e.charAt(a++))<<18|r.indexOf(e.charAt(a++))<<12|(i=r.indexOf(e.charAt(a++)))<<6|(o=r.indexOf(e.charAt(a++))),s+=64===i?String.fromCharCode(t>>16&255):64===o?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return s},t.base64_url_decode=i,t.weappJwtDecode=function(e,t){if("string"!=typeof e)throw new Error("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(i(e.split(".")[r]))}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}},t.weAppJwtDecodeAll=function(e){if("string"!=typeof e)throw new Error("Invalid token specified");try{var t=e.split(".").map(function(e,t){return 2===t?e:JSON.parse(i(e))});return{claims:t[1],header:t[0],signature:t[2]}}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}}},814:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getEncryptInfo=void 0;var i=n(r(12)),o=r(631);t.getEncryptInfo=function(e){var t=void 0===e?{}:e,r=t.publicKey,n=void 0===r?"":r,s=t.payload,a=void 0===s?{}:s;if(!n)return"";try{var u=(0,o.deepClone)(a),c=new i.default;return c.setPublicKey(n),c.encryptLong("object"==typeof u?JSON.stringify(u):u)}catch(e){console.error("encrypt error:",e)}return""}},547:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SinglePromise=void 0;var i=new Map,o=function(){function e(e){this.clientId=(null==e?void 0:e.clientId)||"",i=i||new Map}return e.prototype.run=function(e,t){return r(this,void 0,Promise,function(){var o,s=this;return n(this,function(a){return e="".concat(this.clientId,"_").concat(e),(o=i.get(e))||(o=new Promise(function(o,a){r(s,void 0,void 0,function(){var r,s,u;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return n.sent(),r=t(),s=o,[4,r];case 2:return s.apply(void 0,[n.sent()]),[3,5];case 3:return u=n.sent(),a(u),[3,5];case 4:return i.delete(e),[7];case 5:return[2]}})})}),i.set(e,o)),[2,o]})})},e.prototype.runIdlePromise=function(){return Promise.resolve()},e}();t.SinglePromise=o},631:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.getPathName=t.deepClone=void 0,t.deepClone=function(e){var r=function(r){for(var n in e)e.hasOwnProperty(n)&&(r[n]=(0,t.deepClone)(e[n]));return r},n=null==e?"NullOrUndefined":Object.prototype.toString.call(e).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(n))return e.slice();switch(n){case"Object":return r(Object.create(Object.getPrototypeOf(e)));case"Array":return r([]);case"Date":return new Date(e.valueOf());case"RegExp":return new RegExp(e.source,(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":""));default:return e}},t.getPathName=function(e){var t=e.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return t&&t[2]||""}},425:function(e,t){function r(){if("undefined"==typeof globalThis)return!1;var e=globalThis.wx;if(void 0===e)return!1;if(void 0===globalThis.Page)return!1;if(!e.getDeviceInfo)return!1;if(!e.getStorageSync)return!1;if(!e.setStorageSync)return!1;if(!e.connectSocket)return!1;if(!e.request)return!1;try{if(!e.getDeviceInfo())return!1;if("qq"===e.getDeviceInfo().platform)return!1}catch(e){return!1}return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.isInMpWebView=t.isMp=void 0,t.isMp=r;var n=!1;function i(){n=n||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{r()||(n=n||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?i():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",i,!1))}catch(e){}t.isInMpWebView=function(){return n}},639:function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){if(this.params={},"string"==typeof e)this.parse(e);else if(e&&"object"==typeof e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.append(t,e[t])}return e.prototype.parse=function(e){var t=this;e.split("&").forEach(function(e){var r=e.split("=").map(decodeURIComponent),n=r[0],i=r[1];t.append(n,i)})},e.prototype.append=function(e,t){this.params[e]?this.params[e]=this.params[e].concat([t]):this.params[e]=[t]},e.prototype.get=function(e){return this.params[e]?this.params[e][0]:null},e.prototype.getAll=function(e){return this.params[e]||[]},e.prototype.delete=function(e){delete this.params[e]},e.prototype.has=function(e){return Object.prototype.hasOwnProperty.call(this.params,e)},e.prototype.set=function(e,t){this.params[e]=[t]},e.prototype.toString=function(){var e=[],t=function(t){Object.prototype.hasOwnProperty.call(r.params,t)&&r.params[t].forEach(function(r){e.push("".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(r)))})},r=this;for(var n in this.params)t(n);return e.join("&")},e}();t.default=r},873:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=void 0,t.uuidv4=function(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}},563:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(92)),c=r(962);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,i=(0,c.isArray)(e)?e:[e];r<i.length;r++){var o=i[r],s=o.isMatch,a=o.genAdapter,u=o.runtime;if(s())return{adapter:n({isMatch:s},a(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},92:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},o.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(764),c=r(962),h=r(464),l=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,i=t.timeoutMsg,o=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=i||"请求超时",r.restrictedMethods=o||["get","post","upload","download"],r}return i(t,e),t.prototype.get=function(e){return this.request(o(o({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(o(o({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(o(o({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,i=e.method,s=e.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==i?void 0:i.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(t).forEach(function(e){c.append(e,t[e])}),c.append("key",n),c.append("file",r),this.request(o(o({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(o(o({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,Promise,function(){var t,r,n,i;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(o(o({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(i=document.createElement("a")).href=r,i.setAttribute("download",n),i.style.display="none",document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(r),document.body.removeChild(i),[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.fetch=function(e){var t;return s(this,void 0,Promise,function(){var r,n,i,u,c,h,l,d,p,f,v,g,y,m=this;return a(this,function(_){switch(_.label){case 0:return r=new AbortController,n=e.url,i=e.enableAbort,u=void 0!==i&&i,c=e.stream,h=void 0!==c&&c,l=e.signal,d=e.timeout,p=e.shouldThrowOnError,f=void 0===p||p,v=null!=d?d:this.timeout,l&&(l.aborted&&r.abort(),l.addEventListener("abort",function(){return r.abort()})),g=null,u&&v&&(g=setTimeout(function(){console.warn(m.timeoutMsg),r.abort(new Error(m.timeoutMsg))},v)),[4,fetch(n,o(o({},e),{signal:r.signal})).then(function(e){return s(m,void 0,void 0,function(){var t,r,n;return a(this,function(i){switch(i.label){case 0:return clearTimeout(g),f?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[i.sent()]),i.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(g),Promise.reject(e)})];case 1:return y=_.sent(),[2,{data:h?y.body:(null===(t=y.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?y.json():y.text(),statusCode:y.status,header:y.headers,response:y}]}})})},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise(function(i){var o=e.url,s=e.headers,a=void 0===s?{}:s,u=e.data,l=e.responseType,d=e.withCredentials,p=e.body,f=e.onUploadProgress,v=(0,c.formatUrl)((0,h.getProtocol)(),o,"get"===n?u:{}),g=new XMLHttpRequest;g.open(n,v),l&&(g.responseType=l);var y,m,_=e.signal;_&&(_.aborted?g.abort():_.addEventListener("abort",function(){return g.abort()},{once:!0})),Object.keys(a).forEach(function(e){g.setRequestHeader(e,a[e])}),f&&g.upload.addEventListener("progress",f),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach(function(e){var t=e.split(": "),n=t.shift().toLowerCase(),i=t.join(": ");r[n]=i}),e.header=r,e.statusCode=g.status;try{e.data="blob"===l?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===l?g.response:g.responseText}clearTimeout(y),i(e)}},t&&r.timeout&&(y=setTimeout(function(){console.warn(r.timeoutMsg),g.abort()},r.timeout)),m=(0,c.isFormData)(u)?u:"application/x-www-form-urlencoded"===a["content-type"]?(0,c.toQueryString)(u):p||(u?JSON.stringify(u):void 0),d&&(g.withCredentials=!0),g.send(m)})},t}(u.AbstractSDKRequest);t.WebRequest=l,t.genAdapter=function(){return{type:"default",root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},464:function(e,t){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 n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},519:function(e,t){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"}},778:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,i(r(464),t),i(r(519),t),t.OATUH_LOGINTYPE="constants"},517:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var o=r(962),s=r(778),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function h(e){var t=e.err,r=e.className,n=e.methodName,i=e.sourceLink;if(!i)return null;var o,s=t.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),h=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),l=s.findIndex(function(e){return u.test(e)});if(-1!==l){var d=s.filter(function(e,t){return t>l});d.unshift(s[l].replace(h,"".concat(r,".").concat(n)).replace(c,i)),(o=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return o}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,l=void 0===a?{}:a,d=e.title,p=e.messages,f=void 0===p?[]:p;return function(e,t,a){if(s.IS_DEBUG_MODE){var p=l.className||e.constructor.name,v=l.methodName||t,g=a.value,y=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex(function(e){return u.test(e)});if(-1!==r){var n=c.exec(t[r+1]||"");e=n?n[0]:""}return e}();a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=h({err:new Error,className:p,methodName:v,sourceLink:y});try{return g.apply(this,e)}catch(e){var n=e,i=e.message,s=e.error,a=e.error_description,u={title:d||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:e}]};if(i&&/^\{.*\}$/.test(i)){var c=JSON.parse(i);u.subtitle=i,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=f.map(function(e){return{type:"info",body:e}}))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=f.map(function(e){return{type:"info",body:e}})),(0,o.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,function(){var t,r,n,s,a,u,c,l;return i(this,function(i){switch(i.label){case 0:t=h({err:new Error,className:p,methodName:v,sourceLink:y}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,g.apply(this,e)];case 2:return[2,i.sent()];case 3:throw r=i.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:d||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),c.subtitle=l,l.code&&(t?(t.code=l.code,t.message=l.msg):(r.code=l.code,r.message=l.msg),n=t||r,c.content=f.map(function(e){return{type:"info",body:e}}))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=f.map(function(e){return{type:"info",body:e}})),(0,o.printGroupLog)(c),n;case 4:return[2]}})})}}}}},260:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(517),t)},683:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.langEvent=t.AbortController=t.jwt=t.helpers=t.utils=t.events=t.cache=t.adapters=t.constants=void 0;var a=o(r(778));t.constants=a;var u=o(r(563));t.adapters=u;var c=o(r(865));t.cache=c;var h=o(r(940));t.events=h;var l=o(r(991));t.langEvent=l;var d=o(r(962));t.utils=d;var p=o(r(260));t.helpers=p;var f=s(r(829));t.AbortController=f.default;var v={decode:s(r(107)).default};t.jwt=v},829:function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){var e=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(t,r){"abort"===t&&e.listeners.push(r)}}}return e.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach(function(e){return e()}))},e}();t.default=r},865:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(764),u=r(962),c=r(778),h=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return i(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}(a.AbstractStorage),l=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,i=e.keys,o=void 0===i?{}:i;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(t.root));case"none":return new h(t.root)}}(this.persistenceTag,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.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return o(this,void 0,void 0,function(){var n;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]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return i.sent(),[3,4];case 3:return i.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return o(this,void 0,void 0,function(){var n;return s(this,function(i){switch(i.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=i.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return o(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]}})})},e}();t.CloudbaseCache=l},940:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(962),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return i(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var i=0,c=this.listeners[n]?o([],this.listeners[n],!0):[];i<c.length;i++)c[i].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var h=new c;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)}},991:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.LANG_CHANGE_EVENT=t.bus=void 0;var n=r(940);t.bus=new n.CloudbaseEventEmitter,t.LANG_CHANGE_EVENT="lang_change"},962:function(e,t,r){var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=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.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var i=r(778);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.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)})},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),i="";return Object.keys(r).forEach(function(e){""===i?!n&&(t+="?"):i+="&",i+="".concat(e,"=").concat(encodeURIComponent(r[e]))}),/^http(s)?:\/\//.test(t+=i)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),i=r.substr(r.indexOf("?")+1).match(n);return null!=i?i[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],i=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==i){for(var o=(n=i.split("&")).length-1;o>=0;o-=1)n[o].split("=")[0]===e&&n.splice(o,1);r="".concat(r,"?").concat(n.join("&"))}return r},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 r=new Promise(function(t,r){e=function(e,n){return e?r(e):t(n)}});return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,i=void 0===n?"":n,o=e.content,s=void 0===o?[]:o,a=e.printTrace,u=void 0!==a&&a,c=e.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,i):(console.group||console.error)(r,i);for(var h=0,l=s;h<l.length;h++){var d=l[h],p=d.type,f=d.body;switch(p){case"info":console.log(f);break;case"warn":console.warn(f);break;case"error":console.error(f)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var r=e.split("="),n=r[0],i=r[1];n=decodeURIComponent(n),i=decodeURIComponent(i),n&&(t[n]?Array.isArray(t[n])?t[n].push(i):t[n]=[t[n],i]:t[n]=i)}),t},t.parseCaptcha=function(e){var r={},i=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){e=i[1];var o=i[2];o&&(r=(0,t.parseQueryString)(o))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},12:function(e,t,r){var n;if(r.r(t),!globalThis.IS_MP_BUILD){var i="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;function x(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function M(e,t){return e&t}function j(e,t){return e|t}function V(e,t){return e^t}function B(e,t){return e&~t}function q(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function H(e){for(var t=0;0!=e;)e&=e-1,++t;return t}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function W(e){var t,r,n="";for(t=0;t+3<=e.length;t+=3)r=parseInt(e.substring(t,t+3),16),n+=o.charAt(r>>6)+o.charAt(63&r);for(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=o.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=o.charAt(r>>2)+o.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function G(e){var t,r="",n=0,i=0;for(t=0;t<e.length&&"="!=e.charAt(t);++t){var s=o.indexOf(e.charAt(t));s<0||(0==n?(r+=x(s>>2),i=3&s,n=1):1==n?(r+=x(i<<2|s>>4),i=15&s,n=2):2==n?(r+=x(i),r+=x(s>>2),i=3&s,n=3):(r+=x(i<<2|s>>4),r+=x(15&s),n=0))}return 1==n&&(r+=x(i<<2)),r}var s,a,u={decode:function(e){var t;if(void 0===s){var r="0123456789ABCDEF";for(s={},t=0;t<16;++t)s[r.charAt(t)]=t;for(r=r.toLowerCase(),t=10;t<16;++t)s[r.charAt(t)]=t;for(t=0;t<8;++t)s[" \f\n\r\t \u2028\u2029".charAt(t)]=-1}var n=[],i=0,o=0;for(t=0;t<e.length;++t){var a=e.charAt(t);if("="==a)break;if(-1!=(a=s[a])){if(void 0===a)throw new Error("Illegal character at offset "+t);i|=a,++o>=2?(n[n.length]=i,i=0,o=0):i<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},c={decode:function(e){var t;if(void 0===a){for(a=Object.create(null),t=0;t<64;++t)a["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)]=t;for(t=0;t<9;++t)a["= \f\n\r\t \u2028\u2029".charAt(t)]=-1}var r=[],n=0,i=0;for(t=0;t<e.length;++t){var o=e.charAt(t);if("="==o)break;if(-1!=(o=a[o])){if(void 0===o)throw new Error("Illegal character at offset "+t);n|=o,++i>=4?(r[r.length]=n>>16,r[r.length]=n>>8&255,r[r.length]=255&n,n=0,i=0):n<<=6}}switch(i){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=n>>10;break;case 3:r[r.length]=n>>16,r[r.length]=n>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(e){var t=c.re.exec(e);if(t)if(t[1])e=t[1];else{if(!t[2])throw new Error("RegExp out of sync");e=t[2]}return c.decode(e)}},h=1e13;class F{constructor(e){this.buf=[+e||0]}mulAdd(e,t){var r,n,i=this.buf,o=i.length;for(r=0;r<o;++r)(n=i[r]*e+t)<h?t=0:n-=(t=0|n/h)*h,i[r]=n;t>0&&(i[r]=t)}sub(e){var t,r,n=this.buf,i=n.length;for(t=0;t<i;++t)(r=n[t]-e)<0?(r+=h,e=1):e=0,n[t]=r;for(;0===n[n.length-1];)n.pop()}toString(e){if(10!=(e||10))throw new Error("only base 10 is supported");for(var t=this.buf,r=t[t.length-1].toString(),n=t.length-2;n>=0;--n)r+=(h+t[n]).toString().substring(1);return r}valueOf(){for(var e=this.buf,t=0,r=e.length-1;r>=0;--r)t=t*h+e[r];return t}simplify(){var e=this.buf;return 1==e.length?e[0]:this}}var l,d=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,p=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function Y(e,t){return e.length>t&&(e=e.substring(0,t)+"…"),e}class K{constructor(e,t){this.hexDigits="0123456789ABCDEF",e instanceof K?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=t)}get(e){if(void 0===e&&(e=this.pos++),e>=this.enc.length)throw new Error("Requesting byte offset "+e+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(e):this.enc[e]}hexByte(e){return this.hexDigits.charAt(e>>4&15)+this.hexDigits.charAt(15&e)}hexDump(e,t,r){for(var n="",i=e;i<t;++i)if(n+=this.hexByte(this.get(i)),!0!==r)switch(15&i){case 7:n+=" ";break;case 15:n+="\n";break;default:n+=" "}return n}isASCII(e,t){for(var r=e;r<t;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(e,t){for(var r="",n=e;n<t;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(e,t){for(var r="",n=e;n<t;){var i=this.get(n++);r+=i<128?String.fromCharCode(i):i>191&&i<224?String.fromCharCode((31&i)<<6|63&this.get(n++)):String.fromCharCode((15&i)<<12|(63&this.get(n++))<<6|63&this.get(n++))}return r}parseStringBMP(e,t){for(var r,n,i="",o=e;o<t;)r=this.get(o++),n=this.get(o++),i+=String.fromCharCode(r<<8|n);return i}parseTime(e,t,r){var n=this.parseStringISO(e,t),i=(r?d:p).exec(n);return i?(r&&(i[1]=+i[1],i[1]+=+i[1]<70?2e3:1900),n=i[1]+"-"+i[2]+"-"+i[3]+" "+i[4],i[5]&&(n+=":"+i[5],i[6]&&(n+=":"+i[6],i[7]&&(n+="."+i[7]))),i[8]&&(n+=" UTC","Z"!=i[8]&&(n+=i[8],i[9]&&(n+=":"+i[9]))),n):"Unrecognized time: "+n}parseInteger(e,t){for(var r,n=this.get(e),i=n>127,o=i?255:0,s="";n==o&&++e<t;)n=this.get(e);if(0===(r=t-e))return i?-1:0;if(r>4){for(s=n,r<<=3;!(128&(+s^o));)s=+s<<1,--r;s="("+r+" bit)\n"}i&&(n-=256);for(var a=new F(n),u=e+1;u<t;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(e,t,r){for(var n=this.get(e),i="("+((t-e-1<<3)-n)+" bit)\n",o="",s=e+1;s<t;++s){for(var a=this.get(s),u=s==t-1?n:0,c=7;c>=u;--c)o+=a>>c&1?"1":"0";if(o.length>r)return i+Y(o,r)}return i+o}parseOctetString(e,t,r){if(this.isASCII(e,t))return Y(this.parseStringISO(e,t),r);var n=t-e,i="("+n+" byte)\n";n>(r/=2)&&(t=e+r);for(var o=e;o<t;++o)i+=this.hexByte(this.get(o));return n>r&&(i+="…"),i}parseOID(e,t,r){for(var n="",i=new F,o=0,s=e;s<t;++s){var a=this.get(s);if(i.mulAdd(128,127&a),o+=7,!(128&a)){if(""===n)if((i=i.simplify())instanceof F)i.sub(80),n="2."+i.toString();else{var u=i<80?i<40?0:1:2;n=u+"."+(i-40*u)}else n+="."+i.toString();if(n.length>r)return Y(n,r);i=new F,o=0}}return o>0&&(n+=".incomplete"),n}}class z{constructor(e,t,r,n,i){if(!(n instanceof Q))throw new Error("Invalid tag value.");this.stream=e,this.header=t,this.length=r,this.tag=n,this.sub=i}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(e){if(void 0===this.tag)return null;void 0===e&&(e=1/0);var t=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(t)?"false":"true";case 2:return this.stream.parseInteger(t,t+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+r,e);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);case 6:return this.stream.parseOID(t,t+r,e);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return Y(this.stream.parseStringUTF(t,t+r),e);case 18:case 19:case 20:case 21:case 22:case 26:return Y(this.stream.parseStringISO(t,t+r),e);case 30:return Y(this.stream.parseStringBMP(t,t+r),e);case 23:case 24:return this.stream.parseTime(t,t+r,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(e){void 0===e&&(e="");var t=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(t+=" (encapsulates)"),t+="\n",null!==this.sub){e+=" ";for(var r=0,n=this.sub.length;r<n;++r)t+=this.sub[r].toPrettyString(e)}return t}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(e){var t=e.get(),r=127&t;if(r==t)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(e.pos-1));if(0===r)return null;t=0;for(var n=0;n<r;++n)t=256*t+e.get();return t}getHexStringValue(){var e=this.toHexString(),t=2*this.header,r=2*this.length;return e.substr(t,r)}static decode(e){var t;t=e instanceof K?e:new K(e,0);var r=new K(t),n=new Q(t),i=z.decodeLength(t),o=t.pos,s=o-r.pos,a=null,u=function(){var e=[];if(null!==i){for(var r=o+i;t.pos<r;)e[e.length]=z.decode(t);if(t.pos!=r)throw new Error("Content size is not correct for container starting at offset "+o)}else try{for(;;){var n=z.decode(t);if(n.tag.isEOC())break;e[e.length]=n}i=o-t.pos}catch(e){throw new Error("Exception while decoding undefined length content: "+e)}return e};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=t.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(e){a=null}if(null===a){if(null===i)throw new Error("We can't skip over an invalid tag with undefined length at offset "+o);t.pos=o+Math.abs(i)}return new z(r,s,i,n,a)}}class Q{constructor(e){var t=e.get();if(this.tagClass=t>>6,this.tagConstructed=!!(32&t),this.tagNumber=31&t,31==this.tagNumber){var r=new F;do{t=e.get(),r.mulAdd(128,127&t)}while(128&t);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var f=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],v=(1<<26)/f[f.length-1];class J{constructor(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}toString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,i=!1,o="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(i=!0,o=x(r));s>=0;)a<t?(r=(this[s]&(1<<a)-1)<<t-a,r|=this[--s]>>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=x(r));return i?o:"0"}negate(){var e=Z();return J.ZERO.subTo(this,e),e}abs(){return this.s<0?this.negate():this}compareTo(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+ie(this[this.t-1]^this.s&this.DM)}mod(e){var t=Z();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(J.ZERO)>0&&e.subTo(t,t),t}modPowInt(e,t){var r;return r=e<256||t.isEven()?new y(t):new m(t),this.exp(e,r)}clone(){var e=Z();return this.copyTo(e),e}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var e=this.t,t=[];t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n<this.DB&&(r=this[e]>>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this[e]&(1<<n)-1)<<8-n,r|=this[--e]>>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),128&r&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t}equals(e){return 0==this.compareTo(e)}min(e){return this.compareTo(e)<0?this:e}max(e){return this.compareTo(e)>0?this:e}and(e){var t=Z();return this.bitwiseTo(e,M,t),t}or(e){var t=Z();return this.bitwiseTo(e,j,t),t}xor(e){var t=Z();return this.bitwiseTo(e,V,t),t}andNot(e){var t=Z();return this.bitwiseTo(e,B,t),t}not(){for(var e=Z(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e}shiftLeft(e){var t=Z();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}shiftRight(e){var t=Z();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}getLowestSetBit(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+q(this[e]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=H(this[r]^t);return e}testBit(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)}setBit(e){return this.changeBit(e,j)}clearBit(e){return this.changeBit(e,B)}flipBit(e){return this.changeBit(e,V)}add(e){var t=Z();return this.addTo(e,t),t}subtract(e){var t=Z();return this.subTo(e,t),t}multiply(e){var t=Z();return this.multiplyTo(e,t),t}divide(e){var t=Z();return this.divRemTo(e,t,null),t}remainder(e){var t=Z();return this.divRemTo(e,null,t),t}divideAndRemainder(e){var t=Z(),r=Z();return this.divRemTo(e,t,r),[t,r]}modPow(e,t){var r,n,i=e.bitLength(),o=ne(1);if(i<=0)return o;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new y(t):t.isEven()?new _(t):new m(t);var s=[],a=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var h=Z();for(n.sqrTo(s[1],h);a<=c;)s[a]=Z(),n.mulTo(h,s[a-2],s[a]),a+=2}var l,d,p=e.t-1,f=!0,v=Z();for(i=ie(e[p])-1;p>=0;){for(i>=u?l=e[p]>>i-u&c:(l=(e[p]&(1<<i+1)-1)<<u-i,p>0&&(l|=e[p-1]>>this.DB+i-u)),a=r;!(1&l);)l>>=1,--a;if((i-=a)<0&&(i+=this.DB,--p),f)s[l].copyTo(o),f=!1;else{for(;a>1;)n.sqrTo(o,v),n.sqrTo(v,o),a-=2;a>0?n.sqrTo(o,v):(d=o,o=v,v=d),n.mulTo(v,s[l],o)}for(;p>=0&&!(e[p]&1<<i);)n.sqrTo(o,v),d=o,o=v,v=d,--i<0&&(i=this.DB-1,--p)}return n.revert(o)}modInverse(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return J.ZERO;for(var r=e.clone(),n=this.clone(),i=ne(1),o=ne(0),s=ne(0),a=ne(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(i.isEven()&&o.isEven()||(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),t&&s.subTo(i,s),a.subTo(o,a))}return 0!=n.compareTo(J.ONE)?J.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a}pow(e){return this.exp(e,new g)}gcd(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i<o&&(o=i),o>0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r}isProbablePrime(e){var t,r=this.abs();if(1==r.t&&r[0]<=f[f.length-1]){for(t=0;t<f.length;++t)if(r[0]==f[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<f.length;){for(var n=f[t],i=t+1;i<f.length&&n<v;)n*=f[i++];for(n=r.modInt(n);t<i;)if(n%f[t++]==0)return!1}return r.millerRabin(e)}copyTo(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}fromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}fromString(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,o=0;--n>=0;){var s=8==r?255&+e[n]:re(e,n);s<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<<this.DB-o)-1)<<o,this[this.t++]=s>>this.DB-o):this[this.t-1]|=s<<o,(o+=r)>=this.DB&&(o-=this.DB))}8==r&&128&+e[0]&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),i&&J.ZERO.subTo(this,this)}clamp(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t}dlShiftTo(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s}drShiftTo(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s}lShiftTo(e,t){for(var r=e%this.DB,n=this.DB-r,i=(1<<n)-1,o=Math.floor(e/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)t[a+o+1]=this[a]>>n|s,s=(this[a]&i)<<r;for(a=o-1;a>=0;--a)t[a]=0;t[o]=s,t.t=this.t+o+1,t.s=this.s,t.clamp()}rShiftTo(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<<n)-1;t[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)t[s-r-1]|=(this[s]&o)<<i,t[s-r]=this[s]>>n;n>0&&(t[this.t-r-1]|=(this.s&o)<<i),t.t=this.t-r,t.clamp()}}subTo(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]-e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e[r],t[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()}multiplyTo(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i<n.t;++i)t[i+r.t]=r.am(0,n[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&J.ZERO.subTo(t,t)}squareTo(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()}divRemTo(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=Z());var o=Z(),s=this.s,a=e.s,u=this.DB-ie(n[n.t-1]);u>0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var c=o.t,h=o[c-1];if(0!=h){var l=h*(1<<this.F1)+(c>1?o[c-2]>>this.F2:0),d=this.FV/l,p=(1<<this.F1)/l,f=1<<this.F2,v=r.t,g=v-c,y=null==t?Z():t;for(o.dlShiftTo(g,y),r.compareTo(y)>=0&&(r[r.t++]=1,r.subTo(y,r)),J.ONE.dlShiftTo(c,y),y.subTo(o,o);o.t<c;)o[o.t++]=0;for(;--g>=0;){var m=r[--v]==h?this.DM:Math.floor(r[v]*d+(r[v-1]+f)*p);if((r[v]+=o.am(0,m,r,g,0,c))<m)for(o.dlShiftTo(g,y),r.subTo(y,r);r[v]<--m;)r.subTo(y,r)}null!=t&&(r.drShiftTo(c,t),s!=a&&J.ZERO.subTo(t,t)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&&J.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(e,t){if(e>4294967295||e<1)return J.ONE;var r=Z(),n=Z(),i=t.convert(this),o=ie(e)-1;for(i.copyTo(r);--o>=0;)if(t.sqrTo(r,n),(e&1<<o)>0)t.mulTo(n,i,r);else{var s=r;r=n,n=s}return t.revert(r)}chunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}toRadix(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=ne(r),i=Z(),o=Z(),s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(e)+s}fromRadix(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,s=0,a=0;a<e.length;++a){var u=re(e,a);u<0?"-"==e.charAt(a)&&0==this.signum()&&(i=!0):(s=t*s+u,++o>=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(s,0)),i&&J.ZERO.subTo(this,this)}fromNumber(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(J.ONE.shiftLeft(e-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(J.ONE.shiftLeft(e-1),this);else{var n=[],i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(e,t,r){var n,i,o=Math.min(e.t,this.t);for(n=0;n<o;++n)r[n]=t(this[n],e[n]);if(e.t<this.t){for(i=e.s&this.DM,n=o;n<this.t;++n)r[n]=t(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=o;n<e.t;++n)r[n]=t(i,e[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()}changeBit(e,t){var r=J.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r}addTo(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]+e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e[r],t[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()}dMultiply(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}multiplyLowerTo(e,t,r){var n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(var i=r.t-this.t;n<i;++n)r[n+this.t]=this.am(0,e[n],r,n,0,this.t);for(i=Math.min(e.t,t);n<i;++n)this.am(0,e[n],r,n,0,t-n);r.clamp()}multiplyUpperTo(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r[this.t+n-t]=this.am(t-n,e[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)}modInt(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r}millerRabin(e){var t=this.subtract(J.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>f.length&&(e=f.length);for(var i=Z(),o=0;o<e;++o){i.fromInt(f[Math.floor(Math.random()*f.length)]);var s=i.modPow(n,this);if(0!=s.compareTo(J.ONE)&&0!=s.compareTo(t)){for(var a=1;a++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(J.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0}square(){var e=Z();return this.squareTo(e),e}gcda(e,t){var r=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(r.compareTo(n)<0){var i=r;r=n,n=i}var o=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)t(r);else{o<s&&(s=o),s>0&&(r.rShiftTo(s,r),n.rShiftTo(s,n));var a=()=>{(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),(o=n.getLowestSetBit())>0&&n.rShiftTo(o,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n)),r.signum()>0?setTimeout(a,0):(s>0&&n.lShiftTo(s,n),setTimeout(function(){t(n)},0))};setTimeout(a,10)}}fromNumberAsync(e,t,r,n){if("number"==typeof t)if(e<2)this.fromInt(1);else{this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(J.ONE.shiftLeft(e-1),j,this),this.isEven()&&this.dAddOffset(1,0);var i=this,o=function(){i.dAddOffset(2,0),i.bitLength()>e&&i.subTo(J.ONE.shiftLeft(e-1),i),i.isProbablePrime(t)?setTimeout(function(){n()},0):setTimeout(o,0)};setTimeout(o,0)}else{var s=[],a=7&e;s.length=1+(e>>3),t.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var g=function(){function e(){}return e.prototype.convert=function(e){return e},e.prototype.revert=function(e){return e},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},e.prototype.sqrTo=function(e,t){e.squareTo(t)},e}(),y=function(){function e(e){this.m=e}return e.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),m=function(){function e(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}return e.prototype.convert=function(e){var t=Z();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(J.ZERO)>0&&this.m.subTo(t,t),t},e.prototype.revert=function(e){var t=Z();return e.copyTo(t),this.reduce(t),t},e.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],n=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),_=function(){function e(e){this.m=e,this.r2=Z(),this.q3=Z(),J.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e)}return e.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=Z();return e.copyTo(t),this.reduce(t),t},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}();function Z(){return new J(null)}function X(e,t){return new J(e,t)}function $(e,t,r,n,i,o){for(;--o>=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i}function ee(e,t,r,n,i,o){for(var s=32767&t,a=t>>15;--o>=0;){var u=32767&this[e],c=this[e++]>>15,h=a*u+c*s;i=((u=s*u+((32767&h)<<15)+r[n]+(1073741823&i))>>>30)+(h>>>15)+a*c+(i>>>30),r[n++]=1073741823&u}return i}function te(e,t,r,n,i,o){for(var s=16383&t,a=t>>14;--o>=0;){var u=16383&this[e],c=this[e++]>>14,h=a*u+c*s;i=((u=s*u+((16383&h)<<14)+r[n]+i)>>28)+(h>>14)+a*c,r[n++]=268435455&u}return i}void 0!==i&&"Microsoft Internet Explorer"==(null==i?void 0:i.appName)?(J.prototype.am=ee,l=30):"Netscape"!=(null==i?void 0:i.appName)?(J.prototype.am=$,l=26):(J.prototype.am=te,l=28),J.prototype.DB=l,J.prototype.DM=(1<<l)-1,J.prototype.DV=1<<l,J.prototype.FV=Math.pow(2,52),J.prototype.F1=52-l,J.prototype.F2=2*l-52;var E,b,I=[];for(E="0".charCodeAt(0),b=0;b<=9;++b)I[E++]=b;for(E="a".charCodeAt(0),b=10;b<36;++b)I[E++]=b;for(E="A".charCodeAt(0),b=10;b<36;++b)I[E++]=b;function re(e,t){var r=I[e.charCodeAt(t)];return null==r?-1:r}function ne(e){var t=Z();return t.fromInt(e),t}function ie(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}J.ZERO=ne(0),J.ONE=ne(1);class oe{constructor(){this.i=0,this.j=0,this.S=[]}init(e){var t,r,n;for(t=0;t<256;++t)this.S[t]=t;for(r=0,t=0;t<256;++t)r=r+this.S[t]+e[t%e.length]&255,n=this.S[t],this.S[t]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]}}var A,w,T=null;if(null==T){T=[],w=0;var S,O,P=void 0;if("undefined"!=typeof window&&null!==(S=window)&&void 0!==S&&S.crypto&&null!==(O=window)&&void 0!==O&&O.crypto.getRandomValues){var R,C=new Uint32Array(256);for(null===(R=window)||void 0===R||R.crypto.getRandomValues(C),P=0;P<C.length;++P)T[w++]=255&C[P]}var U,N,D,L=function(e){var t,r,n;if(this.count=this.count||0,this.count>=256||w>=256){if("undefined"!=typeof window)if(null!==(t=window)&&void 0!==t&&t.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",L,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var i;null===(i=window)||void 0===i||i.detachEvent("onmousemove",L)}}else try{var o=e.x+e.y;T[w++]=255&o,this.count+=1}catch(e){}};if("undefined"!=typeof window)if(null!==(U=window)&&void 0!==U&&U.addEventListener)null===(D=window)||void 0===D||D.addEventListener("mousemove",L,!1);else if(null!==(N=window)&&void 0!==N&&N.attachEvent){var k;null===(k=window)||void 0===k||k.attachEvent("onmousemove",L)}}function se(){if(null==A){for(A=new oe;w<256;){var e=Math.floor(65536*Math.random());T[w++]=255&e}for(A.init(T),w=0;w<T.length;++w)T[w]=0;w=0}return A.next()}class ae{constructor(){}nextBytes(e){for(var t=0;t<e.length;++t)e[t]=se()}}function ue(e,t){if(t<e.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=e.length-1;n>=0&&t>0;){var i=e.charCodeAt(n--);i<128?r[--t]=i:i>127&&i<2048?(r[--t]=63&i|128,r[--t]=i>>6|192):(r[--t]=63&i|128,r[--t]=i>>6&63|128,r[--t]=i>>12|224)}r[--t]=0;for(var o=new ae,s=[];t>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);r[--t]=s[0]}return r[--t]=2,r[--t]=0,new J(r)}class ce{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(e){return e.modPowInt(this.e,this.n)}doPrivate(e){if(null==this.p||null==this.q)return e.modPow(this.d,this.n);for(var t=e.mod(this.p).modPow(this.dmp1,this.p),r=e.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(r)<0;)t=t.add(this.p);return t.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(e,t){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=X(e,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")}encrypt(e){var t=ue(e,this.n.bitLength()+7>>3);if(null==t)return null;var r=this.doPublic(t);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n}encryptLong(e){var t=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return e.length>r?(e.match(/.{1,117}/g).forEach(function(e){var r=t.encrypt(e);n+=r}),W(n)):W(this.encrypt(e))}catch(e){return!1}}decryptLong(e){var t=this,r=this.n.bitLength()+7>>3;e=G(e);try{if(e.length>r){var n="";return e.match(/.{1,256}/g).forEach(function(e){var r=t.decrypt(e);n+=r}),n}return this.decrypt(e)}catch(e){return!1}}setPrivate(e,t,r){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=X(e,16),this.e=parseInt(t,16),this.d=X(r,16)):console.error("Invalid RSA private key")}setPrivateEx(e,t,r,n,i,o,s,a){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=X(e,16),this.e=parseInt(t,16),this.d=X(r,16),this.p=X(n,16),this.q=X(i,16),this.dmp1=X(o,16),this.dmq1=X(s,16),this.coeff=X(a,16)):console.error("Invalid RSA private key")}generate(e,t){var r=new ae,n=e>>1;this.e=parseInt(t,16);for(var i=new J(t,16);;){for(;this.p=new J(e-n,1,r),0!=this.p.subtract(J.ONE).gcd(i).compareTo(J.ONE)||!this.p.isProbablePrime(10););for(;this.q=new J(n,1,r),0!=this.q.subtract(J.ONE).gcd(i).compareTo(J.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var s=this.p.subtract(J.ONE),a=this.q.subtract(J.ONE),u=s.multiply(a);if(0==u.gcd(i).compareTo(J.ONE)){this.n=this.p.multiply(this.q),this.d=i.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(e){var t=X(e,16),r=this.doPrivate(t);return null==r?null:he(r,this.n.bitLength()+7>>3)}generateAsync(e,t,r){var n=new ae,i=e>>1;this.e=parseInt(t,16);var o=new J(t,16),s=this,a=()=>{var t=()=>{if(s.p.compareTo(s.q)<=0){var e=s.p;s.p=s.q,s.q=e}var t=s.p.subtract(J.ONE),n=s.q.subtract(J.ONE),i=t.multiply(n);0==i.gcd(o).compareTo(J.ONE)?(s.n=s.p.multiply(s.q),s.d=o.modInverse(i),s.dmp1=s.d.mod(t),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout(function(){r()},0)):setTimeout(a,0)},u=()=>{s.q=Z(),s.q.fromNumberAsync(i,1,n,function(){s.q.subtract(J.ONE).gcda(o,function(e){0==e.compareTo(J.ONE)&&s.q.isProbablePrime(10)?setTimeout(t,0):setTimeout(u,0)})})},c=()=>{s.p=Z(),s.p.fromNumberAsync(e-i,1,n,function(){s.p.subtract(J.ONE).gcda(o,function(e){0==e.compareTo(J.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)})})};setTimeout(c,0)};setTimeout(a,0)}}function he(e,t){for(var r=e.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=t-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var i="";++n<r.length;){var o=255&r[n];o<128?i+=String.fromCharCode(o):o>191&&o<224?(i+=String.fromCharCode((31&o)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&o)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}class le extends ce{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),e&&("string"==typeof e?this.parseKey(e):(this.hasPrivateKeyProperty(e)||this.hasPublicKeyProperty(e))&&this.parsePropertiesFrom(e))}parseKey(e){try{var t=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(e)?u.decode(e):c.unarmor(e),i=z.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){t=i.sub[1].getHexStringValue(),this.n=X(t,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var o=i.sub[3].getHexStringValue();this.d=X(o,16);var s=i.sub[4].getHexStringValue();this.p=X(s,16);var a=i.sub[5].getHexStringValue();this.q=X(a,16);var h=i.sub[6].getHexStringValue();this.dmp1=X(h,16);var l=i.sub[7].getHexStringValue();this.dmq1=X(l,16);var d=i.sub[8].getHexStringValue();this.coeff=X(d,16)}else{if(2!==i.sub.length)return!1;var p=i.sub[1].sub[0];t=p.sub[0].getHexStringValue(),this.n=X(t,16),r=p.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(e){return!1}}hasPublicKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")}hasPrivateKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")}parsePropertiesFrom(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)}}(n=function(e){e=e||{},this.default_key_size=parseInt(e.default_key_size,10)||1024,this.default_public_exponent=e.default_public_exponent||"010001",this.log=e.log||!1,this.key=null}).prototype.setKey=function(e){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new le(e)},n.prototype.setPrivateKey=function(e){this.setKey(e)},n.prototype.setPublicKey=function(e){this.setKey(e)},n.prototype.decrypt=function(e){try{return this.getKey().decrypt(G(e))}catch(e){return!1}},n.prototype.encrypt=function(e){try{return W(this.getKey().encrypt(e))}catch(e){return!1}},n.prototype.encryptLong=function(e){try{for(var t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",n=0,i=/null$/g;i.test(r)&&(n++,t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",!(n>10)););return t}catch(e){return!1}},n.prototype.getKey=function(e){if(!this.key){if(this.key=new le,e&&"[object Function]"==={}.toString.call(e))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}t.default=n},182:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(274)),c=r(616);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,i=(0,c.isArray)(e)?e:[e];r<i.length;r++){var o=i[r],s=o.isMatch,a=o.genAdapter,u=o.runtime;if(s())return{adapter:n({isMatch:s},a(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},274:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},o.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(764),c=r(616),h=r(946),l=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,i=t.timeoutMsg,o=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=i||"请求超时",r.restrictedMethods=o||["get","post","upload","download"],r}return i(t,e),t.prototype.get=function(e){return this.request(o(o({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(o(o({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(o(o({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,i=e.method,s=e.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==i?void 0:i.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(t).forEach(function(e){c.append(e,t[e])}),c.append("key",n),c.append("file",r),this.request(o(o({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(o(o({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,function(){var t,r,n,i;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(o(o({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(i=document.createElement("a")).href=r,i.setAttribute("download",n),i.style.display="none",document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(r),document.body.removeChild(i),[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.fetch=function(e){var t;return s(this,void 0,void 0,function(){var r,n,i,u,c,h,l,d,p,f,v,g,y,m=this;return a(this,function(_){switch(_.label){case 0:return r=new AbortController,n=e.url,i=e.enableAbort,u=void 0!==i&&i,c=e.stream,h=void 0!==c&&c,l=e.signal,d=e.timeout,p=e.shouldThrowOnError,f=void 0===p||p,v=null!=d?d:this.timeout,l&&(l.aborted&&r.abort(),l.addEventListener("abort",function(){return r.abort()})),g=null,u&&v&&(g=setTimeout(function(){console.warn(m.timeoutMsg),r.abort(new Error(m.timeoutMsg))},v)),[4,fetch(n,o(o({},e),{signal:r.signal})).then(function(e){return s(m,void 0,void 0,function(){var t,r,n;return a(this,function(i){switch(i.label){case 0:return clearTimeout(g),f?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[i.sent()]),i.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(g),Promise.reject(e)})];case 1:return y=_.sent(),[2,{data:h?y.body:(null===(t=y.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?y.json():y.text(),statusCode:y.status,header:y.headers,response:y}]}})})},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise(function(i){var o=e.url,s=e.headers,a=void 0===s?{}:s,u=e.data,l=e.responseType,d=e.withCredentials,p=e.body,f=e.onUploadProgress,v=(0,c.formatUrl)((0,h.getProtocol)(),o,"get"===n?u:{}),g=new XMLHttpRequest;g.open(n,v),l&&(g.responseType=l);var y,m,_=e.signal;_&&(_.aborted?g.abort():_.addEventListener("abort",function(){return g.abort()},{once:!0})),Object.keys(a).forEach(function(e){g.setRequestHeader(e,a[e])}),f&&g.upload.addEventListener("progress",f),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach(function(e){var t=e.split(": "),n=t.shift().toLowerCase(),i=t.join(": ");r[n]=i}),e.header=r,e.statusCode=g.status;try{e.data="blob"===l?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===l?g.response:g.responseText}clearTimeout(y),i(e)}},t&&r.timeout&&(y=setTimeout(function(){console.warn(r.timeoutMsg),g.abort()},r.timeout)),m=(0,c.isFormData)(u)?u:"application/x-www-form-urlencoded"===a["content-type"]?(0,c.toQueryString)(u):p||(u?JSON.stringify(u):void 0),d&&(g.withCredentials=!0),g.send(m)})},t}(u.AbstractSDKRequest);t.WebRequest=l,t.genAdapter=function(){return{type:"default",root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},946:function(e,t){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 n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},205:function(e,t){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"}},794:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,i(r(946),t),i(r(205),t),t.OATUH_LOGINTYPE="constants"},718:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var o=r(616),s=r(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function h(e){var t=e.err,r=e.className,n=e.methodName,i=e.sourceLink;if(!i)return null;var o,s=t.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),h=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),l=s.findIndex(function(e){return u.test(e)});if(-1!==l){var d=s.filter(function(e,t){return t>l});d.unshift(s[l].replace(h,"".concat(r,".").concat(n)).replace(c,i)),(o=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return o}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,l=void 0===a?{}:a,d=e.title,p=e.messages,f=void 0===p?[]:p;return function(e,t,a){if(s.IS_DEBUG_MODE){var p=l.className||e.constructor.name,v=l.methodName||t,g=a.value,y=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex(function(e){return u.test(e)});if(-1!==r){var n=c.exec(t[r+1]||"");e=n?n[0]:""}return e}();a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=h({err:new Error,className:p,methodName:v,sourceLink:y});try{return g.apply(this,e)}catch(e){var n=e,i=e.message,s=e.error,a=e.error_description,u={title:d||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:e}]};if(i&&/^\{.*\}$/.test(i)){var c=JSON.parse(i);u.subtitle=i,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=f.map(function(e){return{type:"info",body:e}}))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=f.map(function(e){return{type:"info",body:e}})),(0,o.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,function(){var t,r,n,s,a,u,c,l;return i(this,function(i){switch(i.label){case 0:t=h({err:new Error,className:p,methodName:v,sourceLink:y}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,g.apply(this,e)];case 2:return[2,i.sent()];case 3:throw r=i.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:d||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),c.subtitle=l,l.code&&(t?(t.code=l.code,t.message=l.msg):(r.code=l.code,r.message=l.msg),n=t||r,c.content=f.map(function(e){return{type:"info",body:e}}))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=f.map(function(e){return{type:"info",body:e}})),(0,o.printGroupLog)(c),n;case 4:return[2]}})})}}}}},141:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(718),t)},197:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var r,n,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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(764),u=r(616),c=r(794),h=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return i(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}(a.AbstractStorage),l=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,i=e.keys,o=void 0===i?{}:i;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(t.root));case"none":return new h(t.root)}}(this.persistenceTag,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.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return o(this,void 0,void 0,function(){var n;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]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return i.sent(),[3,4];case 3:return i.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return o(this,void 0,void 0,function(){var n;return s(this,function(i){switch(i.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=i.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return o(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]}})})},e}();t.CloudbaseCache=l},689:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(616),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return i(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var i=0,c=this.listeners[n]?o([],this.listeners[n],!0):[];i<c.length;i++)c[i].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var h=new c;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)}},616:function(e,t,r){var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=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.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var i=r(794);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.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)})},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),i="";return Object.keys(r).forEach(function(e){""===i?!n&&(t+="?"):i+="&",i+="".concat(e,"=").concat(encodeURIComponent(r[e]))}),/^http(s)?:\/\//.test(t+=i)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),i=r.substr(r.indexOf("?")+1).match(n);return null!=i?i[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],i=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==i){for(var o=(n=i.split("&")).length-1;o>=0;o-=1)n[o].split("=")[0]===e&&n.splice(o,1);r="".concat(r,"?").concat(n.join("&"))}return r},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 r=new Promise(function(t,r){e=function(e,n){return e?r(e):t(n)}});return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,i.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,i=void 0===n?"":n,o=e.content,s=void 0===o?[]:o,a=e.printTrace,u=void 0!==a&&a,c=e.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,i):(console.group||console.error)(r,i);for(var h=0,l=s;h<l.length;h++){var d=l[h],p=d.type,f=d.body;switch(p){case"info":console.log(f);break;case"warn":console.warn(f);break;case"error":console.error(f)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var r=e.split("="),n=r[0],i=r[1];n=decodeURIComponent(n),i=decodeURIComponent(i),n&&(t[n]?Array.isArray(t[n])?t[n].push(i):t[n]=[t[n],i]:t[n]=i)}),t},t.parseCaptcha=function(e){var r={},i=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){e=i[1];var o=i[2];o&&(r=(0,t.parseQueryString)(o))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},764:function(e){e.exports=require("@cloudbase/adapter-interface")},917:function(e){e.exports=require("@cloudbase/adapter-wx_mp")},107:function(e){e.exports=require("jwt-decode")}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e].call(o.exports,o,o.exports,i),o.exports}t=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},i.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var o=Object.create(null);i.r(o);var s={};e=e||[null,t({}),t([]),t(t)];for(var a=2&n&&r;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach(function(e){s[e]=function(){return r[e]}});return s.default=function(){return r},i.d(o,s),o},i.d=function(e,t){for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o=i(304);module.exports=o}();
|
|
3
3
|
//# sourceMappingURL=index.js.map
|