@cloudbase/js-sdk 2.6.4-beta.0 → 2.6.6-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/miniprogram_dist/auth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_auth",[],e):"object"==typeof exports?exports.cloudbase_auth=e():t.cloudbase_auth=e()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var t={997:(t,e,r)=>{var n;r.r(e),r.d(e,{AbstractSDKRequest:()=>i,AbstractStorage:()=>o,StorageType:()=>n,formatUrl:()=>s}),function(t){t.local="local",t.none="none",t.session="session"}(n||(n={}));var i=function(){},o=function(){};function s(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),i="";for(var o in r)""===i?!n&&(e+="?"):i+="&",i+=o+"="+encodeURIComponent(r[o]);return/^http(s)?\:\/\//.test(e+=i)?e:""+t+e}},922:(t,e,r)=>{var n,i,o,s,a,c;function u(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}r.r(e),r.d(e,{Auth:()=>ot,LoginState:()=>it,generateAuthInstance:()=>st,registerAuth:()=>ct}),function(t){t.AUTH_SIGN_IN_URL="/auth/v1/signin",t.AUTH_SIGN_IN_ANONYMOUSLY_URL="/auth/v1/signin/anonymously",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v1/signin/with/provider",t.AUTH_SIGN_IN_WITH_WECHAT_URL="/auth/v1/signin/wechat/noauth",t.AUTH_SIGN_UP_URL="/auth/v1/signup",t.AUTH_TOKEN_URL="/auth/v1/token",t.AUTH_REVOKE_URL="/auth/v1/revoke",t.PROVIDER_BIND_URL="/auth/v1/user/provider/bind",t.PROVIDER_TOKEN_URL="/auth/v1/provider/token",t.PROVIDER_URI_URL="/auth/v1/provider/uri",t.USER_ME_URL="/auth/v1/user/me",t.WEDA_USER_URL="/auth/v1/plugin/weda/userinfo",t.USER_QUERY_URL="/auth/v1/user/query",t.USER_PRIFILE_URL="/auth/v1/user/profile",t.USER_BASIC_EDIT_URL="/auth/v1/user/basic/edit",t.USER_TRANS_BY_PROVIDER_URL="/auth/v1/user/trans/by/provider",t.VERIFICATION_URL="/auth/v1/verification",t.VERIFY_URL="/auth/v1/verification/verify",t.CAPTCHA_DATA_URL="/auth/v1/captcha/data",t.VERIFY_CAPTCHA_DATA_URL="/auth/v1/captcha/data/verify",t.GET_CAPTCHA_URL="/auth/v1/captcha/init",t.PROVIDER_LIST="/auth/v1/user/provider",t.PROVIDER_UNBIND_URL="/auth/v1/user/provider",t.CHECK_PWD_URL="/auth/v1/user/sudo",t.SUDO_URL="/auth/v1/user/sudo",t.BIND_CONTACT_URL="/auth/v1/user/contact",t.AUTH_SET_PASSWORD="/auth/v1/user/password",t.AUTH_RESET_PASSWORD="/auth/v1/reset",t.AUTH_GET_DEVICE_CODE="/auth/v1/device/code",t.CHECK_USERNAME="/auth/v1/checkUsername",t.CHECK_IF_USER_EXIST="/auth/v1/checkIfUserExist",t.AUTHORIZE_URL="/auth/v1/user/authorize",t.AUTHORIZE_DEVICE_URL="/auth/v1/user/device/authorize",t.AUTHORIZE_INFO_URL="/auth/v1/user/authorize/info",t.AUTHORIZED_DEVICES_DELETE_URL="/auth/v1/user/authorized/devices/",t.AUTH_REVOKE_ALL_URL="/auth/v1/user/revoke/all",t.GET_PROVIDER_TYPE="/auth/v1/mgr/provider/providerSubType",t.GET_MINIPROGRAM_QRCODE="/auth/v1/qrcode/generate",t.GET_MINIPROGRAM_QRCODE_STATUS="/auth/v1/qrcode/get/status",t.GET_USER_BEHAVIOR_LOG="/auth/v1/user/security/history"}(n||(n={})),function(t){t.AUTH_SIGN_IN_URL="/auth/v2/signin/username",t.AUTH_TOKEN_URL="/auth/v2/token",t.USER_ME_URL="/auth/v2/user/me",t.VERIFY_URL="/auth/v2/signin/verificationcode",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v2/signin/with/provider",t.AUTH_PUBLIC_KEY="/auth/v2/signin/publichkey"}(i||(i={})),function(t){t.REGISTER="REGISTER",t.SIGN_IN="SIGN_IN",t.PASSWORD_RESET="PASSWORD_RESET",t.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",t.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(o||(o={})),(c=s||(s={})).UNREACHABLE="unreachable",c.LOCAL="local",c.CANCELLED="cancelled",c.UNKNOWN="unknown",c.UNAUTHENTICATED="unauthenticated",c.RESOURCE_EXHAUSTED="resource_exhausted",c.FAILED_PRECONDITION="failed_precondition",c.INVALID_ARGUMENT="invalid_argument",c.DEADLINE_EXCEEDED="deadline_exceeded",c.NOT_FOUND="not_found",c.ALREADY_EXISTS="already_exists",c.PERMISSION_DENIED="permission_denied",c.ABORTED="aborted",c.OUT_OF_RANGE="out_of_range",c.UNIMPLEMENTED="unimplemented",c.INTERNAL="internal",c.UNAVAILABLE="unavailable",c.DATA_LOSS="data_loss",c.INVALID_PASSWORD="invalid_password",c.PASSWORD_NOT_SET="password_not_set",c.INVALID_STATUS="invalid_status",c.USER_PENDING="user_pending",c.USER_BLOCKED="user_blocked",c.INVALID_VERIFICATION_CODE="invalid_verification_code",c.TWO_FACTOR_REQUIRED="two_factor_required",c.INVALID_TWO_FACTOR="invalid_two_factor",c.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",c.UNDER_REVIEW="under_review",c.INVALID_REQUEST="invalid_request",c.UNAUTHORIZED_CLIENT="unauthorized_client",c.ACCESS_DENIED="access_denied",c.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",c.INVALID_SCOPE="invalid_scope",c.INVALID_GRANT="invalid_grant",c.SERVER_ERROR="server_error",c.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",c.INTERACTION_REQUIRED="interaction_required",c.LOGIN_REQUIRED="login_required",c.ACCOUNT_SELECTION_REQUIRED="account_selection_required",c.CONSENT_REQUIRED="consent_required",c.INVALID_REQUEST_URI="invalid_request_uri",c.INVALID_REQUEST_OBJECT="invalid_request_object",c.REQUEST_NOT_SUPPORTED="request_not_supported",c.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",c.REGISTRATION_NOT_SUPPORTED="registration_not_supported",c.CAPTCHA_REQUIRED="captcha_required",c.CAPTCHA_INVALID="captcha_invalid",function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(a||(a={}));var h=r(479);class l{constructor(){this.fnPromiseMap=new Map}async run(t,e){let r=this.fnPromiseMap.get(t);return await r||(r=new Promise(((r,n)=>{(async()=>{try{await this.runIdlePromise();const t=e();r(await t)}catch(t){n(t)}finally{this.fnPromiseMap.delete(t)}})()})),this.fnPromiseMap.set(t,r)),r}runIdlePromise(){return Promise.resolve()}}const d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f="x-request-id",p="x-device-id",g="device_id",v=async function(t,e){let r=null,n=null;try{const i=Object.assign({},e);i.method||(i.method="GET"),i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body));const o=await fetch(t,i),s=await o.json();s?.error?(n=s,n.error_uri=new URL(t).pathname):r=s}catch(e){n={error:s.UNREACHABLE,error_description:e.message,error_uri:new URL(t).pathname}}if(n)throw n;return r},y=new class{constructor(t){this._env=t?.env||""}async getItem(t){return window.localStorage.getItem(`${t}${this._env}`)}async removeItem(t){window.localStorage.removeItem(`${t}${this._env}`)}async setItem(t,e){window.localStorage.setItem(`${t}${this._env}`,e)}getItemSync(t){return window.localStorage.getItem(`${t}${this._env}`)}removeItemSync(t){window.localStorage.removeItem(`${t}${this._env}`)}setItemSync(t,e){window.localStorage.setItem(`${t}${this._env}`,e)}};function m(t){let e=!0;return t?.expires_at&&t?.access_token&&(e=t.expires_at<new Date),e}class _{constructor(t){this.credentials=null,this.singlePromise=new l,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage}getStorageCredentialsSync(){let t=null;const e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{t=JSON.parse(e),t?.expires_at&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t}async setCredentials(t){if(t?.expires_in){if(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30)),this.storage){const e=JSON.stringify(t);await this.storage.setItem(this.tokenSectionName,e)}this.credentials=t}else this.storage&&await this.storage.removeItem(this.tokenSectionName),this.credentials=null}async getCredentials(){return this.singlePromise.run("getCredentials",(async()=>(m(this.credentials)&&(this.credentials=await this.getStorageCredentials()),this.credentials)))}async getStorageCredentials(){return this.singlePromise.run("_getStorageCredentials",(async()=>{let t=null;const e=await this.storage.getItem(this.tokenSectionName);if(null!=e)try{t=JSON.parse(e),t?.expires_at&&(t.expires_at=new Date(t.expires_at))}catch(e){await this.storage.removeItem(this.tokenSectionName),t=null}return t}))}}class I{constructor(t){this.singlePromise=new l,this.apiOrigin=t.apiOrigin,this.clientId=t.clientId,this.retry=this.formatRetry(t.retry,I.defaultRetry),t.baseRequest?this.baseRequest=t.baseRequest:this.baseRequest=v,this.tokenInURL=t.tokenInURL,this.headers=t.headers,this.storage=t.storage||y,this.localCredentials=new _({tokenSectionName:`credentials_${t.clientId}`,storage:this.storage}),this.clientSecret=t.clientSecret,""!==t.clientId&&(this.basicAuth=`Basic ${function(t){let e,r,n,i,o="",s=0;const a=(t=String(t)).length%3;for(;s<t.length;){if((r=t.charCodeAt(s++))>255||(n=t.charCodeAt(s++))>255||(i=t.charCodeAt(s++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");e=r<<16|n<<8|i,o+=d.charAt(e>>18&63)+d.charAt(e>>12&63)+d.charAt(e>>6&63)+d.charAt(63&e)}return a?o.slice(0,a-3)+"===".substring(a):o}(`${t.clientId}:${t.clientSecret}`)}`),this.wxCloud=t.wxCloud;try{(function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0})()&&void 0===this.wxCloud&&t.env&&(wx.cloud.init({env:t.env}),this.wxCloud=wx.cloud)}catch(t){}this.refreshTokenFunc=t.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=t.anonymousSignInFunc}setCredentials(t){return this.localCredentials.setCredentials(t)}async getAccessToken(){const t=await this.getCredentials();if(t?.access_token)return Promise.resolve(t.access_token);const e={error:s.UNAUTHENTICATED};return Promise.reject(e)}async request(t,e){e||(e={});const r=this.formatRetry(e.retry,this.retry);if(e.headers=e.headers||{},this.headers&&(e.headers={...this.headers,...e.headers}),e.headers[f]||(e.headers[f]=u()),!e.headers[p]){const t=await this.getDeviceId();e.headers[p]=t}if(e?.withBasicAuth&&this.basicAuth&&(e.headers.Authorization=this.basicAuth),e?.withCredentials){const r=await this.getCredentials();r&&(this.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+=`access_token=${r.access_token}`):e.headers.Authorization=`${r.token_type} ${r.access_token}`)}else this.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+=`client_id=${this.clientId}`);t.startsWith("/")&&(t=this.apiOrigin+t);let n=null;const i=r+1;for(let o=0;o<i;o++){try{n=e.useWxCloud?await this.wxCloudCallFunction(t,e):await this.baseRequest(t,e);break}catch(t){if(e.withCredentials&&t&&t.error===s.UNAUTHENTICATED)return await this.setCredentials(null),Promise.reject(t);if(o===r||!t||"unreachable"!==t.error)return Promise.reject(t)}await this.sleep(I.retryInterval)}return n}async wxCloudCallFunction(t,e){let r=null,n=null;try{const{result:i}=await this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:t,method:e.method,headers:{origin:"https://servicewechat.com",...e.headers},body:e.body}});i?.body?.error_code?(n=i?.body,n.error_uri=(0,h.y)(t)):r=i?.body}catch(e){n={error:s.UNREACHABLE,error_description:e.message,error_uri:(0,h.y)(t)}}if(n)throw n;return r}async getCredentials(){let t=await this.localCredentials.getCredentials();return t?(m(t)&&(t=t&&"anonymous"===t.scope?this.anonymousSignInFunc?await this.anonymousSignInFunc(t)||await this.localCredentials.getCredentials():await this.anonymousSignIn(t):await this.refreshToken(t)),t):this.unAuthenticatedError("credentials not found")}getCredentialsSync(){return this.localCredentials.getStorageCredentialsSync()}getCredentialsAsync(){return this.getCredentials()}async getScope(){const t=await this.localCredentials.getCredentials();return t?t.scope:this.unAuthenticatedError("credentials not found")}async getGroups(){const t=await this.localCredentials.getCredentials();return t?t.groups:this.unAuthenticatedError("credentials not found")}async refreshToken(t){return this.singlePromise.run("_refreshToken",(async()=>{if(!t||!t.refresh_token)return this.unAuthenticatedError("no refresh token found in credentials");try{const e=await this.refreshTokenFunc(t.refresh_token,t);return await this.localCredentials.setCredentials(e),e}catch(t){return t.error===s.INVALID_GRANT?(await this.localCredentials.setCredentials(null),this.unAuthenticatedError(t.error_description)):Promise.reject(t)}}))}checkRetry(t){let e=null;if(("number"!=typeof t||t<I.minRetry||t>I.maxRetry)&&(e={error:s.UNREACHABLE,error_description:"wrong options param: retry"}),e)throw e;return t}formatRetry(t,e){return void 0===t?e:this.checkRetry(t)}async sleep(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}async anonymousSignIn(t){return this.singlePromise.run("_anonymous",(async()=>{if(!t||"anonymous"!==t.scope)return this.unAuthenticatedError("no anonymous in credentials");try{const t=await this.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}});return await this.localCredentials.setCredentials(t),t}catch(t){return t.error===s.INVALID_GRANT?(await this.localCredentials.setCredentials(null),this.unAuthenticatedError(t.error_description)):Promise.reject(t)}}))}async defaultRefreshTokenFunc(t,e){if(void 0===t||""===t)return this.unAuthenticatedError("refresh token not found");let r=n.AUTH_TOKEN_URL;return"v2"===e?.version&&(r=i.AUTH_TOKEN_URL),{...await this.request(r,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}}),version:e?.version||"v1"}}async getDeviceId(){if(this.deviceID)return this.deviceID;let t=await this.storage.getItem(g);return"string"==typeof t&&t.length>=16&&t.length<=48||(t=u(),await this.storage.setItem(g,t)),this.deviceID=t,t}unAuthenticatedError(t){const e={error:s.UNAUTHENTICATED,error_description:t};return Promise.reject(e)}}function b(){const{wx:t}=globalThis;if(void 0===t)return!1;if(void 0===globalThis.Page)return!1;if(!t.getSystemInfoSync)return!1;if(!t.getStorageSync)return!1;if(!t.setStorageSync)return!1;if(!t.connectSocket)return!1;if(!t.request)return!1;try{if(!t.getSystemInfoSync())return!1;if("qq"===t.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0}I.defaultRetry=2,I.minRetry=0,I.maxRetry=5,I.retryInterval=1e3;let w=!1;function S(){w=w||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{b()||(w=w||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?S():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",S,!1))}catch(t){}function E(){return w}class T{constructor(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=y),this.config=t,this.tokenSectionName=`captcha_${t.clientId}`}async request(t,e){e||(e={}),e.method||(e.method="GET");const r=`${e.method}:${t}`;let n,i=t;e.withCaptcha&&(i=await this.appendCaptchaTokenToURL(t,r,!1));try{n=await this.config.request(i,e)}catch(n){return n.error===s.CAPTCHA_REQUIRED||n.error===s.CAPTCHA_INVALID?(t=await this.appendCaptchaTokenToURL(t,r,n.error===s.CAPTCHA_INVALID),this.config.request(t,e)):Promise.reject(n)}return n}getDefaultOpenURIWithCallback(){if(!b()&&!E()&&(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap"))){const t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((()=>{document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback}async defaultOpenURIWithCallback(t,e){const{width:r="355px",height:n="355px"}=e||{};if(t.match(/^(data:.*)$/))return Promise.reject({error:s.UNIMPLEMENTED,error_description:"need to impl captcha data"});const i=document.getElementById("captcha_panel_wrap"),o=document.createElement("iframe");return i.innerHTML="",o.setAttribute("src",t),o.setAttribute("id","review-panel-iframe"),o.style.cssText=`min-width:${r};display:block;height:${n};margin:0 auto;background-color: rgb(255, 255, 255);border: none;`,i.appendChild(o),i.style.display="block",new Promise(((t,e)=>{o.onload=function(){try{const r=window.location,n=o.contentWindow.location;if(n.host+n.pathname===r.host+r.pathname){i.style.display="none";const r=new URLSearchParams(n.search),o=r.get("captcha_token");return o?t({captcha_token:o,expires_in:Number(r.get("expires_in"))}):e({error:r.get("error"),error_description:r.get("error_description")})}i.style.display="block"}catch(t){i.style.display="block"}}}))}async getCaptchaToken(t,e){if(!t){const t=await this.findCaptchaToken();if(t)return t}let r;if(b()||E()){const t=await this.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:""},withCredentials:!1});r={url:`${t.data}?state=${encodeURIComponent(e)}&token=${encodeURIComponent(t.token)}`}}else{const t=`${window.location.origin+window.location.pathname}?__captcha=on`;if(r=await this.config.request(n.GET_CAPTCHA_URL,{method:"POST",body:{client_id:this.config.clientId,redirect_uri:t,state:e},withCredentials:!1}),r.captcha_token){const t={captcha_token:r.captcha_token,expires_in:r.expires_in};return this.saveCaptchaToken(t),r.captcha_token}}const i=await this.config.openURIWithCallback(r.url);return this.saveCaptchaToken(i),i.captcha_token}async appendCaptchaTokenToURL(t,e,r){const n=await this.getCaptchaToken(r,e);return t.indexOf("?")>0?t+=`&captcha_token=${n}`:t+=`?captcha_token=${n}`,t}async saveCaptchaToken(t){t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10));const e=JSON.stringify(t);await this.config.storage.setItem(this.tokenSectionName,e)}async findCaptchaToken(){const t=await this.config.storage.getItem(this.tokenSectionName);if(null!=t)try{const e=JSON.parse(t);return e?.expires_at&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?null:e.captcha_token}catch(t){return await this.config.storage.removeItem(this.tokenSectionName),null}return null}}function R(t){if(!globalThis.IS_MP_BUILD&&t)return r(443)}class O{static parseParamsToSearch(t){return Object.keys(t).forEach((e=>{t[e]||delete t[e]})),new URLSearchParams(t).toString()}constructor(t){let{request:e}=t,r=t.credentialsClient;if(!r){const e={apiOrigin:t.apiOrigin,clientId:t.clientId,storage:t.storage,env:t.env,baseRequest:t.baseRequest,anonymousSignInFunc:t.anonymousSignInFunc,wxCloud:t.wxCloud};r=new I(e)}if(!e){const n=r.request.bind(r),i=new T({clientId:t.clientId,request:n,storage:t.storage,...t.captchaOptions});e=i.request.bind(i)}this.config={env:t.env,apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:r,storage:t.storage||y}}getParamsByVersion(t,e){const r=(0,h.I)(t),o={v2:i}[r?.version]?.[e]||n[e];return r&&delete r.version,{params:r,url:o}}async signIn(t){const e=t.version||"v1",r=this.getParamsByVersion(t,"AUTH_SIGN_IN_URL");r.params.query&&delete r.params.query;const n=await this.getEncryptParams(r.params),i=await this.config.request(r.url,{method:"POST",body:n});return await this.config.credentialsClient.setCredentials({...i,version:e}),Promise.resolve(i)}async signInAnonymously(t={}){const e=await this.config.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t});return await this.config.credentialsClient.setCredentials(e),Promise.resolve(e)}async signUp(t){const e=await this.config.request(n.AUTH_SIGN_UP_URL,{method:"POST",body:t});return await this.config.credentialsClient.setCredentials(e),Promise.resolve(e)}async signOut(){const t=await this.config.credentialsClient.getAccessToken(),e=await this.config.request(n.AUTH_REVOKE_URL,{method:"POST",body:{token:t}});return await this.config.credentialsClient.setCredentials(),Promise.resolve(e)}async revokeAllDevices(){await this.config.request(n.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})}async revokeDevice(t){await this.config.request(n.AUTHORIZED_DEVICES_DELETE_URL+t.device_id,{method:"DELETE",withCredentials:!0})}async getVerification(t){let e=!1;return("CUR_USER"===t.target||await this.hasLoginState())&&(e=!0),this.config.request(n.VERIFICATION_URL,{method:"POST",body:t,withCredentials:e})}async verify(t){const e=this.getParamsByVersion(t,"VERIFY_URL"),r=await this.config.request(e.url,{method:"POST",body:e.params});return"v2"===t?.version&&await this.config.credentialsClient.setCredentials({...r,version:"v2"}),r}async genProviderRedirectUri(t){let e=`${n.PROVIDER_URI_URL}?client_id=${this.config.clientId}&provider_id=${t.provider_id}&redirect_uri=${encodeURIComponent(t.provider_redirect_uri)}&state=${t.state}`;const{other_params:r}=t;return r&&"string"==typeof r.sign_out_uri&&r.sign_out_uri.length>0&&(e+=`&other_params[sign_out_uri]=${r.sign_out_uri}`),this.config.request(e,{method:"GET"})}async grantProviderToken(t,e=!1){return this.config.request(n.PROVIDER_TOKEN_URL,{method:"POST",body:t,useWxCloud:e})}async patchProviderToken(t){return this.config.request(n.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})}async signInWithProvider(t,e=!1){const r=this.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),n=await this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:e});return await this.config.credentialsClient.setCredentials({...n,version:t?.version||"v1"}),Promise.resolve(n)}async signInWithWechat(t={}){const e=await this.config.request(n.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:t});return await this.config.credentialsClient.setCredentials(e),Promise.resolve(e)}async bindWithProvider(t){return this.config.request(n.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})}async getUserProfile(t){return this.getUserInfo(t)}async getUserInfo(t={}){const e=this.getParamsByVersion(t,"USER_ME_URL");if(e.params?.query){const t=new URLSearchParams(e.params.query);e.url+=`?${t.toString()}`}const r=await this.config.request(e.url,{method:"GET",withCredentials:!0});return r.sub&&(r.uid=r.sub),r}async getWedaUserInfo(){return await this.config.request(n.WEDA_USER_URL,{method:"GET",withCredentials:!0})}async deleteMe(t){const e=this.getParamsByVersion(t,"USER_ME_URL"),r=`${e.url}?${O.parseParamsToSearch(e.params)}`;return this.config.request(r,{method:"DELETE",withCredentials:!0})}async hasLoginState(){try{return await this.config.credentialsClient.getAccessToken(),!0}catch(t){return!1}}hasLoginStateSync(){return this.config.credentialsClient.getCredentialsSync()}async getLoginState(){return this.config.credentialsClient.getCredentialsAsync()}async transByProvider(t){return this.config.request(n.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})}async grantToken(t){const e=this.getParamsByVersion(t,"AUTH_TOKEN_URL");return this.config.request(e.url,{method:"POST",body:e.params})}async getProviders(){return this.config.request(n.PROVIDER_LIST,{method:"GET",withCredentials:!0})}async unbindProvider(t){return this.config.request(`${n.PROVIDER_UNBIND_URL}/${t.provider_id}`,{method:"DELETE",withCredentials:!0})}async checkPassword(t){return this.config.request(`${n.CHECK_PWD_URL}`,{method:"POST",withCredentials:!0,body:t})}async editContact(t){return this.config.request(`${n.BIND_CONTACT_URL}`,{method:"PATCH",withCredentials:!0,body:t})}async setPassword(t){return this.config.request(`${n.AUTH_SET_PASSWORD}`,{method:"PATCH",withCredentials:!0,body:t})}async updatePasswordByOld(t){const e=await this.sudo({password:t.old_password});return this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})}async sudo(t){return this.config.request(`${n.SUDO_URL}`,{method:"POST",withCredentials:!0,body:t})}async sendVerificationCodeToCurrentUser(t){return t.target="CUR_USER",this.config.request(n.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})}async changeBoundProvider(t){return this.config.request(`${n.PROVIDER_LIST}/${t.provider_id}/trans`,{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})}async setUserProfile(t){return this.config.request(n.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})}async updateUserBasicInfo(t){return this.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:t})}async queryUserProfile(t){const e=new URLSearchParams(t);return this.config.request(`${n.USER_QUERY_URL}?${e.toString()}`,{method:"GET",withCredentials:!0})}setCustomSignFunc(t){this.getCustomSignTicketFn=t}async signInWithCustomTicket(t){const e=this.getCustomSignTicketFn;if(!e)return Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"});const r=await e();return this.signInWithProvider({...t,provider_id:"custom",provider_token:r})}async resetPassword(t){return this.config.request(n.AUTH_RESET_PASSWORD,{method:"POST",body:t})}async authorize(t){return this.config.request(n.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:t})}async authorizeDevice(t){return this.config.request(n.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:t})}async deviceAuthorize(t){return this.config.request(n.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})}async authorizeInfo(t){const e=`${n.AUTHORIZE_INFO_URL}?${O.parseParamsToSearch(t)}`;let r=!0,i=!1;return await this.hasLoginState()&&(i=!0,r=!1),this.config.request(e,{method:"GET",withBasicAuth:r,withCredentials:i})}async checkUsername(t){return this.config.request(n.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})}async checkIfUserExist(t){const e=new URLSearchParams(t);return this.config.request(`${n.CHECK_IF_USER_EXIST}?${e.toString()}`,{method:"GET"})}async loginScope(){return this.config.credentialsClient.getScope()}async loginGroups(){return this.config.credentialsClient.getGroups()}async refreshTokenForce(t){const e=await this.config.credentialsClient.getCredentials();return await this.config.credentialsClient.refreshToken({...e,version:t?.version||"v1"})}async getCredentials(){return this.config.credentialsClient.getCredentials()}async getPublicKey(){return this.config.request(i.AUTH_PUBLIC_KEY,{method:"POST",body:{}})}async getEncryptParams(t){const{isEncrypt:e}=t;delete t.isEncrypt;const r=(0,h.I)(t),n=R(e);if(!n)return t;let i="",o="";try{const t=await this.getPublicKey();i=t.public_key,o=t.public_key_thumbprint}catch(t){}if(!i||!o)throw new Error("public_key or public_key_thumbprint is empty");return{params:n.getEncryptInfo({publicKey:i,payload:r}),public_key_thumbprint:o}}async getProviderSubType(){return this.config.request(n.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})}async verifyCaptchaData({token:t,key:e}){return this.config.request(n.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:e},withCredentials:!1})}async createCaptchaData({state:t,redirect_uri:e}){return this.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:e},withCredentials:!1})}async getMiniProgramCode(t){return this.config.request(n.GET_MINIPROGRAM_QRCODE,{method:"POST",body:t})}async getMiniProgramQrCodeStatus(t){return this.config.request(n.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:t})}async getUserBehaviorLog(t){const e=`${n.GET_USER_BEHAVIOR_LOG}?${{LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"}[t.type]}&limit=${t.limit}${t.page_token?`&page_token=${t.page_token}`:""}`;return this.config.request(e,{method:"GET",withCredentials:!0})}async modifyPassword(t){let e="",r="";const i=R(!0);if(!i)throw new Error("do not support encrypt, a encrypt util required.");try{const t=await this.getPublicKey();e=t.public_key,r=t.public_key_thumbprint}catch(t){}if(!e||!r)throw new Error("public_key or public_key_thumbprint is empty");const o=t.password?i.getEncryptInfo({publicKey:e,payload:t.password}):"",s=i.getEncryptInfo({publicKey:e,payload:t.new_password});return this.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:t.user_id,encrypt_password:o,encrypt_new_password:s,public_key_thumbprint:r}})}}class A{constructor(t){const{apiOrigin:e,clientId:r,env:n,storage:i,request:o,baseRequest:s,anonymousSignInFunc:a,wxCloud:c}=t;this.oauth2client=new I({apiOrigin:e,clientId:r,env:n,storage:i,baseRequest:s||o,anonymousSignInFunc:a,wxCloud:c}),this.authApi=new O({credentialsClient:this.oauth2client,...t,request:o?this.oauth2client.request.bind(this.oauth2client):void 0})}}var P,C=r(894),U=r(141),N=r(466),L=r(988),D=r(418),x=r(997),k=(P=function(t,e){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},P(t,e)},function(t,e){function r(){this.constructor=t}P(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),M=function(){return M=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},M.apply(this,arguments)},q=function(t){function e(e){void 0===e&&(e={});var r=t.call(this)||this,n=e.timeout,i=e.timeoutMsg,o=e.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=i||"请求超时",r._restrictedMethods=o||["get","post","upload","download"],r}return k(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(r,n){var i=t.url,o=t.data,s=t.headers,a=wx.request({url:(0,x.formatUrl)("https:",i),data:o,timeout:e._timeout,method:"POST",header:s,success:function(t){r(t)},fail:function(t){n(t)},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("post")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{a.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,r=this;return new Promise((function(n){return i=e,o=void 0,a=function(){var e,i,o,s,a,c;return function(t,e){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(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}(this,(function(u){return e=t.url,i=t.file,o=t.data,s=t.headers,a=t.onUploadProgress,c=wx.uploadFile({url:e,filePath:i,name:"file",formData:M({},o),header:s,timeout:this._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&o.success_action_status&&(e.statusCode=parseInt(o.success_action_status,10)),n(e)},fail:function(t){n(t)},complete:function(t){if(t&&t.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(r._timeoutMsg);try{c.abort()}catch(t){}}}}),a&&c.onProgressUpdate((function(t){a(t)})),[2]}))},new((s=void 0)||(s=Promise))((function(t,e){function r(t){try{c(a.next(t))}catch(t){e(t)}}function n(t){try{c(a.throw(t))}catch(t){e(t)}}function c(e){var i;e.done?t(e.value):(i=e.value,i instanceof s?i:new s((function(t){t(i)}))).then(r,n)}c((a=a.apply(i,o||[])).next())}));var i,o,s,a}))},e.prototype.download=function(t){var e=this,r=this;return new Promise((function(n,i){var o=t.url,s=t.headers,a=wx.downloadFile({url:(0,x.formatUrl)("https:",o),header:s,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?n({statusCode:200,tempFilePath:t.tempFilePath}):n(t)},fail:function(t){i(t)},complete:function(t){if(t&&t.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg){console.warn(r._timeoutMsg);try{a.abort()}catch(t){}}}})}))},e}(x.AbstractSDKRequest),B={setItem:function(t,e){wx.setStorageSync(t,e)},getItem:function(t){return wx.getStorageSync(t)},removeItem:function(t){wx.removeStorageSync(t)},clear:function(){wx.clearStorageSync()}},j=function(t,e){void 0===e&&(e={});var r=wx.connectSocket(M({url:t},e));return{set onopen(t){r.onOpen(t)},set onmessage(t){r.onMessage(t)},set onclose(t){r.onClose(t)},set onerror(t){r.onError(t)},send:function(t){return r.send({data:t})},close:function(t,e){return r.close({code:t,reason:e})},get readyState(){return r.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};const V=function(){return{root:{},reqClass:q,wsClass:j,localStorage:B,primaryStorage:x.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},F=function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0};var H=r(105),W=function(){return W=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},W.apply(this,arguments)},G=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},$=function(t,e){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(c){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=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},K=function(){function t(t){this.localStorage=(null==t?void 0:t.localStorage)||globalThis.localStorage}return t.prototype.getItem=function(t){return G(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return G(this,void 0,void 0,(function(){return $(this,(function(e){return this.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return G(this,void 0,void 0,(function(){return $(this,(function(r){return this.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return this.localStorage.getItem(t)},t.prototype.setItemSync=function(t,e){this.localStorage.setItem(t,e)},t.prototype.removeItemSync=function(t){this.localStorage.removeItem(t)},t}(),Y=/^[^:]+:\/\/[^/]+(\/[^?#]+)/;var z=function(t){if(!F()||t.storage&&t.baseRequest)return t;var e={};try{var r=V(),n=r.localStorage,i=r.reqClass;if(n&&(e.storage=new K({localStorage:n})),i){var o=new i({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});e.request=function(t){return function(e,r){var n;return G(this,void 0,void 0,(function(){var i;return $(this,(function(o){return i=null===(n=null==r?void 0:r.headers)||void 0===n?void 0:n["x-request-id"],[2,new Promise((function(n,o){var s=Object.assign({},r);s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));var a=wx.request({url:e,data:s.body,timeout:t._timeout,method:s.method||"GET",header:s.headers,success:function(t){t.code&&(t={error:t.code,error_description:t.message||t.code,request_id:t.requestId}),t.request_id||(t.request_id=t.request_id||i),t.error&&(t.error_uri=function(t){return Y.test(t)?RegExp.$1:t}(e),o(t)),n(t.data||{})},fail:function(t){o({error:"unreachable",error_description:t.message})},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("request")&&"request:fail timeout"===e.errMsg){console.warn(t._timeoutMsg);try{a.abort()}catch(t){}}}})}))]}))}))}}(o)}return W(W({},t),e)}catch(t){console.error("adapter generate fail:",t)}return t},Q=function(){return Q=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Q.apply(this,arguments)},Z=function(t,e,r,n){var i,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},J=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},X=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},tt=function(t,e){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(c){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=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},et="loginStateChanged",rt=new L.CloudbaseEventEmitter,nt=function(){function t(t){var e=t.cache,r=t.oauthInstance;this.cache=e,this.oauthInstance=r,this.setUserInfo()}return t.prototype.checkLocalInfo=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return X(this,void 0,void 0,(function(){var t,e,r,n;return tt(this,(function(i){switch(i.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=i.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.gender=i.sent(),this.picture=this.getLocalUserInfo("picture"),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]}}))}))},t.prototype.update=function(t){return X(this,void 0,void 0,(function(){var e;return tt(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(Q({},t))];case 1:return e=r.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updateUserBasicInfo=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(Q({},t))];case 1:return e.sent(),this.setLocalUserInfo({username:t.username}),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&(0,C.throwError)(U.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(t){return X(this,void 0,void 0,(function(){var e;return tt(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(t)];case 1:return e=r.sent(),this.setLocalUserInfo(e),[2,e]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;return this.cache.getStore(e)[t]},t.prototype.getLocalUserInfoAsync=function(t){return X(this,void 0,void 0,(function(){var e;return tt(this,(function(r){switch(r.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,r.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,r=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username"].forEach((function(e){t[e]=r[e]}))},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},Z([(0,N.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"update",null),Z([(0,N.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[String,String]),J("design:returntype",void 0)],t.prototype,"updatePassword",null),Z([(0,N.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[String]),J("design:returntype",void 0)],t.prototype,"updateUsername",null),Z([(0,N.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"refresh",null),t}(),it=function(){function t(t){var e=t.envId,r=t.cache,n=t.oauthInstance;e||(0,C.throwError)(U.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new nt({cache:this.cache,oauthInstance:n})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}}))}))},t}(),ot=function(){function t(t){this.config=t,this.cache=t.cache,this.oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.editContact(t)]}))}))},t.prototype.unbindProvider=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},t.prototype.bindEmail=function(t){return this.oauthInstance.authApi.editContact(t)},t.prototype.verify=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.getVerification(t)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}(0,C.printWarn)(U.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return X(this,void 0,void 0,(function(){var t;return tt(this,(function(e){switch(e.label){case 0:return[4,this.getLoginState()];case 1:return(t=e.sent())?[4,t.user.checkLocalInfoAsync()]:[3,3];case 2:return e.sent(),[2,t.user||null];case 3:return[2,null]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInWithOpenId=function(t){var e=(void 0===t?{}:t).useWxCloud,r=void 0===e||e;return X(this,void 0,void 0,(function(){var t,e,n=this;return tt(this,(function(i){switch(i.label){case 0:if(!F())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return X(n,void 0,void 0,(function(){var n,i;return tt(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==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.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]}}))}))},[4,new Promise((function(t,r){wx.login({success:function(i){return X(n,void 0,void 0,(function(){var n;return tt(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,e(i.code)];case 1:return o.sent(),t(!0),[3,3];case 2:return n=o.sent(),r(n),[3,3];case 3:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})}))];case 1:return i.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInWithUnionId=function(){return X(this,void 0,void 0,(function(){var t=this;return tt(this,(function(e){switch(e.label){case 0:if(!F())throw Error("wx api undefined");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,new Promise((function(e,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(i){return X(t,void 0,void 0,(function(){var t,o,s,a,c;return tt(this,(function(u){switch(u.label){case 0:t=null==n?void 0:n.appId,u.label=1;case 1:return u.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:i.code,provider_id:t,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return o=u.sent(),(s=o.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:t,provider_token:s})]:(r(o),[2]);case 3:return(null==(a=u.sent())?void 0:a.error_code)?(r(a),[2]):(e(!0),[3,5]);case 4:return c=u.sent(),r(c),[3,5];case 5:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})}))];case 2:return e.sent(),[3,4];case 3:throw e.sent();case 4:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithPhoneAuth=function(t){var e=t.phoneCode,r=void 0===e?"":e;return X(this,void 0,void 0,(function(){var t,e,n,i,o;return tt(this,(function(s){switch(s.label){case 0:if(!F())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e={provider_params:{provider_code_type:"phone"},provider_id:t.appId},[4,wx.login()];case 1:n=s.sent().code,e.provider_code=n,s.label=2;case 2:return s.trys.push([2,6,,7]),[4,this.oauthInstance.authApi.grantProviderToken(e)];case 3:if((i=s.sent()).error_code)throw i;return[4,this.oauthInstance.authApi.patchProviderToken({provider_token:i.provider_token,provider_id:t.appId,provider_params:{code:r,provider_code_type:"phone"}})];case 4:if((i=s.sent()).error_code)throw i;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:i.provider_token})];case 5:if(null==(o=s.sent())?void 0:o.error_code)throw o;return[3,7];case 6:throw s.sent();case 7:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithSms=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,i=void 0===n?"":n,o=t.phoneNum,s=void 0===o?"":o,a=t.bindInfo,c=void 0===a?void 0:a;return X(this,void 0,void 0,(function(){var t,e,n,o,a;return tt(this,(function(u){switch(u.label){case 0:return u.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:i})];case 1:if(null==(t=u.sent())?void 0:t.error_code)throw t;return e=t.verification_token,r.is_user?[4,this.oauthInstance.authApi.signIn({username:"+86 ".concat(s),verification_token:e})]:[3,5];case 2:if(null==(n=u.sent())?void 0:n.error_code)throw n;return c?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==c?void 0:c.providerToken})]:[3,4];case 3:if(null==(o=u.sent())?void 0:o.error_code)throw o;u.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp({phone_number:"+86 ".concat(s),verification_token:e,provider_token:null==c?void 0:c.providerId})];case 6:if(null==(a=u.sent())?void 0:a.error_code)throw a;u.label=7;case 7:return[2,this.createLoginState()];case 8:throw u.sent();case 9:return[2]}}))}))},t.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithCustomTicket(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signIn=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.signUp=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signUp(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setPassword=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,C.throwError)(U.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,e.sent().exist]}}))}))},t.prototype.signOut=function(){return X(this,void 0,void 0,(function(){var t;return tt(this,(function(e){switch(e.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut()];case 1:return e.sent(),[4,this.cache.removeStoreAsync(t)];case 2:return e.sent(),rt.fire(et),[2]}}))}))},t.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new it({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,C.printWarn)(U.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.getLoginState()];case 1:return t.sent()?[2,new it({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.getUserInfo(t)]}))}))},t.prototype.getWedaUserInfo=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(t){return X(this,void 0,void 0,(function(){var e;return tt(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(e=r.sent())?[4,e.user.updateUserBasicInfo(t)]:[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(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}}))}))},t.prototype.grantProviderToken=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.patchProviderToken=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.grantToken=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return X(this,void 0,void 0,(function(){var e,r=this;return tt(this,(function(n){switch(n.label){case 0:return rt.on(et,(function(){return X(r,void 0,void 0,(function(){var e;return tt(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return e=r.sent(),t.call(this,e),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))},t.prototype.refreshTokenForce=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]}))}))},t.prototype.getCredentials=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getProviderSubType=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]}))}))},t.prototype.verifyCaptchaData=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]}))}))},t.prototype.getMiniProgramQrCode=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]}))}))},t.prototype.modifyPassword=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.modifyPassword(t)]}))}))},t.prototype.getUserBehaviorLog=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.getUserBehaviorLog(t)]}))}))},t.prototype.createLoginState=function(t){return X(this,void 0,void 0,(function(){var e;return tt(this,(function(r){switch(r.label){case 0:return[4,(e=new it({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return r.sent(),[4,e.user.refresh(t)];case 2:return r.sent(),rt.fire(et),[2,e]}}))}))},Z([(0,N.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),Z([(0,N.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"unbindProvider",null),Z([(0,N.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",void 0)],t.prototype,"bindEmail",null),Z([(0,N.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"verify",null),Z([(0,N.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"getVerification",null),Z([(0,N.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[]),J("design:returntype",Promise)],t.prototype,"getCurrentUser",null),Z([(0,N.catchErrorsDecorator)({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"signInAnonymously",null),Z([(0,N.catchErrorsDecorator)({title:"小程序openId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().signInWithOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"signInWithOpenId",null),Z([(0,N.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[]),J("design:returntype",Promise)],t.prototype,"signInWithUnionId",null),Z([(0,N.catchErrorsDecorator)({title:"小程序手机号授权登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序手机号授权登录"," 2 - 调用 auth().signInWithPhoneAuth() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"signInWithPhoneAuth",null),Z([(0,N.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"signInWithSms",null),Z([(0,N.catchErrorsDecorator)({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),Z([(0,N.catchErrorsDecorator)({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"signUp",null),Z([(0,N.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[String]),J("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),Z([(0,N.catchErrorsDecorator)({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[]),J("design:returntype",Promise)],t.prototype,"signOut",null),Z([(0,N.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[]),J("design:returntype",Promise)],t.prototype,"getLoginState",null),Z([(0,N.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"getUserInfo",null),Z([(0,N.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[]),J("design:returntype",Promise)],t.prototype,"getWedaUserInfo",null),Z([(0,N.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"bindWithProvider",null),Z([(0,N.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[]),J("design:returntype",Promise)],t.prototype,"getProviderSubType",null),t}();function st(t,e){var r=t.region,n=void 0===r?"ap-shanghai":r,i=(null==e?void 0:e.platform)||(0,H.useDefaultAdapter)(),o=i.runtime,s=e||{},a=s.env,c=s.clientId,u=s.debug,h=s.cache,l=s.app,d=(e||{}).apiOrigin;d||(d="https://".concat(a,".").concat(n,".tcb-api.tencentcloudapi.com"));var f=new A(z({env:a,clientId:c,apiOrigin:d,storage:null==t?void 0:t.storage,baseRequest:null==t?void 0:t.baseRequest,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc,captchaOptions:null==t?void 0:t.captchaOptions,wxCloud:null==t?void 0:t.wxCloud}));return{authInstance:new ot({env:a,region:n,persistence:t.persistence,debug:u,cache:h||new D.CloudbaseCache({persistence:t.persistence,keys:{userInfoKey:"user_info_".concat(a)},platformInfo:i}),runtime:o||"web",_fromApp:l,oauthInstance:f}),oauthInstance:f}}var at={name:"auth",namespace:"auth",entity:function(t){if(void 0===t&&(t={region:"",persistence:"local"}),this.authInstance)return(0,C.printWarn)(U.ERRORS.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var e=this.platform.adapter,r=t.persistence||e.primaryStorage;r&&r!==this.config.persistence&&this.updateConfig({persistence:r});var n=st(Q(Q({wxCloud:this.config.wxCloud,storage:this.config.storage},t),{persistence:this.config.persistence}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),i=n.authInstance,o=n.oauthInstance;return this.oauthInstance=o,this.authInstance=i,this.authInstance}};try{cloudbase.registerComponent(at)}catch(t){}function ct(t){try{t.registerComponent(at)}catch(t){console.warn(t)}}},443:(t,e,r)=>{let n;if(r.r(e),r.d(e,{getEncryptInfo:()=>D}),!globalThis.IS_MP_BUILD){const x="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;var i="0123456789abcdefghijklmnopqrstuvwxyz";function k(t){return i.charAt(t)}function M(t,e){return t&e}function q(t,e){return t|e}function B(t,e){return t^e}function j(t,e){return t&~e}function V(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function F(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s="=";function H(t){var e,r,n="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),n+=o.charAt(r>>6)+o.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=o.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=o.charAt(r>>2)+o.charAt((3&r)<<4));(3&n.length)>0;)n+=s;return n}function W(t){var e,r="",n=0,i=0;for(e=0;e<t.length&&t.charAt(e)!=s;++e){var a=o.indexOf(t.charAt(e));a<0||(0==n?(r+=k(a>>2),i=3&a,n=1):1==n?(r+=k(i<<2|a>>4),i=15&a,n=2):2==n?(r+=k(i),r+=k(a>>2),i=3&a,n=3):(r+=k(i<<2|a>>4),r+=k(15&a),n=0))}return 1==n&&(r+=k(i<<2)),r}var a,c,u={decode:function(t){var e;if(void 0===a){var r="0123456789ABCDEF",n=" \f\n\r\t \u2028\u2029";for(a={},e=0;e<16;++e)a[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)a[r.charAt(e)]=e;for(e=0;e<n.length;++e)a[n.charAt(e)]=-1}var i=[],o=0,s=0;for(e=0;e<t.length;++e){var c=t.charAt(e);if("="==c)break;if(-1!=(c=a[c])){if(void 0===c)throw new Error("Illegal character at offset "+e);o|=c,++s>=2?(i[i.length]=o,o=0,s=0):o<<=4}}if(s)throw new Error("Hex encoding incomplete: 4 bits missing");return i}},h={decode:function(t){var e;if(void 0===c){var r="= \f\n\r\t \u2028\u2029";for(c=Object.create(null),e=0;e<64;++e)c["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<r.length;++e)c[r.charAt(e)]=-1}var n=[],i=0,o=0;for(e=0;e<t.length;++e){var s=t.charAt(e);if("="==s)break;if(-1!=(s=c[s])){if(void 0===s)throw new Error("Illegal character at offset "+e);i|=s,++o>=4?(n[n.length]=i>>16,n[n.length]=i>>8&255,n[n.length]=255&i,i=0,o=0):i<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=i>>10;break;case 3:n[n.length]=i>>16,n[n.length]=i>>8&255}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=h.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return h.decode(t)}},l=1e13;class G{constructor(t){this.buf=[+t||0]}mulAdd(t,e){var r,n,i=this.buf,o=i.length;for(r=0;r<o;++r)(n=i[r]*t+e)<l?e=0:n-=(e=0|n/l)*l,i[r]=n;e>0&&(i[r]=e)}sub(t){var e,r,n=this.buf,i=n.length;for(e=0;e<i;++e)(r=n[e]-t)<0?(r+=l,t=1):t=0,n[e]=r;for(;0===n[n.length-1];)n.pop()}toString(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),n=e.length-2;n>=0;--n)r+=(l+e[n]).toString().substring(1);return r}valueOf(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*l+t[r];return e}simplify(){var t=this.buf;return 1==t.length?t[0]:this}}var d,f="…",p=/^(\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)?)?$/,g=/^(\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 $(t,e){return t.length>e&&(t=t.substring(0,e)+f),t}class K{constructor(t,e){this.hexDigits="0123456789ABCDEF",t instanceof K?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}get(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]}hexByte(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)}hexDump(t,e,r){for(var n="",i=t;i<e;++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(t,e){for(var r=t;r<e;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(t,e){for(var r="",n=t;n<e;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(t,e){for(var r="",n=t;n<e;){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(t,e){for(var r,n,i="",o=t;o<e;)r=this.get(o++),n=this.get(o++),i+=String.fromCharCode(r<<8|n);return i}parseTime(t,e,r){var n=this.parseStringISO(t,e),i=(r?p:g).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(t,e){for(var r,n=this.get(t),i=n>127,o=i?255:0,s="";n==o&&++t<e;)n=this.get(t);if(0==(r=e-t))return i?-1:0;if(r>4){for(s=n,r<<=3;0==(128&(+s^o));)s=+s<<1,--r;s="("+r+" bit)\n"}i&&(n-=256);for(var a=new G(n),c=t+1;c<e;++c)a.mulAdd(256,this.get(c));return s+a.toString()}parseBitString(t,e,r){for(var n=this.get(t),i="("+((e-t-1<<3)-n)+" bit)\n",o="",s=t+1;s<e;++s){for(var a=this.get(s),c=s==e-1?n:0,u=7;u>=c;--u)o+=a>>u&1?"1":"0";if(o.length>r)return i+$(o,r)}return i+o}parseOctetString(t,e,r){if(this.isASCII(t,e))return $(this.parseStringISO(t,e),r);var n=e-t,i="("+n+" byte)\n";n>(r/=2)&&(e=t+r);for(var o=t;o<e;++o)i+=this.hexByte(this.get(o));return n>r&&(i+=f),i}parseOID(t,e,r){for(var n="",i=new G,o=0,s=t;s<e;++s){var a=this.get(s);if(i.mulAdd(128,127&a),o+=7,!(128&a)){if(""===n)if((i=i.simplify())instanceof G)i.sub(80),n="2."+i.toString();else{var c=i<80?i<40?0:1:2;n=c+"."+(i-40*c)}else n+="."+i.toString();if(n.length>r)return $(n,r);i=new G,o=0}}return o>0&&(n+=".incomplete"),n}}class Y{constructor(t,e,r,n,i){if(!(n instanceof z))throw new Error("Invalid tag value.");this.stream=t,this.header=e,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(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+r,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);case 6:return this.stream.parseOID(e,e+r,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return $(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return $(this.stream.parseStringISO(e,e+r),t);case 30:return $(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+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(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var r=0,n=this.sub.length;r<n;++r)e+=this.sub[r].toPrettyString(t)}return e}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(t){var e=t.get(),r=127&e;if(r==e)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var n=0;n<r;++n)e=256*e+t.get();return e}getHexStringValue(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)}static decode(t){var e;e=t instanceof K?t:new K(t,0);var r=new K(e),n=new z(e),i=Y.decodeLength(e),o=e.pos,s=o-r.pos,a=null,c=function(){var t=[];if(null!==i){for(var r=o+i;e.pos<r;)t[t.length]=Y.decode(e);if(e.pos!=r)throw new Error("Content size is not correct for container starting at offset "+o)}else try{for(;;){var n=Y.decode(e);if(n.tag.isEOC())break;t[t.length]=n}i=o-e.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(n.tagConstructed)a=c();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=e.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=c();for(var u=0;u<a.length;++u)if(a[u].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){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);e.pos=o+Math.abs(i)}return new Y(r,s,i,n,a)}}class z{constructor(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){var r=new G;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var v=[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],y=(1<<26)/v[v.length-1];class Q{constructor(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}toString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<<e)-1,i=!1,o="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(i=!0,o=k(r));s>=0;)a<e?(r=(this[s]&(1<<a)-1)<<e-a,r|=this[--s]>>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=k(r));return i?o:"0"}negate(){var t=Z();return Q.ZERO.subTo(this,t),t}abs(){return this.s<0?this.negate():this}compareTo(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+it(this[this.t-1]^this.s&this.DM)}mod(t){var e=Z();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(Q.ZERO)>0&&t.subTo(e,e),e}modPowInt(t,e){var r;return r=t<256||e.isEven()?new _(e):new I(e),this.exp(t,r)}clone(){var t=Z();return this.copyTo(t),t}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 t=this.t,e=[];e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e}equals(t){return 0==this.compareTo(t)}min(t){return this.compareTo(t)<0?this:t}max(t){return this.compareTo(t)>0?this:t}and(t){var e=Z();return this.bitwiseTo(t,M,e),e}or(t){var e=Z();return this.bitwiseTo(t,q,e),e}xor(t){var e=Z();return this.bitwiseTo(t,B,e),e}andNot(t){var e=Z();return this.bitwiseTo(t,j,e),e}not(){for(var t=Z(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}shiftLeft(t){var e=Z();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}shiftRight(t){var e=Z();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}getLowestSetBit(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+V(this[t]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=F(this[r]^e);return t}testBit(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)}setBit(t){return this.changeBit(t,q)}clearBit(t){return this.changeBit(t,j)}flipBit(t){return this.changeBit(t,B)}add(t){var e=Z();return this.addTo(t,e),e}subtract(t){var e=Z();return this.subTo(t,e),e}multiply(t){var e=Z();return this.multiplyTo(t,e),e}divide(t){var e=Z();return this.divRemTo(t,e,null),e}remainder(t){var e=Z();return this.divRemTo(t,null,e),e}divideAndRemainder(t){var e=Z(),r=Z();return this.divRemTo(t,e,r),[e,r]}modPow(t,e){var r,n,i=t.bitLength(),o=nt(1);if(i<=0)return o;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new _(e):e.isEven()?new b(e):new I(e);var s=[],a=3,c=r-1,u=(1<<r)-1;if(s[1]=n.convert(this),r>1){var h=Z();for(n.sqrTo(s[1],h);a<=u;)s[a]=Z(),n.mulTo(h,s[a-2],s[a]),a+=2}var l,d,f=t.t-1,p=!0,g=Z();for(i=it(t[f])-1;f>=0;){for(i>=c?l=t[f]>>i-c&u:(l=(t[f]&(1<<i+1)-1)<<c-i,f>0&&(l|=t[f-1]>>this.DB+i-c)),a=r;0==(1&l);)l>>=1,--a;if((i-=a)<0&&(i+=this.DB,--f),p)s[l].copyTo(o),p=!1;else{for(;a>1;)n.sqrTo(o,g),n.sqrTo(g,o),a-=2;a>0?n.sqrTo(o,g):(d=o,o=g,g=d),n.mulTo(g,s[l],o)}for(;f>=0&&0==(t[f]&1<<i);)n.sqrTo(o,g),d=o,o=g,g=d,--i<0&&(i=this.DB-1,--f)}return n.revert(o)}modInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return Q.ZERO;for(var r=t.clone(),n=this.clone(),i=nt(1),o=nt(0),s=nt(0),a=nt(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(i.isEven()&&o.isEven()||(i.addTo(this,i),o.subTo(t,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),e?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(t,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}return 0!=n.compareTo(Q.ONE)?Q.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}pow(t){return this.exp(t,new m)}gcd(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i<o&&(o=i),o>0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r}isProbablePrime(t){var e,r=this.abs();if(1==r.t&&r[0]<=v[v.length-1]){for(e=0;e<v.length;++e)if(r[0]==v[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<v.length;){for(var n=v[e],i=e+1;i<v.length&&n<y;)n*=v[i++];for(n=r.modInt(n);e<i;)if(n%v[e++]==0)return!1}return r.millerRabin(t)}copyTo(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}fromInt(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}fromString(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&+t[n]:rt(t,n);s<0?"-"==t.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&&0!=(128&+t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),i&&Q.ZERO.subTo(this,this)}clamp(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}dlShiftTo(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s}drShiftTo(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s}lShiftTo(t,e){for(var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,o=Math.floor(t/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+o+1]=this[a]>>n|s,s=(this[a]&i)<<r;for(a=o-1;a>=0;--a)e[a]=0;e[o]=s,e.t=this.t+o+1,e.s=this.s,e.clamp()}rShiftTo(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<<n)-1;e[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)e[s-r-1]|=(this[s]&o)<<i,e[s-r]=this[s]>>n;n>0&&(e[this.t-r-1]|=(this.s&o)<<i),e.t=this.t-r,e.clamp()}}subTo(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()}multiplyTo(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i<n.t;++i)e[i+r.t]=r.am(0,n[i],e,i,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&Q.ZERO.subTo(e,e)}squareTo(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()}divRemTo(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=Z());var o=Z(),s=this.s,a=t.s,c=this.DB-it(n[n.t-1]);c>0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var u=o.t,h=o[u-1];if(0!=h){var l=h*(1<<this.F1)+(u>1?o[u-2]>>this.F2:0),d=this.FV/l,f=(1<<this.F1)/l,p=1<<this.F2,g=r.t,v=g-u,y=null==e?Z():e;for(o.dlShiftTo(v,y),r.compareTo(y)>=0&&(r[r.t++]=1,r.subTo(y,r)),Q.ONE.dlShiftTo(u,y),y.subTo(o,o);o.t<u;)o[o.t++]=0;for(;--v>=0;){var m=r[--g]==h?this.DM:Math.floor(r[g]*d+(r[g-1]+p)*f);if((r[g]+=o.am(0,m,r,v,0,u))<m)for(o.dlShiftTo(v,y),r.subTo(y,r);r[g]<--m;)r.subTo(y,r)}null!=e&&(r.drShiftTo(u,e),s!=a&&Q.ZERO.subTo(e,e)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),s<0&&Q.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(t,e){if(t>4294967295||t<1)return Q.ONE;var r=Z(),n=Z(),i=e.convert(this),o=it(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<<o)>0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)}chunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}toRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=nt(r),i=Z(),o=Z(),s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s}fromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a<t.length;++a){var c=rt(t,a);c<0?"-"==t.charAt(a)&&0==this.signum()&&(i=!0):(s=e*s+c,++o>=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&Q.ZERO.subTo(this,this)}fromNumber(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(Q.ONE.shiftLeft(t-1),q,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(Q.ONE.shiftLeft(t-1),this);else{var n=[],i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(t,e,r){var n,i,o=Math.min(t.t,this.t);for(n=0;n<o;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(i=t.s&this.DM,n=o;n<this.t;++n)r[n]=e(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=o;n<t.t;++n)r[n]=e(i,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}changeBit(t,e){var r=Q.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}addTo(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()}dMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}multiplyLowerTo(t,e,r){var n=Math.min(this.t+t.t,e);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,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()}multiplyUpperTo(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)}modInt(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r}millerRabin(t){var e=this.subtract(Q.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>v.length&&(t=v.length);for(var i=Z(),o=0;o<t;++o){i.fromInt(v[Math.floor(Math.random()*v.length)]);var s=i.modPow(n,this);if(0!=s.compareTo(Q.ONE)&&0!=s.compareTo(e)){for(var a=1;a++<r&&0!=s.compareTo(e);)if(0==(s=s.modPowInt(2,this)).compareTo(Q.ONE))return!1;if(0!=s.compareTo(e))return!1}}return!0}square(){var t=Z();return this.squareTo(t),t}gcda(t,e){var r=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(r.compareTo(n)<0){var i=r;r=n,n=i}var o=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)e(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(){e(n)}),0))};setTimeout(a,10)}}fromNumberAsync(t,e,r,n){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(Q.ONE.shiftLeft(t-1),q,this),this.isEven()&&this.dAddOffset(1,0);var i=this,o=function(){i.dAddOffset(2,0),i.bitLength()>t&&i.subTo(Q.ONE.shiftLeft(t-1),i),i.isProbablePrime(e)?setTimeout((function(){n()}),0):setTimeout(o,0)};setTimeout(o,0)}else{var s=[],a=7&t;s.length=1+(t>>3),e.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var m=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),_=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),I=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=Z();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(Q.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=Z();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),b=function(){function t(t){this.m=t,this.r2=Z(),this.q3=Z(),Q.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=Z();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function Z(){return new Q(null)}function J(t,e){return new Q(t,e)}function X(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i}function tt(t,e,r,n,i,o){for(var s=32767&e,a=e>>15;--o>=0;){var c=32767&this[t],u=this[t++]>>15,h=a*c+u*s;i=((c=s*c+((32767&h)<<15)+r[n]+(1073741823&i))>>>30)+(h>>>15)+a*u+(i>>>30),r[n++]=1073741823&c}return i}function et(t,e,r,n,i,o){for(var s=16383&e,a=e>>14;--o>=0;){var c=16383&this[t],u=this[t++]>>14,h=a*c+u*s;i=((c=s*c+((16383&h)<<14)+r[n]+i)>>28)+(h>>14)+a*u,r[n++]=268435455&c}return i}void 0!==x&&"Microsoft Internet Explorer"==x?.appName?(Q.prototype.am=tt,d=30):"Netscape"!=x?.appName?(Q.prototype.am=X,d=26):(Q.prototype.am=et,d=28),Q.prototype.DB=d,Q.prototype.DM=(1<<d)-1,Q.prototype.DV=1<<d,Q.prototype.FV=Math.pow(2,52),Q.prototype.F1=52-d,Q.prototype.F2=2*d-52;var w,S,E=[];for(w="0".charCodeAt(0),S=0;S<=9;++S)E[w++]=S;for(w="a".charCodeAt(0),S=10;S<36;++S)E[w++]=S;for(w="A".charCodeAt(0),S=10;S<36;++S)E[w++]=S;function rt(t,e){var r=E[t.charCodeAt(e)];return null==r?-1:r}function nt(t){var e=Z();return e.fromInt(t),e}function it(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}Q.ZERO=nt(0),Q.ONE=nt(1);class ot{constructor(){this.i=0,this.j=0,this.S=[]}init(t){var e,r,n;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,n=this.S[e],this.S[e]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}}var T,R,O=256,A=null;if(null==A){A=[],R=0;var P=void 0;if(window?.crypto&&window?.crypto.getRandomValues){var C=new Uint32Array(256);for(window?.crypto.getRandomValues(C),P=0;P<C.length;++P)A[R++]=255&C[P]}var U=function(t){if(this.count=this.count||0,this.count>=256||R>=O)window?.removeEventListener?window?.removeEventListener("mousemove",U,!1):window?.detachEvent&&window?.detachEvent("onmousemove",U);else try{var e=t.x+t.y;A[R++]=255&e,this.count+=1}catch(t){}};window?.addEventListener?window?.addEventListener("mousemove",U,!1):window?.attachEvent&&window?.attachEvent("onmousemove",U)}function st(){if(null==T){for(T=new ot;R<O;){var t=Math.floor(65536*Math.random());A[R++]=255&t}for(T.init(A),R=0;R<A.length;++R)A[R]=0;R=0}return T.next()}class at{constructor(){}nextBytes(t){for(var e=0;e<t.length;++e)t[e]=st()}}function ct(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=t.length-1;n>=0&&e>0;){var i=t.charCodeAt(n--);i<128?r[--e]=i:i>127&&i<2048?(r[--e]=63&i|128,r[--e]=i>>6|192):(r[--e]=63&i|128,r[--e]=i>>6&63|128,r[--e]=i>>12|224)}r[--e]=0;for(var o=new at,s=[];e>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);r[--e]=s[0]}return r[--e]=2,r[--e]=0,new Q(r)}class ut{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(t){return t.modPowInt(this.e,this.n)}doPrivate(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=J(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}encrypt(t){var e=ct(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var n=r.toString(16);return 0==(1&n.length)?n:"0"+n}encryptLong(t){var e=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return t.length>r?(t.match(/.{1,117}/g).forEach((function(t){var r=e.encrypt(t);n+=r})),H(n)):H(this.encrypt(t))}catch(t){return!1}}decryptLong(t){var e=this,r=this.n.bitLength()+7>>3;t=W(t);try{if(t.length>r){var n="";return t.match(/.{1,256}/g).forEach((function(t){var r=e.decrypt(t);n+=r})),n}return this.decrypt(t)}catch(t){return!1}}setPrivate(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=J(t,16),this.e=parseInt(e,16),this.d=J(r,16)):console.error("Invalid RSA private key")}setPrivateEx(t,e,r,n,i,o,s,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=J(t,16),this.e=parseInt(e,16),this.d=J(r,16),this.p=J(n,16),this.q=J(i,16),this.dmp1=J(o,16),this.dmq1=J(s,16),this.coeff=J(a,16)):console.error("Invalid RSA private key")}generate(t,e){var r=new at,n=t>>1;this.e=parseInt(e,16);for(var i=new Q(e,16);;){for(;this.p=new Q(t-n,1,r),0!=this.p.subtract(Q.ONE).gcd(i).compareTo(Q.ONE)||!this.p.isProbablePrime(10););for(;this.q=new Q(n,1,r),0!=this.q.subtract(Q.ONE).gcd(i).compareTo(Q.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(Q.ONE),a=this.q.subtract(Q.ONE),c=s.multiply(a);if(0==c.gcd(i).compareTo(Q.ONE)){this.n=this.p.multiply(this.q),this.d=i.modInverse(c),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(t){var e=J(t,16),r=this.doPrivate(e);return null==r?null:ht(r,this.n.bitLength()+7>>3)}generateAsync(t,e,r){var n=new at,i=t>>1;this.e=parseInt(e,16);var o=new Q(e,16),s=this,a=()=>{var e=()=>{if(s.p.compareTo(s.q)<=0){var t=s.p;s.p=s.q,s.q=t}var e=s.p.subtract(Q.ONE),n=s.q.subtract(Q.ONE),i=e.multiply(n);0==i.gcd(o).compareTo(Q.ONE)?(s.n=s.p.multiply(s.q),s.d=o.modInverse(i),s.dmp1=s.d.mod(e),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},c=()=>{s.q=Z(),s.q.fromNumberAsync(i,1,n,(function(){s.q.subtract(Q.ONE).gcda(o,(function(t){0==t.compareTo(Q.ONE)&&s.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(c,0)}))}))},u=()=>{s.p=Z(),s.p.fromNumberAsync(t-i,1,n,(function(){s.p.subtract(Q.ONE).gcda(o,(function(t){0==t.compareTo(Q.ONE)&&s.p.isProbablePrime(10)?setTimeout(c,0):setTimeout(u,0)}))}))};setTimeout(u,0)};setTimeout(a,0)}}function ht(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-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 lt extends ut{constructor(t=""){t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))}parseKey(t){try{var e=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?u.decode(t):h.unarmor(t),i=Y.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=J(e,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var o=i.sub[3].getHexStringValue();this.d=J(o,16);var s=i.sub[4].getHexStringValue();this.p=J(s,16);var a=i.sub[5].getHexStringValue();this.q=J(a,16);var c=i.sub[6].getHexStringValue();this.dmp1=J(c,16);var l=i.sub[7].getHexStringValue();this.dmq1=J(l,16);var d=i.sub[8].getHexStringValue();this.coeff=J(d,16)}else{if(2!==i.sub.length)return!1;var f=i.sub[1].sub[0];e=f.sub[0].getHexStringValue(),this.n=J(e,16),r=f.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}}hasPublicKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")}hasPrivateKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")}parsePropertiesFrom(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)}}n=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null},n.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new lt(t)},n.prototype.setPrivateKey=function(t){this.setKey(t)},n.prototype.setPublicKey=function(t){this.setKey(t)},n.prototype.decrypt=function(t){try{return this.getKey().decrypt(W(t))}catch(t){return!1}},n.prototype.encrypt=function(t){try{return H(this.getKey().encrypt(t))}catch(t){return!1}},n.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",n=0,i=/null$/g;i.test(r)&&(n++,e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",!(n>10)););return e}catch(t){return!1}},n.prototype.getKey=function(t){if(!this.key){if(this.key=new lt,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}const N=n;var L=r(479);const D=({publicKey:t="",payload:e={}}={})=>{if(!t)return"";try{const r=(0,L.I)(e),n=new N({});return n.setPublicKey(t),n.encryptLong("object"==typeof r?JSON.stringify(r):r)}catch(t){}return""}},479:(t,e,r)=>{r.d(e,{I:()=>n,y:()=>i});const n=t=>{const e=e=>{for(const r in t)t.hasOwnProperty(r)&&(e[r]=n(t[r]));return e},r=null==t?"NullOrUndefined":Object.prototype.toString.call(t).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return t.slice();switch(r){case"Object":return e(Object.create(Object.getPrototypeOf(t)));case"Array":return e([]);case"Date":return new Date(t.valueOf());case"RegExp":return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""));default:return t}},i=t=>{const e=t.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return e&&e[2]||""}},105:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&n(e,t,r);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var s,a=o(r(587)),c=r(894);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(s=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t){for(var e=0,r=(0,c.isArray)(t)?t:[t];e<r.length;e++){var n=r[e],i=n.isMatch,o=n.genAdapter,s=n.runtime;if(i())return{adapter:o(),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:a.genAdapter(),runtime:s.WEB}}},587:function(t,e,r){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){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(c){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=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var c=r(997),u=r(894),h=r(652),l=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,i=e.timeoutMsg,o=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=i||"请求超时",r.restrictedMethods=o||["get","post","upload","download"],r}return i(e,t),e.prototype.get=function(t){return this.request(o(o({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(o(o({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(o(o({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,i=t.method,s=t.headers,a=void 0===s?{}:s,c={post:"post",put:"put"}[null==i?void 0:i.toLowerCase()]||"put",u=new FormData;return"post"===c?(Object.keys(e).forEach((function(t){u.append(t,e[t])})),u.append("key",n),u.append("file",r),this.request(o(o({},t),{data:u,method:c}),this.restrictedMethods.includes("upload"))):this.request(o(o({},t),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,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({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.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(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(i){var o,s,a=t.url,c=t.headers,l=void 0===c?{}:c,d=t.data,f=t.responseType,p=t.withCredentials,g=t.body,v=t.onUploadProgress,y=(0,u.formatUrl)((0,h.getProtocol)(),a,"get"===n?d:{}),m=new XMLHttpRequest;m.open(n,y),f&&(m.responseType=f),Object.keys(l).forEach((function(t){m.setRequestHeader(t,l[t])})),v&&m.upload.addEventListener("progress",v),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),i=e.join(": ");r[n]=i})),t.header=r,t.statusCode=m.status;try{t.data="blob"===f?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===f?m.response:m.responseText}clearTimeout(o),i(t)}},e&&r.timeout&&(o=setTimeout((function(){console.warn(r.timeoutMsg),m.abort()}),r.timeout)),s=(0,u.isFormData)(d)?d:"application/x-www-form-urlencoded"===l["content-type"]?(0,u.toQueryString)(d):g||(d?JSON.stringify(d):void 0),p&&(m.withCredentials=!0),m.send(s)}))},e}(c.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{root:window,reqClass:l,wsClass:WebSocket,localStorage}}},652:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var n="https:";e.setProtocol=function(t){n=t},e.getProtocol=function(){return n},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},151:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},141:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,i(r(652),e),i(r(151),e),e.OATUH_LOGINTYPE="constants"},64:function(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){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(c){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=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var o=r(894),s=r(141),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var c=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function h(t){var e=t.err,r=t.className,n=t.methodName,i=t.sourceLink;if(!i)return null;var o,s=e.stack.split("\n"),c=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(t){return c.test(t)}));if(-1!==l){var d=s.filter((function(t,e){return e>l}));d.unshift(s[l].replace(h,"".concat(r,".").concat(n)).replace(u,i)),(o=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return o}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,a=t.customInfo,l=void 0===a?{}:a,d=t.title,f=t.messages,p=void 0===f?[]:f;return function(t,e,a){if(s.IS_DEBUG_MODE){var f=l.className||t.constructor.name,g=l.methodName||e,v=a.value,y=function(t){var e="",r=(new Error).stack.split("\n"),n=r.findIndex((function(t){return c.test(t)}));if(-1!==n){var i=u.exec(r[n+1]||"");e=i?i[0]:""}return e}();a.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=h({err:new Error,className:f,methodName:g,sourceLink:y});try{return v.apply(this,t)}catch(t){var n=t,i=t.message,s=t.error,a=t.error_description,c={title:d||"".concat(f,".").concat(g," failed"),content:[{type:"error",body:t}]};if(i&&/^\{.*\}$/.test(i)){var u=JSON.parse(i);c.subtitle=i,u.code&&(r?(r.code=u.code,r.msg=u.msg):(t.code=u.code,t.message=u.msg),n=r||t,c.content=p.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(c.subtitle=a,r?(r.code=s,r.msg=a):(t.code=s,t.message=a),n=r||t,c.content=p.map((function(t){return{type:"info",body:t}}))),(0,o.printGroupLog)(c),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this,void 0,void 0,(function(){var e,r,n,s,a,c,u,l;return i(this,(function(i){switch(i.label){case 0:e=h({err:new Error,className:f,methodName:g,sourceLink:y}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,v.apply(this,t)];case 2:return[2,i.sent()];case 3:throw r=i.sent(),n=r,s=r.message,a=r.error,c=r.error_description,u={title:d||"".concat(f,".").concat(g," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),u.subtitle=l,l.code&&(e?(e.code=l.code,e.message=l.msg):(r.code=l.code,r.message=l.msg),n=e||r,u.content=p.map((function(t){return{type:"info",body:t}})))),a&&c&&(u.subtitle=c,e?(e.code=a,e.msg=c):(r.code=a,r.message=c),n=e||r,u.content=p.map((function(t){return{type:"info",body:t}}))),(0,o.printGroupLog)(u),n;case 4:return[2]}}))}))}}}}},466:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(64),e)},418:function(t,e,r){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){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(c){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=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=r(997),c=r(894),u=r(141),h=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return i(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(a.AbstractStorage),l=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,i=t.keys,o=void 0===i?{}:i;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(e.root));case"none":return new h(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=o)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,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:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return i.sent(),[3,4];case 3:return i.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){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=process.env)||void 0===r?void 0:r.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=i.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return o(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}();e.CloudbaseCache=l},988:function(t,e,r){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=r(894),a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var c=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return i(e,t),e}(a);e.IErrorEvent=c;var u=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,c))return console.error(t.error),this;var r=(0,s.isString)(t)?new a(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var i=0,u=this.listeners[n]?o([],this.listeners[n],!0):[];i<u.length;i++)u[i].call(this,r)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=u;var h=new u;e.addEventListener=function(t,e){h.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),h.fire(t,e)},e.removeEventListener=function(t,e){h.off(t,e)}},894:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.formatUrl=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var n=r(141);e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.formatUrl=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),i="";return Object.keys(r).forEach((function(t){""===i?!n&&(e+="?"):i+="&",i+="".concat(t,"=").concat(encodeURIComponent(r[t]))})),/^http(s)?:\/\//.test(e+=i)?e:"".concat(t).concat(e)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var r=e||window.location.search,n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),i=r.substr(r.indexOf("?")+1).match(n);return null!=i?i[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""},e.removeParam=function(t,e){var r=e.split("?")[0],n=[],i=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==i){for(var o=(n=i.split("&")).length-1;o>=0;o-=1)n[o].split("=")[0]===t&&n.splice(o,1);r="".concat(r,"?").concat(n.join("&"))}return r},e.createPromiseCallback=function(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,t},e.execCallback=function(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r},e.printWarn=function(t,e){console.warn("[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e=t.title,r=t.subtitle,n=void 0===r?"":r,i=t.content,o=void 0===i?[]:i,s=t.printTrace,a=void 0!==s&&s,c=t.collapsed;void 0!==c&&c?console.groupCollapsed(e,n):console.group(e,n);for(var u=0,h=o;u<h.length;u++){var l=h[u],d=l.type,f=l.body;switch(d){case"info":console.log(f);break;case"warn":console.warn(f);break;case"error":console.error(f)}}a&&console.trace("stack trace:"),console.groupEnd()},e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86".concat(t)}}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{var t=n;Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=void 0;var e=r(922);t.registerAuth=e.registerAuth})(),n})()));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_auth",[],e):"object"==typeof exports?exports.cloudbase_auth=e():t.cloudbase_auth=e()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var t={997:(t,e,r)=>{var n;r.r(e),r.d(e,{AbstractSDKRequest:()=>i,AbstractStorage:()=>o,StorageType:()=>n,formatUrl:()=>s}),function(t){t.local="local",t.none="none",t.session="session"}(n||(n={}));var i=function(){},o=function(){};function s(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),i="";for(var o in r)""===i?!n&&(e+="?"):i+="&",i+=o+"="+encodeURIComponent(r[o]);return/^http(s)?\:\/\//.test(e+=i)?e:""+t+e}},922:(t,e,r)=>{var n,i,o,s,a,c;function u(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}r.r(e),r.d(e,{Auth:()=>ot,LoginState:()=>it,generateAuthInstance:()=>st,registerAuth:()=>ct}),function(t){t.AUTH_SIGN_IN_URL="/auth/v1/signin",t.AUTH_SIGN_IN_ANONYMOUSLY_URL="/auth/v1/signin/anonymously",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v1/signin/with/provider",t.AUTH_SIGN_IN_WITH_WECHAT_URL="/auth/v1/signin/wechat/noauth",t.AUTH_SIGN_UP_URL="/auth/v1/signup",t.AUTH_TOKEN_URL="/auth/v1/token",t.AUTH_REVOKE_URL="/auth/v1/revoke",t.PROVIDER_BIND_URL="/auth/v1/user/provider/bind",t.PROVIDER_TOKEN_URL="/auth/v1/provider/token",t.PROVIDER_URI_URL="/auth/v1/provider/uri",t.USER_ME_URL="/auth/v1/user/me",t.WEDA_USER_URL="/auth/v1/plugin/weda/userinfo",t.USER_QUERY_URL="/auth/v1/user/query",t.USER_PRIFILE_URL="/auth/v1/user/profile",t.USER_BASIC_EDIT_URL="/auth/v1/user/basic/edit",t.USER_TRANS_BY_PROVIDER_URL="/auth/v1/user/trans/by/provider",t.VERIFICATION_URL="/auth/v1/verification",t.VERIFY_URL="/auth/v1/verification/verify",t.CAPTCHA_DATA_URL="/auth/v1/captcha/data",t.VERIFY_CAPTCHA_DATA_URL="/auth/v1/captcha/data/verify",t.GET_CAPTCHA_URL="/auth/v1/captcha/init",t.PROVIDER_LIST="/auth/v1/user/provider",t.PROVIDER_UNBIND_URL="/auth/v1/user/provider",t.CHECK_PWD_URL="/auth/v1/user/sudo",t.SUDO_URL="/auth/v1/user/sudo",t.BIND_CONTACT_URL="/auth/v1/user/contact",t.AUTH_SET_PASSWORD="/auth/v1/user/password",t.AUTH_RESET_PASSWORD="/auth/v1/reset",t.AUTH_GET_DEVICE_CODE="/auth/v1/device/code",t.CHECK_USERNAME="/auth/v1/checkUsername",t.CHECK_IF_USER_EXIST="/auth/v1/checkIfUserExist",t.AUTHORIZE_URL="/auth/v1/user/authorize",t.AUTHORIZE_DEVICE_URL="/auth/v1/user/device/authorize",t.AUTHORIZE_INFO_URL="/auth/v1/user/authorize/info",t.AUTHORIZED_DEVICES_DELETE_URL="/auth/v1/user/authorized/devices/",t.AUTH_REVOKE_ALL_URL="/auth/v1/user/revoke/all",t.GET_PROVIDER_TYPE="/auth/v1/mgr/provider/providerSubType",t.GET_MINIPROGRAM_QRCODE="/auth/v1/qrcode/generate",t.GET_MINIPROGRAM_QRCODE_STATUS="/auth/v1/qrcode/get/status",t.GET_USER_BEHAVIOR_LOG="/auth/v1/user/security/history"}(n||(n={})),function(t){t.AUTH_SIGN_IN_URL="/auth/v2/signin/username",t.AUTH_TOKEN_URL="/auth/v2/token",t.USER_ME_URL="/auth/v2/user/me",t.VERIFY_URL="/auth/v2/signin/verificationcode",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v2/signin/with/provider",t.AUTH_PUBLIC_KEY="/auth/v2/signin/publichkey"}(i||(i={})),function(t){t.REGISTER="REGISTER",t.SIGN_IN="SIGN_IN",t.PASSWORD_RESET="PASSWORD_RESET",t.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",t.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(o||(o={})),(c=s||(s={})).UNREACHABLE="unreachable",c.LOCAL="local",c.CANCELLED="cancelled",c.UNKNOWN="unknown",c.UNAUTHENTICATED="unauthenticated",c.RESOURCE_EXHAUSTED="resource_exhausted",c.FAILED_PRECONDITION="failed_precondition",c.INVALID_ARGUMENT="invalid_argument",c.DEADLINE_EXCEEDED="deadline_exceeded",c.NOT_FOUND="not_found",c.ALREADY_EXISTS="already_exists",c.PERMISSION_DENIED="permission_denied",c.ABORTED="aborted",c.OUT_OF_RANGE="out_of_range",c.UNIMPLEMENTED="unimplemented",c.INTERNAL="internal",c.UNAVAILABLE="unavailable",c.DATA_LOSS="data_loss",c.INVALID_PASSWORD="invalid_password",c.PASSWORD_NOT_SET="password_not_set",c.INVALID_STATUS="invalid_status",c.USER_PENDING="user_pending",c.USER_BLOCKED="user_blocked",c.INVALID_VERIFICATION_CODE="invalid_verification_code",c.TWO_FACTOR_REQUIRED="two_factor_required",c.INVALID_TWO_FACTOR="invalid_two_factor",c.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",c.UNDER_REVIEW="under_review",c.INVALID_REQUEST="invalid_request",c.UNAUTHORIZED_CLIENT="unauthorized_client",c.ACCESS_DENIED="access_denied",c.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",c.INVALID_SCOPE="invalid_scope",c.INVALID_GRANT="invalid_grant",c.SERVER_ERROR="server_error",c.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",c.INTERACTION_REQUIRED="interaction_required",c.LOGIN_REQUIRED="login_required",c.ACCOUNT_SELECTION_REQUIRED="account_selection_required",c.CONSENT_REQUIRED="consent_required",c.INVALID_REQUEST_URI="invalid_request_uri",c.INVALID_REQUEST_OBJECT="invalid_request_object",c.REQUEST_NOT_SUPPORTED="request_not_supported",c.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",c.REGISTRATION_NOT_SUPPORTED="registration_not_supported",c.CAPTCHA_REQUIRED="captcha_required",c.CAPTCHA_INVALID="captcha_invalid",function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(a||(a={}));var h=r(479);class l{constructor(){this.fnPromiseMap=new Map}async run(t,e){let r=this.fnPromiseMap.get(t);return await r||(r=new Promise(((r,n)=>{(async()=>{try{await this.runIdlePromise();const t=e();r(await t)}catch(t){n(t)}finally{this.fnPromiseMap.delete(t)}})()})),this.fnPromiseMap.set(t,r)),r}runIdlePromise(){return Promise.resolve()}}const d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f="x-request-id",p="x-device-id",g="device_id",v=async function(t,e){let r=null,n=null;try{const i=Object.assign({},e);i.method||(i.method="GET"),i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body));const o=await fetch(t,i),s=await o.json();s?.error?(n=s,n.error_uri=new URL(t).pathname):r=s}catch(e){n={error:s.UNREACHABLE,error_description:e.message,error_uri:new URL(t).pathname}}if(n)throw n;return r},y=new class{constructor(t){this._env=t?.env||""}async getItem(t){return window.localStorage.getItem(`${t}${this._env}`)}async removeItem(t){window.localStorage.removeItem(`${t}${this._env}`)}async setItem(t,e){window.localStorage.setItem(`${t}${this._env}`,e)}getItemSync(t){return window.localStorage.getItem(`${t}${this._env}`)}removeItemSync(t){window.localStorage.removeItem(`${t}${this._env}`)}setItemSync(t,e){window.localStorage.setItem(`${t}${this._env}`,e)}};function m(t){let e=!0;return t?.expires_at&&t?.access_token&&(e=t.expires_at<new Date),e}class _{constructor(t){this.credentials=null,this.singlePromise=new l,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage}getStorageCredentialsSync(){let t=null;const e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{t=JSON.parse(e),t?.expires_at&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t}async setCredentials(t){if(t?.expires_in){if(t?.expires_at||(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30))),this.storage){const e=JSON.stringify(t);await this.storage.setItem(this.tokenSectionName,e)}this.credentials=t}else this.storage&&await this.storage.removeItem(this.tokenSectionName),this.credentials=null}async getCredentials(){return this.singlePromise.run("getCredentials",(async()=>(m(this.credentials)&&(this.credentials=await this.getStorageCredentials()),this.credentials)))}async getStorageCredentials(){return this.singlePromise.run("_getStorageCredentials",(async()=>{let t=null;const e=await this.storage.getItem(this.tokenSectionName);if(null!=e)try{t=JSON.parse(e),t?.expires_at&&(t.expires_at=new Date(t.expires_at))}catch(e){await this.storage.removeItem(this.tokenSectionName),t=null}return t}))}}class I{constructor(t){this.singlePromise=new l,this.apiOrigin=t.apiOrigin,this.clientId=t.clientId,this.retry=this.formatRetry(t.retry,I.defaultRetry),t.baseRequest?this.baseRequest=t.baseRequest:this.baseRequest=v,this.tokenInURL=t.tokenInURL,this.headers=t.headers,this.storage=t.storage||y,this.localCredentials=new _({tokenSectionName:`credentials_${t.clientId}`,storage:this.storage}),this.clientSecret=t.clientSecret,""!==t.clientId&&(this.basicAuth=`Basic ${function(t){let e,r,n,i,o="",s=0;const a=(t=String(t)).length%3;for(;s<t.length;){if((r=t.charCodeAt(s++))>255||(n=t.charCodeAt(s++))>255||(i=t.charCodeAt(s++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");e=r<<16|n<<8|i,o+=d.charAt(e>>18&63)+d.charAt(e>>12&63)+d.charAt(e>>6&63)+d.charAt(63&e)}return a?o.slice(0,a-3)+"===".substring(a):o}(`${t.clientId}:${t.clientSecret}`)}`),this.wxCloud=t.wxCloud;try{(function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0})()&&void 0===this.wxCloud&&t.env&&(wx.cloud.init({env:t.env}),this.wxCloud=wx.cloud)}catch(t){}this.refreshTokenFunc=t.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=t.anonymousSignInFunc}setCredentials(t){return this.localCredentials.setCredentials(t)}async getAccessToken(){const t=await this.getCredentials();if(t?.access_token)return Promise.resolve(t.access_token);const e={error:s.UNAUTHENTICATED};return Promise.reject(e)}async request(t,e){e||(e={});const r=this.formatRetry(e.retry,this.retry);if(e.headers=e.headers||{},this.headers&&(e.headers={...this.headers,...e.headers}),e.headers[f]||(e.headers[f]=u()),!e.headers[p]){const t=await this.getDeviceId();e.headers[p]=t}if(e?.withBasicAuth&&this.basicAuth&&(e.headers.Authorization=this.basicAuth),e?.withCredentials){const r=await this.getCredentials();r&&(this.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+=`access_token=${r.access_token}`):e.headers.Authorization=`${r.token_type} ${r.access_token}`)}else this.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+=`client_id=${this.clientId}`);t.startsWith("/")&&(t=this.apiOrigin+t);let n=null;const i=r+1;for(let o=0;o<i;o++){try{n=e.useWxCloud?await this.wxCloudCallFunction(t,e):await this.baseRequest(t,e);break}catch(t){if(e.withCredentials&&t&&t.error===s.UNAUTHENTICATED)return await this.setCredentials(null),Promise.reject(t);if(o===r||!t||"unreachable"!==t.error)return Promise.reject(t)}await this.sleep(I.retryInterval)}return n}async wxCloudCallFunction(t,e){let r=null,n=null;try{const{result:i}=await this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:t,method:e.method,headers:{origin:"https://servicewechat.com",...e.headers},body:e.body}});i?.body?.error_code?(n=i?.body,n.error_uri=(0,h.y)(t)):r=i?.body}catch(e){n={error:s.UNREACHABLE,error_description:e.message,error_uri:(0,h.y)(t)}}if(n)throw n;return r}async getCredentials(){let t=await this.localCredentials.getCredentials();return t?(m(t)&&(t=t&&"anonymous"===t.scope?this.anonymousSignInFunc?await this.anonymousSignInFunc(t)||await this.localCredentials.getCredentials():await this.anonymousSignIn(t):await this.refreshToken(t)),t):this.unAuthenticatedError("credentials not found")}getCredentialsSync(){return this.localCredentials.getStorageCredentialsSync()}getCredentialsAsync(){return this.getCredentials()}async getScope(){const t=await this.localCredentials.getCredentials();return t?t.scope:this.unAuthenticatedError("credentials not found")}async getGroups(){const t=await this.localCredentials.getCredentials();return t?t.groups:this.unAuthenticatedError("credentials not found")}async refreshToken(t){return this.singlePromise.run("_refreshToken",(async()=>{if(!t||!t.refresh_token)return this.unAuthenticatedError("no refresh token found in credentials");try{const e=await this.refreshTokenFunc(t.refresh_token,t);return await this.localCredentials.setCredentials(e),e}catch(t){return t.error===s.INVALID_GRANT?(await this.localCredentials.setCredentials(null),this.unAuthenticatedError(t.error_description)):Promise.reject(t)}}))}checkRetry(t){let e=null;if(("number"!=typeof t||t<I.minRetry||t>I.maxRetry)&&(e={error:s.UNREACHABLE,error_description:"wrong options param: retry"}),e)throw e;return t}formatRetry(t,e){return void 0===t?e:this.checkRetry(t)}async sleep(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}async anonymousSignIn(t){return this.singlePromise.run("_anonymous",(async()=>{if(!t||"anonymous"!==t.scope)return this.unAuthenticatedError("no anonymous in credentials");try{const t=await this.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}});return await this.localCredentials.setCredentials(t),t}catch(t){return t.error===s.INVALID_GRANT?(await this.localCredentials.setCredentials(null),this.unAuthenticatedError(t.error_description)):Promise.reject(t)}}))}async defaultRefreshTokenFunc(t,e){if(void 0===t||""===t)return this.unAuthenticatedError("refresh token not found");let r=n.AUTH_TOKEN_URL;return"v2"===e?.version&&(r=i.AUTH_TOKEN_URL),{...await this.request(r,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}}),version:e?.version||"v1"}}async getDeviceId(){if(this.deviceID)return this.deviceID;let t=await this.storage.getItem(g);return"string"==typeof t&&t.length>=16&&t.length<=48||(t=u(),await this.storage.setItem(g,t)),this.deviceID=t,t}unAuthenticatedError(t){const e={error:s.UNAUTHENTICATED,error_description:t};return Promise.reject(e)}}function b(){const{wx:t}=globalThis;if(void 0===t)return!1;if(void 0===globalThis.Page)return!1;if(!t.getSystemInfoSync)return!1;if(!t.getStorageSync)return!1;if(!t.setStorageSync)return!1;if(!t.connectSocket)return!1;if(!t.request)return!1;try{if(!t.getSystemInfoSync())return!1;if("qq"===t.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0}I.defaultRetry=2,I.minRetry=0,I.maxRetry=5,I.retryInterval=1e3;let w=!1;function S(){w=w||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{b()||(w=w||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?S():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",S,!1))}catch(t){}function E(){return w}class T{constructor(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=y),this.config=t,this.tokenSectionName=`captcha_${t.clientId}`}async request(t,e){e||(e={}),e.method||(e.method="GET");const r=`${e.method}:${t}`;let n,i=t;e.withCaptcha&&(i=await this.appendCaptchaTokenToURL(t,r,!1));try{n=await this.config.request(i,e)}catch(n){return n.error===s.CAPTCHA_REQUIRED||n.error===s.CAPTCHA_INVALID?(t=await this.appendCaptchaTokenToURL(t,r,n.error===s.CAPTCHA_INVALID),this.config.request(t,e)):Promise.reject(n)}return n}getDefaultOpenURIWithCallback(){if(!b()&&!E()&&(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap"))){const t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((()=>{document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback}async defaultOpenURIWithCallback(t,e){const{width:r="355px",height:n="355px"}=e||{};if(t.match(/^(data:.*)$/))return Promise.reject({error:s.UNIMPLEMENTED,error_description:"need to impl captcha data"});const i=document.getElementById("captcha_panel_wrap"),o=document.createElement("iframe");return i.innerHTML="",o.setAttribute("src",t),o.setAttribute("id","review-panel-iframe"),o.style.cssText=`min-width:${r};display:block;height:${n};margin:0 auto;background-color: rgb(255, 255, 255);border: none;`,i.appendChild(o),i.style.display="block",new Promise(((t,e)=>{o.onload=function(){try{const r=window.location,n=o.contentWindow.location;if(n.host+n.pathname===r.host+r.pathname){i.style.display="none";const r=new URLSearchParams(n.search),o=r.get("captcha_token");return o?t({captcha_token:o,expires_in:Number(r.get("expires_in"))}):e({error:r.get("error"),error_description:r.get("error_description")})}i.style.display="block"}catch(t){i.style.display="block"}}}))}async getCaptchaToken(t,e){if(!t){const t=await this.findCaptchaToken();if(t)return t}let r;if(b()||E()){const t=await this.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:""},withCredentials:!1});r={url:`${t.data}?state=${encodeURIComponent(e)}&token=${encodeURIComponent(t.token)}`}}else{const t=`${window.location.origin+window.location.pathname}?__captcha=on`;if(r=await this.config.request(n.GET_CAPTCHA_URL,{method:"POST",body:{client_id:this.config.clientId,redirect_uri:t,state:e},withCredentials:!1}),r.captcha_token){const t={captcha_token:r.captcha_token,expires_in:r.expires_in};return this.saveCaptchaToken(t),r.captcha_token}}const i=await this.config.openURIWithCallback(r.url);return this.saveCaptchaToken(i),i.captcha_token}async appendCaptchaTokenToURL(t,e,r){const n=await this.getCaptchaToken(r,e);return t.indexOf("?")>0?t+=`&captcha_token=${n}`:t+=`?captcha_token=${n}`,t}async saveCaptchaToken(t){t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10));const e=JSON.stringify(t);await this.config.storage.setItem(this.tokenSectionName,e)}async findCaptchaToken(){const t=await this.config.storage.getItem(this.tokenSectionName);if(null!=t)try{const e=JSON.parse(t);return e?.expires_at&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?null:e.captcha_token}catch(t){return await this.config.storage.removeItem(this.tokenSectionName),null}return null}}function R(t){if(!globalThis.IS_MP_BUILD&&t)return r(443)}class O{static parseParamsToSearch(t){return Object.keys(t).forEach((e=>{t[e]||delete t[e]})),new URLSearchParams(t).toString()}constructor(t){let{request:e}=t,r=t.credentialsClient;if(!r){const e={apiOrigin:t.apiOrigin,clientId:t.clientId,storage:t.storage,env:t.env,baseRequest:t.baseRequest,anonymousSignInFunc:t.anonymousSignInFunc,wxCloud:t.wxCloud};r=new I(e)}if(!e){const n=r.request.bind(r),i=new T({clientId:t.clientId,request:n,storage:t.storage,...t.captchaOptions});e=i.request.bind(i)}this.config={env:t.env,apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:r,storage:t.storage||y}}getParamsByVersion(t,e){const r=(0,h.I)(t),o={v2:i}[r?.version]?.[e]||n[e];return r&&delete r.version,{params:r,url:o}}async signIn(t){const e=t.version||"v1",r=this.getParamsByVersion(t,"AUTH_SIGN_IN_URL");r.params.query&&delete r.params.query;const n=await this.getEncryptParams(r.params),i=await this.config.request(r.url,{method:"POST",body:n});return await this.config.credentialsClient.setCredentials({...i,version:e}),Promise.resolve(i)}async signInAnonymously(t={}){const e=await this.config.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t});return await this.config.credentialsClient.setCredentials(e),Promise.resolve(e)}async signUp(t){const e=await this.config.request(n.AUTH_SIGN_UP_URL,{method:"POST",body:t});return await this.config.credentialsClient.setCredentials(e),Promise.resolve(e)}async signOut(){const t=await this.config.credentialsClient.getAccessToken(),e=await this.config.request(n.AUTH_REVOKE_URL,{method:"POST",body:{token:t}});return await this.config.credentialsClient.setCredentials(),Promise.resolve(e)}async revokeAllDevices(){await this.config.request(n.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})}async revokeDevice(t){await this.config.request(n.AUTHORIZED_DEVICES_DELETE_URL+t.device_id,{method:"DELETE",withCredentials:!0})}async getVerification(t){let e=!1;return("CUR_USER"===t.target||await this.hasLoginState())&&(e=!0),this.config.request(n.VERIFICATION_URL,{method:"POST",body:t,withCredentials:e})}async verify(t){const e=this.getParamsByVersion(t,"VERIFY_URL"),r=await this.config.request(e.url,{method:"POST",body:e.params});return"v2"===t?.version&&await this.config.credentialsClient.setCredentials({...r,version:"v2"}),r}async genProviderRedirectUri(t){let e=`${n.PROVIDER_URI_URL}?client_id=${this.config.clientId}&provider_id=${t.provider_id}&redirect_uri=${encodeURIComponent(t.provider_redirect_uri)}&state=${t.state}`;const{other_params:r}=t;return r&&"string"==typeof r.sign_out_uri&&r.sign_out_uri.length>0&&(e+=`&other_params[sign_out_uri]=${r.sign_out_uri}`),this.config.request(e,{method:"GET"})}async grantProviderToken(t,e=!1){return this.config.request(n.PROVIDER_TOKEN_URL,{method:"POST",body:t,useWxCloud:e})}async patchProviderToken(t){return this.config.request(n.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})}async signInWithProvider(t,e=!1){const r=this.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),n=await this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:e});return await this.config.credentialsClient.setCredentials({...n,version:t?.version||"v1"}),Promise.resolve(n)}async signInWithWechat(t={}){const e=await this.config.request(n.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:t});return await this.config.credentialsClient.setCredentials(e),Promise.resolve(e)}async bindWithProvider(t){return this.config.request(n.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})}async getUserProfile(t){return this.getUserInfo(t)}async getUserInfo(t={}){const e=this.getParamsByVersion(t,"USER_ME_URL");if(e.params?.query){const t=new URLSearchParams(e.params.query);e.url+=`?${t.toString()}`}const r=await this.config.request(e.url,{method:"GET",withCredentials:!0});return r.sub&&(r.uid=r.sub),r}async getWedaUserInfo(){return await this.config.request(n.WEDA_USER_URL,{method:"GET",withCredentials:!0})}async deleteMe(t){const e=this.getParamsByVersion(t,"USER_ME_URL"),r=`${e.url}?${O.parseParamsToSearch(e.params)}`;return this.config.request(r,{method:"DELETE",withCredentials:!0})}async hasLoginState(){try{return await this.config.credentialsClient.getAccessToken(),!0}catch(t){return!1}}hasLoginStateSync(){return this.config.credentialsClient.getCredentialsSync()}async getLoginState(){return this.config.credentialsClient.getCredentialsAsync()}async transByProvider(t){return this.config.request(n.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})}async grantToken(t){const e=this.getParamsByVersion(t,"AUTH_TOKEN_URL");return this.config.request(e.url,{method:"POST",body:e.params})}async getProviders(){return this.config.request(n.PROVIDER_LIST,{method:"GET",withCredentials:!0})}async unbindProvider(t){return this.config.request(`${n.PROVIDER_UNBIND_URL}/${t.provider_id}`,{method:"DELETE",withCredentials:!0})}async checkPassword(t){return this.config.request(`${n.CHECK_PWD_URL}`,{method:"POST",withCredentials:!0,body:t})}async editContact(t){return this.config.request(`${n.BIND_CONTACT_URL}`,{method:"PATCH",withCredentials:!0,body:t})}async setPassword(t){return this.config.request(`${n.AUTH_SET_PASSWORD}`,{method:"PATCH",withCredentials:!0,body:t})}async updatePasswordByOld(t){const e=await this.sudo({password:t.old_password});return this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})}async sudo(t){return this.config.request(`${n.SUDO_URL}`,{method:"POST",withCredentials:!0,body:t})}async sendVerificationCodeToCurrentUser(t){return t.target="CUR_USER",this.config.request(n.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})}async changeBoundProvider(t){return this.config.request(`${n.PROVIDER_LIST}/${t.provider_id}/trans`,{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})}async setUserProfile(t){return this.config.request(n.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})}async updateUserBasicInfo(t){return this.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:t})}async queryUserProfile(t){const e=new URLSearchParams(t);return this.config.request(`${n.USER_QUERY_URL}?${e.toString()}`,{method:"GET",withCredentials:!0})}setCustomSignFunc(t){this.getCustomSignTicketFn=t}async signInWithCustomTicket(t){const e=this.getCustomSignTicketFn;if(!e)return Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"});const r=await e();return this.signInWithProvider({...t,provider_id:"custom",provider_token:r})}async resetPassword(t){return this.config.request(n.AUTH_RESET_PASSWORD,{method:"POST",body:t})}async authorize(t){return this.config.request(n.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:t})}async authorizeDevice(t){return this.config.request(n.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:t})}async deviceAuthorize(t){return this.config.request(n.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})}async authorizeInfo(t){const e=`${n.AUTHORIZE_INFO_URL}?${O.parseParamsToSearch(t)}`;let r=!0,i=!1;return await this.hasLoginState()&&(i=!0,r=!1),this.config.request(e,{method:"GET",withBasicAuth:r,withCredentials:i})}async checkUsername(t){return this.config.request(n.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})}async checkIfUserExist(t){const e=new URLSearchParams(t);return this.config.request(`${n.CHECK_IF_USER_EXIST}?${e.toString()}`,{method:"GET"})}async loginScope(){return this.config.credentialsClient.getScope()}async loginGroups(){return this.config.credentialsClient.getGroups()}async refreshTokenForce(t){const e=await this.config.credentialsClient.getCredentials();return await this.config.credentialsClient.refreshToken({...e,version:t?.version||"v1"})}async getCredentials(){return this.config.credentialsClient.getCredentials()}async getPublicKey(){return this.config.request(i.AUTH_PUBLIC_KEY,{method:"POST",body:{}})}async getEncryptParams(t){const{isEncrypt:e}=t;delete t.isEncrypt;const r=(0,h.I)(t),n=R(e);if(!n)return t;let i="",o="";try{const t=await this.getPublicKey();i=t.public_key,o=t.public_key_thumbprint}catch(t){}if(!i||!o)throw new Error("public_key or public_key_thumbprint is empty");return{params:n.getEncryptInfo({publicKey:i,payload:r}),public_key_thumbprint:o}}async getProviderSubType(){return this.config.request(n.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})}async verifyCaptchaData({token:t,key:e}){return this.config.request(n.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:e},withCredentials:!1})}async createCaptchaData({state:t,redirect_uri:e}){return this.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:e},withCredentials:!1})}async getMiniProgramCode(t){return this.config.request(n.GET_MINIPROGRAM_QRCODE,{method:"POST",body:t})}async getMiniProgramQrCodeStatus(t){return this.config.request(n.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:t})}async getUserBehaviorLog(t){const e=`${n.GET_USER_BEHAVIOR_LOG}?${{LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"}[t.type]}&limit=${t.limit}${t.page_token?`&page_token=${t.page_token}`:""}`;return this.config.request(e,{method:"GET",withCredentials:!0})}async modifyPassword(t){let e="",r="";const i=R(!0);if(!i)throw new Error("do not support encrypt, a encrypt util required.");try{const t=await this.getPublicKey();e=t.public_key,r=t.public_key_thumbprint}catch(t){}if(!e||!r)throw new Error("public_key or public_key_thumbprint is empty");const o=t.password?i.getEncryptInfo({publicKey:e,payload:t.password}):"",s=i.getEncryptInfo({publicKey:e,payload:t.new_password});return this.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:t.user_id,encrypt_password:o,encrypt_new_password:s,public_key_thumbprint:r}})}}class A{constructor(t){const{apiOrigin:e,clientId:r,env:n,storage:i,request:o,baseRequest:s,anonymousSignInFunc:a,wxCloud:c}=t;this.oauth2client=new I({apiOrigin:e,clientId:r,env:n,storage:i,baseRequest:s||o,anonymousSignInFunc:a,wxCloud:c}),this.authApi=new O({credentialsClient:this.oauth2client,...t,request:o?this.oauth2client.request.bind(this.oauth2client):void 0})}}var P,C=r(894),U=r(141),N=r(466),L=r(988),D=r(418),x=r(997),k=(P=function(t,e){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},P(t,e)},function(t,e){function r(){this.constructor=t}P(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),M=function(){return M=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},M.apply(this,arguments)},q=function(t){function e(e){void 0===e&&(e={});var r=t.call(this)||this,n=e.timeout,i=e.timeoutMsg,o=e.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=i||"请求超时",r._restrictedMethods=o||["get","post","upload","download"],r}return k(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(r,n){var i=t.url,o=t.data,s=t.headers,a=wx.request({url:(0,x.formatUrl)("https:",i),data:o,timeout:e._timeout,method:"POST",header:s,success:function(t){r(t)},fail:function(t){n(t)},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("post")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{a.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,r=this;return new Promise((function(n){return i=e,o=void 0,a=function(){var e,i,o,s,a,c;return function(t,e){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(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}(this,(function(u){return e=t.url,i=t.file,o=t.data,s=t.headers,a=t.onUploadProgress,c=wx.uploadFile({url:e,filePath:i,name:"file",formData:M({},o),header:s,timeout:this._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&o.success_action_status&&(e.statusCode=parseInt(o.success_action_status,10)),n(e)},fail:function(t){n(t)},complete:function(t){if(t&&t.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(r._timeoutMsg);try{c.abort()}catch(t){}}}}),a&&c.onProgressUpdate((function(t){a(t)})),[2]}))},new((s=void 0)||(s=Promise))((function(t,e){function r(t){try{c(a.next(t))}catch(t){e(t)}}function n(t){try{c(a.throw(t))}catch(t){e(t)}}function c(e){var i;e.done?t(e.value):(i=e.value,i instanceof s?i:new s((function(t){t(i)}))).then(r,n)}c((a=a.apply(i,o||[])).next())}));var i,o,s,a}))},e.prototype.download=function(t){var e=this,r=this;return new Promise((function(n,i){var o=t.url,s=t.headers,a=wx.downloadFile({url:(0,x.formatUrl)("https:",o),header:s,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?n({statusCode:200,tempFilePath:t.tempFilePath}):n(t)},fail:function(t){i(t)},complete:function(t){if(t&&t.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg){console.warn(r._timeoutMsg);try{a.abort()}catch(t){}}}})}))},e}(x.AbstractSDKRequest),B={setItem:function(t,e){wx.setStorageSync(t,e)},getItem:function(t){return wx.getStorageSync(t)},removeItem:function(t){wx.removeStorageSync(t)},clear:function(){wx.clearStorageSync()}},j=function(t,e){void 0===e&&(e={});var r=wx.connectSocket(M({url:t},e));return{set onopen(t){r.onOpen(t)},set onmessage(t){r.onMessage(t)},set onclose(t){r.onClose(t)},set onerror(t){r.onError(t)},send:function(t){return r.send({data:t})},close:function(t,e){return r.close({code:t,reason:e})},get readyState(){return r.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};const V=function(){return{root:{},reqClass:q,wsClass:j,localStorage:B,primaryStorage:x.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},F=function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0};var H=r(105),W=function(){return W=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},W.apply(this,arguments)},G=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},$=function(t,e){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(c){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=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},K=function(){function t(t){this.localStorage=(null==t?void 0:t.localStorage)||globalThis.localStorage}return t.prototype.getItem=function(t){return G(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return G(this,void 0,void 0,(function(){return $(this,(function(e){return this.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return G(this,void 0,void 0,(function(){return $(this,(function(r){return this.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return this.localStorage.getItem(t)},t.prototype.setItemSync=function(t,e){this.localStorage.setItem(t,e)},t.prototype.removeItemSync=function(t){this.localStorage.removeItem(t)},t}(),Y=/^[^:]+:\/\/[^/]+(\/[^?#]+)/;var z=function(t){if(!F()||t.storage&&t.baseRequest)return t;var e={};try{var r=V(),n=r.localStorage,i=r.reqClass;if(n&&(e.storage=new K({localStorage:n})),i){var o=new i({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});e.request=function(t){return function(e,r){var n;return G(this,void 0,void 0,(function(){var i;return $(this,(function(o){return i=null===(n=null==r?void 0:r.headers)||void 0===n?void 0:n["x-request-id"],[2,new Promise((function(n,o){var s=Object.assign({},r);s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));var a=wx.request({url:e,data:s.body,timeout:t._timeout,method:s.method||"GET",header:s.headers,success:function(t){t.code&&(t={error:t.code,error_description:t.message||t.code,request_id:t.requestId}),t.request_id||(t.request_id=t.request_id||i),t.error&&(t.error_uri=function(t){return Y.test(t)?RegExp.$1:t}(e),o(t)),n(t.data||{})},fail:function(t){o({error:"unreachable",error_description:t.message})},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("request")&&"request:fail timeout"===e.errMsg){console.warn(t._timeoutMsg);try{a.abort()}catch(t){}}}})}))]}))}))}}(o)}return W(W({},t),e)}catch(t){console.error("adapter generate fail:",t)}return t},Q=function(){return Q=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Q.apply(this,arguments)},Z=function(t,e,r,n){var i,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},J=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},X=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},tt=function(t,e){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(c){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=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},et="loginStateChanged",rt=new L.CloudbaseEventEmitter,nt=function(){function t(t){var e=t.cache,r=t.oauthInstance;this.cache=e,this.oauthInstance=r,this.setUserInfo()}return t.prototype.checkLocalInfo=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return X(this,void 0,void 0,(function(){var t,e,r,n;return tt(this,(function(i){switch(i.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=i.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.gender=i.sent(),this.picture=this.getLocalUserInfo("picture"),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]}}))}))},t.prototype.update=function(t){return X(this,void 0,void 0,(function(){var e;return tt(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(Q({},t))];case 1:return e=r.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updateUserBasicInfo=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(Q({},t))];case 1:return e.sent(),this.setLocalUserInfo({username:t.username}),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&(0,C.throwError)(U.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(t){return X(this,void 0,void 0,(function(){var e;return tt(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(t)];case 1:return e=r.sent(),this.setLocalUserInfo(e),[2,e]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;return this.cache.getStore(e)[t]},t.prototype.getLocalUserInfoAsync=function(t){return X(this,void 0,void 0,(function(){var e;return tt(this,(function(r){switch(r.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,r.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,r=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username"].forEach((function(e){t[e]=r[e]}))},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},Z([(0,N.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"update",null),Z([(0,N.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[String,String]),J("design:returntype",void 0)],t.prototype,"updatePassword",null),Z([(0,N.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[String]),J("design:returntype",void 0)],t.prototype,"updateUsername",null),Z([(0,N.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"refresh",null),t}(),it=function(){function t(t){var e=t.envId,r=t.cache,n=t.oauthInstance;e||(0,C.throwError)(U.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new nt({cache:this.cache,oauthInstance:n})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}}))}))},t}(),ot=function(){function t(t){this.config=t,this.cache=t.cache,this.oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.editContact(t)]}))}))},t.prototype.unbindProvider=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},t.prototype.bindEmail=function(t){return this.oauthInstance.authApi.editContact(t)},t.prototype.verify=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.getVerification(t)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}(0,C.printWarn)(U.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return X(this,void 0,void 0,(function(){var t;return tt(this,(function(e){switch(e.label){case 0:return[4,this.getLoginState()];case 1:return(t=e.sent())?[4,t.user.checkLocalInfoAsync()]:[3,3];case 2:return e.sent(),[2,t.user||null];case 3:return[2,null]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInWithOpenId=function(t){var e=(void 0===t?{}:t).useWxCloud,r=void 0===e||e;return X(this,void 0,void 0,(function(){var t,e,n=this;return tt(this,(function(i){switch(i.label){case 0:if(!F())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return X(n,void 0,void 0,(function(){var n,i;return tt(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==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.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]}}))}))},[4,new Promise((function(t,r){wx.login({success:function(i){return X(n,void 0,void 0,(function(){var n;return tt(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,e(i.code)];case 1:return o.sent(),t(!0),[3,3];case 2:return n=o.sent(),r(n),[3,3];case 3:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})}))];case 1:return i.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInWithUnionId=function(){return X(this,void 0,void 0,(function(){var t=this;return tt(this,(function(e){switch(e.label){case 0:if(!F())throw Error("wx api undefined");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,new Promise((function(e,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(i){return X(t,void 0,void 0,(function(){var t,o,s,a,c;return tt(this,(function(u){switch(u.label){case 0:t=null==n?void 0:n.appId,u.label=1;case 1:return u.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:i.code,provider_id:t,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return o=u.sent(),(s=o.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:t,provider_token:s})]:(r(o),[2]);case 3:return(null==(a=u.sent())?void 0:a.error_code)?(r(a),[2]):(e(!0),[3,5]);case 4:return c=u.sent(),r(c),[3,5];case 5:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})}))];case 2:return e.sent(),[3,4];case 3:throw e.sent();case 4:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithPhoneAuth=function(t){var e=t.phoneCode,r=void 0===e?"":e;return X(this,void 0,void 0,(function(){var t,e,n,i,o;return tt(this,(function(s){switch(s.label){case 0:if(!F())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e={provider_params:{provider_code_type:"phone"},provider_id:t.appId},[4,wx.login()];case 1:n=s.sent().code,e.provider_code=n,s.label=2;case 2:return s.trys.push([2,6,,7]),[4,this.oauthInstance.authApi.grantProviderToken(e)];case 3:if((i=s.sent()).error_code)throw i;return[4,this.oauthInstance.authApi.patchProviderToken({provider_token:i.provider_token,provider_id:t.appId,provider_params:{code:r,provider_code_type:"phone"}})];case 4:if((i=s.sent()).error_code)throw i;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:i.provider_token})];case 5:if(null==(o=s.sent())?void 0:o.error_code)throw o;return[3,7];case 6:throw s.sent();case 7:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithSms=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,i=void 0===n?"":n,o=t.phoneNum,s=void 0===o?"":o,a=t.bindInfo,c=void 0===a?void 0:a;return X(this,void 0,void 0,(function(){var t,e,n,o,a;return tt(this,(function(u){switch(u.label){case 0:return u.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:i})];case 1:if(null==(t=u.sent())?void 0:t.error_code)throw t;return e=t.verification_token,r.is_user?[4,this.oauthInstance.authApi.signIn({username:"+86 ".concat(s),verification_token:e})]:[3,5];case 2:if(null==(n=u.sent())?void 0:n.error_code)throw n;return c?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==c?void 0:c.providerToken})]:[3,4];case 3:if(null==(o=u.sent())?void 0:o.error_code)throw o;u.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp({phone_number:"+86 ".concat(s),verification_token:e,provider_token:null==c?void 0:c.providerId})];case 6:if(null==(a=u.sent())?void 0:a.error_code)throw a;u.label=7;case 7:return[2,this.createLoginState()];case 8:throw u.sent();case 9:return[2]}}))}))},t.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithCustomTicket(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signIn=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.signUp=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signUp(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setPassword=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,C.throwError)(U.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,e.sent().exist]}}))}))},t.prototype.signOut=function(){return X(this,void 0,void 0,(function(){var t;return tt(this,(function(e){switch(e.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut()];case 1:return e.sent(),[4,this.cache.removeStoreAsync(t)];case 2:return e.sent(),rt.fire(et),[2]}}))}))},t.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new it({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,C.printWarn)(U.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.getLoginState()];case 1:return t.sent()?[2,new it({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.getUserInfo(t)]}))}))},t.prototype.getWedaUserInfo=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(t){return X(this,void 0,void 0,(function(){var e;return tt(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(e=r.sent())?[4,e.user.updateUserBasicInfo(t)]:[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(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}}))}))},t.prototype.grantProviderToken=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.patchProviderToken=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.grantToken=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return X(this,void 0,void 0,(function(){var e,r=this;return tt(this,(function(n){switch(n.label){case 0:return rt.on(et,(function(){return X(r,void 0,void 0,(function(){var e;return tt(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return e=r.sent(),t.call(this,e),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))},t.prototype.refreshTokenForce=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]}))}))},t.prototype.getCredentials=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getProviderSubType=function(){return X(this,void 0,void 0,(function(){return tt(this,(function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]}))}))},t.prototype.verifyCaptchaData=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]}))}))},t.prototype.getMiniProgramQrCode=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]}))}))},t.prototype.modifyPassword=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.modifyPassword(t)]}))}))},t.prototype.getUserBehaviorLog=function(t){return X(this,void 0,void 0,(function(){return tt(this,(function(e){return[2,this.oauthInstance.authApi.getUserBehaviorLog(t)]}))}))},t.prototype.createLoginState=function(t){return X(this,void 0,void 0,(function(){var e;return tt(this,(function(r){switch(r.label){case 0:return[4,(e=new it({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return r.sent(),[4,e.user.refresh(t)];case 2:return r.sent(),rt.fire(et),[2,e]}}))}))},Z([(0,N.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),Z([(0,N.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"unbindProvider",null),Z([(0,N.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",void 0)],t.prototype,"bindEmail",null),Z([(0,N.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"verify",null),Z([(0,N.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"getVerification",null),Z([(0,N.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[]),J("design:returntype",Promise)],t.prototype,"getCurrentUser",null),Z([(0,N.catchErrorsDecorator)({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"signInAnonymously",null),Z([(0,N.catchErrorsDecorator)({title:"小程序openId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().signInWithOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"signInWithOpenId",null),Z([(0,N.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[]),J("design:returntype",Promise)],t.prototype,"signInWithUnionId",null),Z([(0,N.catchErrorsDecorator)({title:"小程序手机号授权登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序手机号授权登录"," 2 - 调用 auth().signInWithPhoneAuth() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"signInWithPhoneAuth",null),Z([(0,N.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"signInWithSms",null),Z([(0,N.catchErrorsDecorator)({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),Z([(0,N.catchErrorsDecorator)({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"signUp",null),Z([(0,N.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[String]),J("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),Z([(0,N.catchErrorsDecorator)({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[]),J("design:returntype",Promise)],t.prototype,"signOut",null),Z([(0,N.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[]),J("design:returntype",Promise)],t.prototype,"getLoginState",null),Z([(0,N.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"getUserInfo",null),Z([(0,N.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[]),J("design:returntype",Promise)],t.prototype,"getWedaUserInfo",null),Z([(0,N.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[Object]),J("design:returntype",Promise)],t.prototype,"bindWithProvider",null),Z([(0,N.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(U.COMMUNITY_SITE_URL)]}),J("design:type",Function),J("design:paramtypes",[]),J("design:returntype",Promise)],t.prototype,"getProviderSubType",null),t}();function st(t,e){var r=t.region,n=void 0===r?"ap-shanghai":r,i=(null==e?void 0:e.platform)||(0,H.useDefaultAdapter)(),o=i.runtime,s=e||{},a=s.env,c=s.clientId,u=s.debug,h=s.cache,l=s.app,d=(e||{}).apiOrigin;d||(d="https://".concat(a,".").concat(n,".tcb-api.tencentcloudapi.com"));var f=new A(z({env:a,clientId:c,apiOrigin:d,storage:null==t?void 0:t.storage,baseRequest:null==t?void 0:t.baseRequest,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc,captchaOptions:null==t?void 0:t.captchaOptions,wxCloud:null==t?void 0:t.wxCloud}));return{authInstance:new ot({env:a,region:n,persistence:t.persistence,debug:u,cache:h||new D.CloudbaseCache({persistence:t.persistence,keys:{userInfoKey:"user_info_".concat(a)},platformInfo:i}),runtime:o||"web",_fromApp:l,oauthInstance:f}),oauthInstance:f}}var at={name:"auth",namespace:"auth",entity:function(t){if(void 0===t&&(t={region:"",persistence:"local"}),this.authInstance)return(0,C.printWarn)(U.ERRORS.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var e=this.platform.adapter,r=t.persistence||e.primaryStorage;r&&r!==this.config.persistence&&this.updateConfig({persistence:r});var n=st(Q(Q({wxCloud:this.config.wxCloud,storage:this.config.storage},t),{persistence:this.config.persistence}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),i=n.authInstance,o=n.oauthInstance;return this.oauthInstance=o,this.authInstance=i,this.authInstance}};try{cloudbase.registerComponent(at)}catch(t){}function ct(t){try{t.registerComponent(at)}catch(t){console.warn(t)}}},443:(t,e,r)=>{let n;if(r.r(e),r.d(e,{getEncryptInfo:()=>D}),!globalThis.IS_MP_BUILD){const x="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;var i="0123456789abcdefghijklmnopqrstuvwxyz";function k(t){return i.charAt(t)}function M(t,e){return t&e}function q(t,e){return t|e}function B(t,e){return t^e}function j(t,e){return t&~e}function V(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function F(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s="=";function H(t){var e,r,n="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),n+=o.charAt(r>>6)+o.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=o.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=o.charAt(r>>2)+o.charAt((3&r)<<4));(3&n.length)>0;)n+=s;return n}function W(t){var e,r="",n=0,i=0;for(e=0;e<t.length&&t.charAt(e)!=s;++e){var a=o.indexOf(t.charAt(e));a<0||(0==n?(r+=k(a>>2),i=3&a,n=1):1==n?(r+=k(i<<2|a>>4),i=15&a,n=2):2==n?(r+=k(i),r+=k(a>>2),i=3&a,n=3):(r+=k(i<<2|a>>4),r+=k(15&a),n=0))}return 1==n&&(r+=k(i<<2)),r}var a,c,u={decode:function(t){var e;if(void 0===a){var r="0123456789ABCDEF",n=" \f\n\r\t \u2028\u2029";for(a={},e=0;e<16;++e)a[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)a[r.charAt(e)]=e;for(e=0;e<n.length;++e)a[n.charAt(e)]=-1}var i=[],o=0,s=0;for(e=0;e<t.length;++e){var c=t.charAt(e);if("="==c)break;if(-1!=(c=a[c])){if(void 0===c)throw new Error("Illegal character at offset "+e);o|=c,++s>=2?(i[i.length]=o,o=0,s=0):o<<=4}}if(s)throw new Error("Hex encoding incomplete: 4 bits missing");return i}},h={decode:function(t){var e;if(void 0===c){var r="= \f\n\r\t \u2028\u2029";for(c=Object.create(null),e=0;e<64;++e)c["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<r.length;++e)c[r.charAt(e)]=-1}var n=[],i=0,o=0;for(e=0;e<t.length;++e){var s=t.charAt(e);if("="==s)break;if(-1!=(s=c[s])){if(void 0===s)throw new Error("Illegal character at offset "+e);i|=s,++o>=4?(n[n.length]=i>>16,n[n.length]=i>>8&255,n[n.length]=255&i,i=0,o=0):i<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=i>>10;break;case 3:n[n.length]=i>>16,n[n.length]=i>>8&255}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=h.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return h.decode(t)}},l=1e13;class G{constructor(t){this.buf=[+t||0]}mulAdd(t,e){var r,n,i=this.buf,o=i.length;for(r=0;r<o;++r)(n=i[r]*t+e)<l?e=0:n-=(e=0|n/l)*l,i[r]=n;e>0&&(i[r]=e)}sub(t){var e,r,n=this.buf,i=n.length;for(e=0;e<i;++e)(r=n[e]-t)<0?(r+=l,t=1):t=0,n[e]=r;for(;0===n[n.length-1];)n.pop()}toString(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),n=e.length-2;n>=0;--n)r+=(l+e[n]).toString().substring(1);return r}valueOf(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*l+t[r];return e}simplify(){var t=this.buf;return 1==t.length?t[0]:this}}var d,f="…",p=/^(\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)?)?$/,g=/^(\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 $(t,e){return t.length>e&&(t=t.substring(0,e)+f),t}class K{constructor(t,e){this.hexDigits="0123456789ABCDEF",t instanceof K?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}get(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]}hexByte(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)}hexDump(t,e,r){for(var n="",i=t;i<e;++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(t,e){for(var r=t;r<e;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(t,e){for(var r="",n=t;n<e;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(t,e){for(var r="",n=t;n<e;){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(t,e){for(var r,n,i="",o=t;o<e;)r=this.get(o++),n=this.get(o++),i+=String.fromCharCode(r<<8|n);return i}parseTime(t,e,r){var n=this.parseStringISO(t,e),i=(r?p:g).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(t,e){for(var r,n=this.get(t),i=n>127,o=i?255:0,s="";n==o&&++t<e;)n=this.get(t);if(0==(r=e-t))return i?-1:0;if(r>4){for(s=n,r<<=3;0==(128&(+s^o));)s=+s<<1,--r;s="("+r+" bit)\n"}i&&(n-=256);for(var a=new G(n),c=t+1;c<e;++c)a.mulAdd(256,this.get(c));return s+a.toString()}parseBitString(t,e,r){for(var n=this.get(t),i="("+((e-t-1<<3)-n)+" bit)\n",o="",s=t+1;s<e;++s){for(var a=this.get(s),c=s==e-1?n:0,u=7;u>=c;--u)o+=a>>u&1?"1":"0";if(o.length>r)return i+$(o,r)}return i+o}parseOctetString(t,e,r){if(this.isASCII(t,e))return $(this.parseStringISO(t,e),r);var n=e-t,i="("+n+" byte)\n";n>(r/=2)&&(e=t+r);for(var o=t;o<e;++o)i+=this.hexByte(this.get(o));return n>r&&(i+=f),i}parseOID(t,e,r){for(var n="",i=new G,o=0,s=t;s<e;++s){var a=this.get(s);if(i.mulAdd(128,127&a),o+=7,!(128&a)){if(""===n)if((i=i.simplify())instanceof G)i.sub(80),n="2."+i.toString();else{var c=i<80?i<40?0:1:2;n=c+"."+(i-40*c)}else n+="."+i.toString();if(n.length>r)return $(n,r);i=new G,o=0}}return o>0&&(n+=".incomplete"),n}}class Y{constructor(t,e,r,n,i){if(!(n instanceof z))throw new Error("Invalid tag value.");this.stream=t,this.header=e,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(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+r,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);case 6:return this.stream.parseOID(e,e+r,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return $(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return $(this.stream.parseStringISO(e,e+r),t);case 30:return $(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+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(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var r=0,n=this.sub.length;r<n;++r)e+=this.sub[r].toPrettyString(t)}return e}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(t){var e=t.get(),r=127&e;if(r==e)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var n=0;n<r;++n)e=256*e+t.get();return e}getHexStringValue(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)}static decode(t){var e;e=t instanceof K?t:new K(t,0);var r=new K(e),n=new z(e),i=Y.decodeLength(e),o=e.pos,s=o-r.pos,a=null,c=function(){var t=[];if(null!==i){for(var r=o+i;e.pos<r;)t[t.length]=Y.decode(e);if(e.pos!=r)throw new Error("Content size is not correct for container starting at offset "+o)}else try{for(;;){var n=Y.decode(e);if(n.tag.isEOC())break;t[t.length]=n}i=o-e.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(n.tagConstructed)a=c();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=e.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=c();for(var u=0;u<a.length;++u)if(a[u].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){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);e.pos=o+Math.abs(i)}return new Y(r,s,i,n,a)}}class z{constructor(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){var r=new G;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var v=[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],y=(1<<26)/v[v.length-1];class Q{constructor(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}toString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<<e)-1,i=!1,o="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(i=!0,o=k(r));s>=0;)a<e?(r=(this[s]&(1<<a)-1)<<e-a,r|=this[--s]>>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=k(r));return i?o:"0"}negate(){var t=Z();return Q.ZERO.subTo(this,t),t}abs(){return this.s<0?this.negate():this}compareTo(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+it(this[this.t-1]^this.s&this.DM)}mod(t){var e=Z();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(Q.ZERO)>0&&t.subTo(e,e),e}modPowInt(t,e){var r;return r=t<256||e.isEven()?new _(e):new I(e),this.exp(t,r)}clone(){var t=Z();return this.copyTo(t),t}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 t=this.t,e=[];e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e}equals(t){return 0==this.compareTo(t)}min(t){return this.compareTo(t)<0?this:t}max(t){return this.compareTo(t)>0?this:t}and(t){var e=Z();return this.bitwiseTo(t,M,e),e}or(t){var e=Z();return this.bitwiseTo(t,q,e),e}xor(t){var e=Z();return this.bitwiseTo(t,B,e),e}andNot(t){var e=Z();return this.bitwiseTo(t,j,e),e}not(){for(var t=Z(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}shiftLeft(t){var e=Z();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}shiftRight(t){var e=Z();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}getLowestSetBit(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+V(this[t]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=F(this[r]^e);return t}testBit(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)}setBit(t){return this.changeBit(t,q)}clearBit(t){return this.changeBit(t,j)}flipBit(t){return this.changeBit(t,B)}add(t){var e=Z();return this.addTo(t,e),e}subtract(t){var e=Z();return this.subTo(t,e),e}multiply(t){var e=Z();return this.multiplyTo(t,e),e}divide(t){var e=Z();return this.divRemTo(t,e,null),e}remainder(t){var e=Z();return this.divRemTo(t,null,e),e}divideAndRemainder(t){var e=Z(),r=Z();return this.divRemTo(t,e,r),[e,r]}modPow(t,e){var r,n,i=t.bitLength(),o=nt(1);if(i<=0)return o;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new _(e):e.isEven()?new b(e):new I(e);var s=[],a=3,c=r-1,u=(1<<r)-1;if(s[1]=n.convert(this),r>1){var h=Z();for(n.sqrTo(s[1],h);a<=u;)s[a]=Z(),n.mulTo(h,s[a-2],s[a]),a+=2}var l,d,f=t.t-1,p=!0,g=Z();for(i=it(t[f])-1;f>=0;){for(i>=c?l=t[f]>>i-c&u:(l=(t[f]&(1<<i+1)-1)<<c-i,f>0&&(l|=t[f-1]>>this.DB+i-c)),a=r;0==(1&l);)l>>=1,--a;if((i-=a)<0&&(i+=this.DB,--f),p)s[l].copyTo(o),p=!1;else{for(;a>1;)n.sqrTo(o,g),n.sqrTo(g,o),a-=2;a>0?n.sqrTo(o,g):(d=o,o=g,g=d),n.mulTo(g,s[l],o)}for(;f>=0&&0==(t[f]&1<<i);)n.sqrTo(o,g),d=o,o=g,g=d,--i<0&&(i=this.DB-1,--f)}return n.revert(o)}modInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return Q.ZERO;for(var r=t.clone(),n=this.clone(),i=nt(1),o=nt(0),s=nt(0),a=nt(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(i.isEven()&&o.isEven()||(i.addTo(this,i),o.subTo(t,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),e?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(t,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}return 0!=n.compareTo(Q.ONE)?Q.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}pow(t){return this.exp(t,new m)}gcd(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i<o&&(o=i),o>0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r}isProbablePrime(t){var e,r=this.abs();if(1==r.t&&r[0]<=v[v.length-1]){for(e=0;e<v.length;++e)if(r[0]==v[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<v.length;){for(var n=v[e],i=e+1;i<v.length&&n<y;)n*=v[i++];for(n=r.modInt(n);e<i;)if(n%v[e++]==0)return!1}return r.millerRabin(t)}copyTo(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}fromInt(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}fromString(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&+t[n]:rt(t,n);s<0?"-"==t.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&&0!=(128&+t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),i&&Q.ZERO.subTo(this,this)}clamp(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}dlShiftTo(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s}drShiftTo(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s}lShiftTo(t,e){for(var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,o=Math.floor(t/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+o+1]=this[a]>>n|s,s=(this[a]&i)<<r;for(a=o-1;a>=0;--a)e[a]=0;e[o]=s,e.t=this.t+o+1,e.s=this.s,e.clamp()}rShiftTo(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<<n)-1;e[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)e[s-r-1]|=(this[s]&o)<<i,e[s-r]=this[s]>>n;n>0&&(e[this.t-r-1]|=(this.s&o)<<i),e.t=this.t-r,e.clamp()}}subTo(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()}multiplyTo(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i<n.t;++i)e[i+r.t]=r.am(0,n[i],e,i,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&Q.ZERO.subTo(e,e)}squareTo(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()}divRemTo(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=Z());var o=Z(),s=this.s,a=t.s,c=this.DB-it(n[n.t-1]);c>0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var u=o.t,h=o[u-1];if(0!=h){var l=h*(1<<this.F1)+(u>1?o[u-2]>>this.F2:0),d=this.FV/l,f=(1<<this.F1)/l,p=1<<this.F2,g=r.t,v=g-u,y=null==e?Z():e;for(o.dlShiftTo(v,y),r.compareTo(y)>=0&&(r[r.t++]=1,r.subTo(y,r)),Q.ONE.dlShiftTo(u,y),y.subTo(o,o);o.t<u;)o[o.t++]=0;for(;--v>=0;){var m=r[--g]==h?this.DM:Math.floor(r[g]*d+(r[g-1]+p)*f);if((r[g]+=o.am(0,m,r,v,0,u))<m)for(o.dlShiftTo(v,y),r.subTo(y,r);r[g]<--m;)r.subTo(y,r)}null!=e&&(r.drShiftTo(u,e),s!=a&&Q.ZERO.subTo(e,e)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),s<0&&Q.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(t,e){if(t>4294967295||t<1)return Q.ONE;var r=Z(),n=Z(),i=e.convert(this),o=it(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<<o)>0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)}chunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}toRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=nt(r),i=Z(),o=Z(),s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s}fromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a<t.length;++a){var c=rt(t,a);c<0?"-"==t.charAt(a)&&0==this.signum()&&(i=!0):(s=e*s+c,++o>=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&Q.ZERO.subTo(this,this)}fromNumber(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(Q.ONE.shiftLeft(t-1),q,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(Q.ONE.shiftLeft(t-1),this);else{var n=[],i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(t,e,r){var n,i,o=Math.min(t.t,this.t);for(n=0;n<o;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(i=t.s&this.DM,n=o;n<this.t;++n)r[n]=e(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=o;n<t.t;++n)r[n]=e(i,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}changeBit(t,e){var r=Q.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}addTo(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()}dMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}multiplyLowerTo(t,e,r){var n=Math.min(this.t+t.t,e);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,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()}multiplyUpperTo(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)}modInt(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r}millerRabin(t){var e=this.subtract(Q.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>v.length&&(t=v.length);for(var i=Z(),o=0;o<t;++o){i.fromInt(v[Math.floor(Math.random()*v.length)]);var s=i.modPow(n,this);if(0!=s.compareTo(Q.ONE)&&0!=s.compareTo(e)){for(var a=1;a++<r&&0!=s.compareTo(e);)if(0==(s=s.modPowInt(2,this)).compareTo(Q.ONE))return!1;if(0!=s.compareTo(e))return!1}}return!0}square(){var t=Z();return this.squareTo(t),t}gcda(t,e){var r=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(r.compareTo(n)<0){var i=r;r=n,n=i}var o=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)e(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(){e(n)}),0))};setTimeout(a,10)}}fromNumberAsync(t,e,r,n){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(Q.ONE.shiftLeft(t-1),q,this),this.isEven()&&this.dAddOffset(1,0);var i=this,o=function(){i.dAddOffset(2,0),i.bitLength()>t&&i.subTo(Q.ONE.shiftLeft(t-1),i),i.isProbablePrime(e)?setTimeout((function(){n()}),0):setTimeout(o,0)};setTimeout(o,0)}else{var s=[],a=7&t;s.length=1+(t>>3),e.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var m=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),_=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),I=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=Z();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(Q.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=Z();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),b=function(){function t(t){this.m=t,this.r2=Z(),this.q3=Z(),Q.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=Z();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function Z(){return new Q(null)}function J(t,e){return new Q(t,e)}function X(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i}function tt(t,e,r,n,i,o){for(var s=32767&e,a=e>>15;--o>=0;){var c=32767&this[t],u=this[t++]>>15,h=a*c+u*s;i=((c=s*c+((32767&h)<<15)+r[n]+(1073741823&i))>>>30)+(h>>>15)+a*u+(i>>>30),r[n++]=1073741823&c}return i}function et(t,e,r,n,i,o){for(var s=16383&e,a=e>>14;--o>=0;){var c=16383&this[t],u=this[t++]>>14,h=a*c+u*s;i=((c=s*c+((16383&h)<<14)+r[n]+i)>>28)+(h>>14)+a*u,r[n++]=268435455&c}return i}void 0!==x&&"Microsoft Internet Explorer"==x?.appName?(Q.prototype.am=tt,d=30):"Netscape"!=x?.appName?(Q.prototype.am=X,d=26):(Q.prototype.am=et,d=28),Q.prototype.DB=d,Q.prototype.DM=(1<<d)-1,Q.prototype.DV=1<<d,Q.prototype.FV=Math.pow(2,52),Q.prototype.F1=52-d,Q.prototype.F2=2*d-52;var w,S,E=[];for(w="0".charCodeAt(0),S=0;S<=9;++S)E[w++]=S;for(w="a".charCodeAt(0),S=10;S<36;++S)E[w++]=S;for(w="A".charCodeAt(0),S=10;S<36;++S)E[w++]=S;function rt(t,e){var r=E[t.charCodeAt(e)];return null==r?-1:r}function nt(t){var e=Z();return e.fromInt(t),e}function it(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}Q.ZERO=nt(0),Q.ONE=nt(1);class ot{constructor(){this.i=0,this.j=0,this.S=[]}init(t){var e,r,n;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,n=this.S[e],this.S[e]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}}var T,R,O=256,A=null;if(null==A){A=[],R=0;var P=void 0;if(window?.crypto&&window?.crypto.getRandomValues){var C=new Uint32Array(256);for(window?.crypto.getRandomValues(C),P=0;P<C.length;++P)A[R++]=255&C[P]}var U=function(t){if(this.count=this.count||0,this.count>=256||R>=O)window?.removeEventListener?window?.removeEventListener("mousemove",U,!1):window?.detachEvent&&window?.detachEvent("onmousemove",U);else try{var e=t.x+t.y;A[R++]=255&e,this.count+=1}catch(t){}};window?.addEventListener?window?.addEventListener("mousemove",U,!1):window?.attachEvent&&window?.attachEvent("onmousemove",U)}function st(){if(null==T){for(T=new ot;R<O;){var t=Math.floor(65536*Math.random());A[R++]=255&t}for(T.init(A),R=0;R<A.length;++R)A[R]=0;R=0}return T.next()}class at{constructor(){}nextBytes(t){for(var e=0;e<t.length;++e)t[e]=st()}}function ct(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=t.length-1;n>=0&&e>0;){var i=t.charCodeAt(n--);i<128?r[--e]=i:i>127&&i<2048?(r[--e]=63&i|128,r[--e]=i>>6|192):(r[--e]=63&i|128,r[--e]=i>>6&63|128,r[--e]=i>>12|224)}r[--e]=0;for(var o=new at,s=[];e>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);r[--e]=s[0]}return r[--e]=2,r[--e]=0,new Q(r)}class ut{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(t){return t.modPowInt(this.e,this.n)}doPrivate(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=J(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}encrypt(t){var e=ct(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var n=r.toString(16);return 0==(1&n.length)?n:"0"+n}encryptLong(t){var e=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return t.length>r?(t.match(/.{1,117}/g).forEach((function(t){var r=e.encrypt(t);n+=r})),H(n)):H(this.encrypt(t))}catch(t){return!1}}decryptLong(t){var e=this,r=this.n.bitLength()+7>>3;t=W(t);try{if(t.length>r){var n="";return t.match(/.{1,256}/g).forEach((function(t){var r=e.decrypt(t);n+=r})),n}return this.decrypt(t)}catch(t){return!1}}setPrivate(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=J(t,16),this.e=parseInt(e,16),this.d=J(r,16)):console.error("Invalid RSA private key")}setPrivateEx(t,e,r,n,i,o,s,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=J(t,16),this.e=parseInt(e,16),this.d=J(r,16),this.p=J(n,16),this.q=J(i,16),this.dmp1=J(o,16),this.dmq1=J(s,16),this.coeff=J(a,16)):console.error("Invalid RSA private key")}generate(t,e){var r=new at,n=t>>1;this.e=parseInt(e,16);for(var i=new Q(e,16);;){for(;this.p=new Q(t-n,1,r),0!=this.p.subtract(Q.ONE).gcd(i).compareTo(Q.ONE)||!this.p.isProbablePrime(10););for(;this.q=new Q(n,1,r),0!=this.q.subtract(Q.ONE).gcd(i).compareTo(Q.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(Q.ONE),a=this.q.subtract(Q.ONE),c=s.multiply(a);if(0==c.gcd(i).compareTo(Q.ONE)){this.n=this.p.multiply(this.q),this.d=i.modInverse(c),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(t){var e=J(t,16),r=this.doPrivate(e);return null==r?null:ht(r,this.n.bitLength()+7>>3)}generateAsync(t,e,r){var n=new at,i=t>>1;this.e=parseInt(e,16);var o=new Q(e,16),s=this,a=()=>{var e=()=>{if(s.p.compareTo(s.q)<=0){var t=s.p;s.p=s.q,s.q=t}var e=s.p.subtract(Q.ONE),n=s.q.subtract(Q.ONE),i=e.multiply(n);0==i.gcd(o).compareTo(Q.ONE)?(s.n=s.p.multiply(s.q),s.d=o.modInverse(i),s.dmp1=s.d.mod(e),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},c=()=>{s.q=Z(),s.q.fromNumberAsync(i,1,n,(function(){s.q.subtract(Q.ONE).gcda(o,(function(t){0==t.compareTo(Q.ONE)&&s.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(c,0)}))}))},u=()=>{s.p=Z(),s.p.fromNumberAsync(t-i,1,n,(function(){s.p.subtract(Q.ONE).gcda(o,(function(t){0==t.compareTo(Q.ONE)&&s.p.isProbablePrime(10)?setTimeout(c,0):setTimeout(u,0)}))}))};setTimeout(u,0)};setTimeout(a,0)}}function ht(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-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 lt extends ut{constructor(t=""){super(),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))}parseKey(t){try{var e=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?u.decode(t):h.unarmor(t),i=Y.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=J(e,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var o=i.sub[3].getHexStringValue();this.d=J(o,16);var s=i.sub[4].getHexStringValue();this.p=J(s,16);var a=i.sub[5].getHexStringValue();this.q=J(a,16);var c=i.sub[6].getHexStringValue();this.dmp1=J(c,16);var l=i.sub[7].getHexStringValue();this.dmq1=J(l,16);var d=i.sub[8].getHexStringValue();this.coeff=J(d,16)}else{if(2!==i.sub.length)return!1;var f=i.sub[1].sub[0];e=f.sub[0].getHexStringValue(),this.n=J(e,16),r=f.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}}hasPublicKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")}hasPrivateKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")}parsePropertiesFrom(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)}}n=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null},n.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new lt(t)},n.prototype.setPrivateKey=function(t){this.setKey(t)},n.prototype.setPublicKey=function(t){this.setKey(t)},n.prototype.decrypt=function(t){try{return this.getKey().decrypt(W(t))}catch(t){return!1}},n.prototype.encrypt=function(t){try{return H(this.getKey().encrypt(t))}catch(t){return!1}},n.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",n=0,i=/null$/g;i.test(r)&&(n++,e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",!(n>10)););return e}catch(t){return!1}},n.prototype.getKey=function(t){if(!this.key){if(this.key=new lt,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}const N=n;var L=r(479);const D=({publicKey:t="",payload:e={}}={})=>{if(!t)return"";try{const r=(0,L.I)(e),n=new N;return n.setPublicKey(t),n.encryptLong("object"==typeof r?JSON.stringify(r):r)}catch(t){console.error("encrypt error:",t)}return""}},479:(t,e,r)=>{r.d(e,{I:()=>n,y:()=>i});const n=t=>{const e=e=>{for(const r in t)t.hasOwnProperty(r)&&(e[r]=n(t[r]));return e},r=null==t?"NullOrUndefined":Object.prototype.toString.call(t).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return t.slice();switch(r){case"Object":return e(Object.create(Object.getPrototypeOf(t)));case"Array":return e([]);case"Date":return new Date(t.valueOf());case"RegExp":return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""));default:return t}},i=t=>{const e=t.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return e&&e[2]||""}},105:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&n(e,t,r);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var s,a=o(r(587)),c=r(894);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(s=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t){for(var e=0,r=(0,c.isArray)(t)?t:[t];e<r.length;e++){var n=r[e],i=n.isMatch,o=n.genAdapter,s=n.runtime;if(i())return{adapter:o(),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:a.genAdapter(),runtime:s.WEB}}},587:function(t,e,r){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){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(c){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=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var c=r(997),u=r(894),h=r(652),l=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,i=e.timeoutMsg,o=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=i||"请求超时",r.restrictedMethods=o||["get","post","upload","download"],r}return i(e,t),e.prototype.get=function(t){return this.request(o(o({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(o(o({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(o(o({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,i=t.method,s=t.headers,a=void 0===s?{}:s,c={post:"post",put:"put"}[null==i?void 0:i.toLowerCase()]||"put",u=new FormData;return"post"===c?(Object.keys(e).forEach((function(t){u.append(t,e[t])})),u.append("key",n),u.append("file",r),this.request(o(o({},t),{data:u,method:c}),this.restrictedMethods.includes("upload"))):this.request(o(o({},t),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,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({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.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(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(i){var o,s,a=t.url,c=t.headers,l=void 0===c?{}:c,d=t.data,f=t.responseType,p=t.withCredentials,g=t.body,v=t.onUploadProgress,y=(0,u.formatUrl)((0,h.getProtocol)(),a,"get"===n?d:{}),m=new XMLHttpRequest;m.open(n,y),f&&(m.responseType=f),Object.keys(l).forEach((function(t){m.setRequestHeader(t,l[t])})),v&&m.upload.addEventListener("progress",v),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),i=e.join(": ");r[n]=i})),t.header=r,t.statusCode=m.status;try{t.data="blob"===f?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===f?m.response:m.responseText}clearTimeout(o),i(t)}},e&&r.timeout&&(o=setTimeout((function(){console.warn(r.timeoutMsg),m.abort()}),r.timeout)),s=(0,u.isFormData)(d)?d:"application/x-www-form-urlencoded"===l["content-type"]?(0,u.toQueryString)(d):g||(d?JSON.stringify(d):void 0),p&&(m.withCredentials=!0),m.send(s)}))},e}(c.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{root:window,reqClass:l,wsClass:WebSocket,localStorage}}},652:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var n="https:";e.setProtocol=function(t){n=t},e.getProtocol=function(){return n},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},151:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},141:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,i(r(652),e),i(r(151),e),e.OATUH_LOGINTYPE="constants"},64:function(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){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(c){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=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var o=r(894),s=r(141),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var c=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function h(t){var e=t.err,r=t.className,n=t.methodName,i=t.sourceLink;if(!i)return null;var o,s=e.stack.split("\n"),c=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(t){return c.test(t)}));if(-1!==l){var d=s.filter((function(t,e){return e>l}));d.unshift(s[l].replace(h,"".concat(r,".").concat(n)).replace(u,i)),(o=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return o}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,a=t.customInfo,l=void 0===a?{}:a,d=t.title,f=t.messages,p=void 0===f?[]:f;return function(t,e,a){if(s.IS_DEBUG_MODE){var f=l.className||t.constructor.name,g=l.methodName||e,v=a.value,y=function(t){var e="",r=(new Error).stack.split("\n"),n=r.findIndex((function(t){return c.test(t)}));if(-1!==n){var i=u.exec(r[n+1]||"");e=i?i[0]:""}return e}();a.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=h({err:new Error,className:f,methodName:g,sourceLink:y});try{return v.apply(this,t)}catch(t){var n=t,i=t.message,s=t.error,a=t.error_description,c={title:d||"".concat(f,".").concat(g," failed"),content:[{type:"error",body:t}]};if(i&&/^\{.*\}$/.test(i)){var u=JSON.parse(i);c.subtitle=i,u.code&&(r?(r.code=u.code,r.msg=u.msg):(t.code=u.code,t.message=u.msg),n=r||t,c.content=p.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(c.subtitle=a,r?(r.code=s,r.msg=a):(t.code=s,t.message=a),n=r||t,c.content=p.map((function(t){return{type:"info",body:t}}))),(0,o.printGroupLog)(c),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this,void 0,void 0,(function(){var e,r,n,s,a,c,u,l;return i(this,(function(i){switch(i.label){case 0:e=h({err:new Error,className:f,methodName:g,sourceLink:y}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,v.apply(this,t)];case 2:return[2,i.sent()];case 3:throw r=i.sent(),n=r,s=r.message,a=r.error,c=r.error_description,u={title:d||"".concat(f,".").concat(g," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),u.subtitle=l,l.code&&(e?(e.code=l.code,e.message=l.msg):(r.code=l.code,r.message=l.msg),n=e||r,u.content=p.map((function(t){return{type:"info",body:t}})))),a&&c&&(u.subtitle=c,e?(e.code=a,e.msg=c):(r.code=a,r.message=c),n=e||r,u.content=p.map((function(t){return{type:"info",body:t}}))),(0,o.printGroupLog)(u),n;case 4:return[2]}}))}))}}}}},466:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(64),e)},418:function(t,e,r){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){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(c){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=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=r(997),c=r(894),u=r(141),h=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return i(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(a.AbstractStorage),l=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,i=t.keys,o=void 0===i?{}:i;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(e.root));case"none":return new h(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=o)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,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:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return i.sent(),[3,4];case 3:return i.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){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=process.env)||void 0===r?void 0:r.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=i.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return o(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}();e.CloudbaseCache=l},988:function(t,e,r){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=r(894),a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var c=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return i(e,t),e}(a);e.IErrorEvent=c;var u=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,c))return console.error(t.error),this;var r=(0,s.isString)(t)?new a(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var i=0,u=this.listeners[n]?o([],this.listeners[n],!0):[];i<u.length;i++)u[i].call(this,r)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=u;var h=new u;e.addEventListener=function(t,e){h.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),h.fire(t,e)},e.removeEventListener=function(t,e){h.off(t,e)}},894:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.formatUrl=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var n=r(141);e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.formatUrl=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),i="";return Object.keys(r).forEach((function(t){""===i?!n&&(e+="?"):i+="&",i+="".concat(t,"=").concat(encodeURIComponent(r[t]))})),/^http(s)?:\/\//.test(e+=i)?e:"".concat(t).concat(e)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var r=e||window.location.search,n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),i=r.substr(r.indexOf("?")+1).match(n);return null!=i?i[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""},e.removeParam=function(t,e){var r=e.split("?")[0],n=[],i=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==i){for(var o=(n=i.split("&")).length-1;o>=0;o-=1)n[o].split("=")[0]===t&&n.splice(o,1);r="".concat(r,"?").concat(n.join("&"))}return r},e.createPromiseCallback=function(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,t},e.execCallback=function(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r},e.printWarn=function(t,e){console.warn("[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e=t.title,r=t.subtitle,n=void 0===r?"":r,i=t.content,o=void 0===i?[]:i,s=t.printTrace,a=void 0!==s&&s,c=t.collapsed;void 0!==c&&c?console.groupCollapsed(e,n):console.group(e,n);for(var u=0,h=o;u<h.length;u++){var l=h[u],d=l.type,f=l.body;switch(d){case"info":console.log(f);break;case"warn":console.warn(f);break;case"error":console.error(f)}}a&&console.trace("stack trace:"),console.groupEnd()},e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86".concat(t)}}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{var t=n;Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=void 0;var e=r(922);t.registerAuth=e.registerAuth})(),n})()));
|