@cloudbase/js-sdk 2.6.3-beta.0 → 2.6.4-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_oauth",[],e):"object"==typeof exports?exports.cloudbase_oauth=e():t.cloudbase_oauth=e()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var t={549:(t,e,n)=>{n.r(e),n.d(e,{ApiUrls:()=>o,Auth:()=>Zt,AuthClient:()=>Jt,CloudbaseOAuth:()=>Xt,ErrorType:()=>i,OAuth2Client:()=>U,Syntax:()=>r,authModels:()=>h,defaultRequest:()=>A,defaultStorage:()=>x,generateRequestId:()=>C,toResponseError:()=>O});var r,i,o,s,a,u,c,h={};n.r(h),function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(r||(r={})),function(t){t.UNREACHABLE="unreachable",t.LOCAL="local",t.CANCELLED="cancelled",t.UNKNOWN="unknown",t.INVALID_ARGUMENT="invalid_argument",t.DEADLINE_EXCEEDED="deadline_exceeded",t.NOT_FOUND="not_found",t.ALREADY_EXISTS="already_exists",t.PERMISSION_DENIED="permission_denied",t.UNAUTHENTICATED="unauthenticated",t.RESOURCE_EXHAUSTED="resource_exhausted",t.FAILED_PRECONDITION="failed_precondition",t.ABORTED="aborted",t.OUT_OF_RANGE="out_of_range",t.UNIMPLEMENTED="unimplemented",t.INTERNAL="internal",t.UNAVAILABLE="unavailable",t.DATA_LOSS="data_loss",t.CAPTCHA_REQUIRED="captcha_required",t.CAPTCHA_INVALID="captcha_invalid",t.INVALID_PASSWORD="invalid_password",t.INVALID_STATUS="invalid_status",t.USER_PENDING="user_pending",t.USER_BLOCKED="user_blocked",t.INVALID_VERIFICATION_CODE="invalid_verification_code",t.TWO_FACTOR_REQUIRED="two_factor_required",t.INVALID_TWO_FACTOR="invalid_two_factor",t.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",t.UNDER_REVIEW="under_review",t.INVALID_REQUEST="invalid_request",t.UNAUTHORIZED_CLIENT="unauthorized_client",t.ACCESS_DENIED="access_denied",t.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",t.INVALID_SCOPE="invalid_scope",t.INVALID_GRANT="invalid_grant",t.SERVER_ERROR="server_error",t.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",t.INTERACTION_REQUIRED="interaction_required",t.LOGIN_REQUIRED="login_required",t.ACCOUNT_SELECTION_REQUIRED="account_selection_required",t.CONSENT_REQUIRED="consent_required",t.INVALID_REQUEST_URI="invalid_request_uri",t.INVALID_REQUEST_OBJECT="invalid_request_object",t.REQUEST_NOT_SUPPORTED="request_not_supported",t.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",t.REGISTRATION_NOT_SUPPORTED="registration_not_supported"}(i||(i={})),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.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"}(o||(o={})),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"}(s||(s={})),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"}(a||(a={})),function(t){t.INVALID_ARGUMENT="invalid_argument",t.DEADLINE_EXCEEDED="deadline_exceeded",t.NOT_FOUND="not_found",t.ALREADY_EXISTS="already_exists",t.PERMISSION_DENIED="permission_denied",t.ABORTED="aborted",t.OUT_OF_RANGE="out_of_range",t.UNIMPLEMENTED="unimplemented",t.INTERNAL="internal",t.UNAVAILABLE="unavailable",t.DATA_LOSS="data_loss",t.CAPTCHA_REQUIRED="captcha_required",t.CAPTCHA_INVALID="captcha_invalid",t.INVALID_PASSWORD="invalid_password",t.PASSWORD_NOT_SET="password_not_set",t.INVALID_STATUS="invalid_status",t.USER_PENDING="user_pending",t.USER_BLOCKED="user_blocked"}(u||(u={})),function(t){t.local="local",t.none="none",t.session="session"}(c||(c={}));function l(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),i="";for(var o in n)""===i?!r&&(e+="?"):i+="&",i+=o+"="+encodeURIComponent(n[o]);return/^http(s)?\:\/\//.test(e+=i)?e:""+t+e}var f,d=(f=function(t,e){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},f(t,e)},function(t,e){function n(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),p=function(){return p=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},p.apply(this,arguments)};!function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this,r=e.timeout,i=e.timeoutMsg,o=e.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=i||"请求超时",n._restrictedMethods=o||["get","post","upload","download"],n}d(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(n,r){var i=t.url,o=t.data,s=t.headers,a=wx.request({url:l("https:",i),data:o,timeout:e._timeout,method:"POST",header:s,success:function(t){n(t)},fail:function(t){r(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,n=this;return new Promise((function(r){return i=e,o=void 0,a=function(){var e,i,o,s,a,u;return function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(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],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}(this,(function(c){return e=t.url,i=t.file,o=t.data,s=t.headers,a=t.onUploadProgress,u=wx.uploadFile({url:e,filePath:i,name:"file",formData:p({},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)),r(e)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{u.abort()}catch(t){}}}}),a&&u.onProgressUpdate((function(t){a(t)})),[2]}))},new((s=void 0)||(s=Promise))((function(t,e){function n(t){try{u(a.next(t))}catch(t){e(t)}}function r(t){try{u(a.throw(t))}catch(t){e(t)}}function u(e){var i;e.done?t(e.value):(i=e.value,i instanceof s?i:new s((function(t){t(i)}))).then(n,r)}u((a=a.apply(i,o||[])).next())}));var i,o,s,a}))},e.prototype.download=function(t){var e=this,n=this;return new Promise((function(r,i){var o=t.url,s=t.headers,a=wx.downloadFile({url:l("https:",o),header:s,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?r({statusCode:200,tempFilePath:t.tempFilePath}):r(t)},fail:function(t){i(t)},complete:function(t){if(t&&t.errMsg&&n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{a.abort()}catch(t){}}}})}))}}((function(){}));const g=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};function v(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}var y=function(t){var e=function(e){for(var n in t)t.hasOwnProperty(n)&&(e[n]=y(t[n]));return e},n=null==t?"NullOrUndefined":Object.prototype.toString.call(t).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(n))return t.slice();switch(n){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}},m=function(t){var e=t.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return e&&e[2]||""},b=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},E=function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},T=function(){function t(){this.fnPromiseMap=new Map}return t.prototype.run=function(t,e){return b(this,void 0,void 0,(function(){var n,r=this;return E(this,(function(i){switch(i.label){case 0:return[4,n=this.fnPromiseMap.get(t)];case 1:return i.sent()||(n=new Promise((function(n,i){b(r,void 0,void 0,(function(){var r,o,s;return E(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return a.sent(),r=e(),o=n,[4,r];case 2:return o.apply(void 0,[a.sent()]),[3,5];case 3:return s=a.sent(),i(s),[3,5];case 4:return this.fnPromiseMap.delete(t),[7];case 5:return[2]}}))}))})),this.fnPromiseMap.set(t,n)),[2,n]}}))}))},t.prototype.runIdlePromise=function(){return Promise.resolve()},t}(),S=function(){return S=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},S.apply(this,arguments)},_=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},w=function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},R="x-request-id",I="x-device-id",D="device_id",A=function(t,e){return _(this,void 0,void 0,(function(){var n,r,o,s,a;return w(this,(function(u){switch(u.label){case 0:n=null,r=null,u.label=1;case 1:return u.trys.push([1,4,,5]),(o=Object.assign({},e)).method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body)),[4,fetch(t,o)];case 2:return[4,u.sent().json()];case 3:return(null==(s=u.sent())?void 0:s.error)?(r=s).error_uri=new URL(t).pathname:n=s,[3,5];case 4:return a=u.sent(),r={error:i.UNREACHABLE,error_description:a.message,error_uri:new URL(t).pathname},[3,5];case 5:if(r)throw r;return[2,n]}}))}))},O=function(t,e){var n,r=e||{};if(t instanceof Error)n={error:r.error||i.LOCAL,error_description:r.error_description||t.message,error_uri:r.error_uri,details:r.details||t.stack};else{var o=t||{};n={error:r.error||o.error||i.LOCAL,error_description:r.error_description||o.error_description,error_uri:r.error_uri||o.error_uri,details:r.details||o.details}}return n};function C(){return v()}var x=new(function(){function t(){}return t.prototype.getItem=function(t){return _(this,void 0,void 0,(function(){return w(this,(function(e){return[2,window.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return _(this,void 0,void 0,(function(){return w(this,(function(e){return window.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return _(this,void 0,void 0,(function(){return w(this,(function(n){return window.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return window.localStorage.getItem(t)},t.prototype.removeItemSync=function(t){window.localStorage.removeItem(t)},t.prototype.setItemSync=function(t,e){window.localStorage.setItem(t,e)},t}());function P(t){var e=!0;return(null==t?void 0:t.expires_at)&&(null==t?void 0:t.access_token)&&(e=t.expires_at<new Date),e}var N=function(){function t(t){this.credentials=null,this.singlePromise=new T,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage}return t.prototype.getStorageCredentialsSync=function(){var t=null,e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t},t.prototype.setCredentials=function(t){return _(this,void 0,void 0,(function(){var e;return w(this,(function(n){switch(n.label){case 0:return(null==t?void 0:t.expires_in)?(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30)),this.storage?(e=JSON.stringify(t),[4,this.storage.setItem(this.tokenSectionName,e)]):[3,2]):[3,3];case 1:n.sent(),n.label=2;case 2:return this.credentials=t,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:n.sent(),n.label=5;case 5:this.credentials=null,n.label=6;case 6:return[2]}}))}))},t.prototype.getCredentials=function(){return _(this,void 0,void 0,(function(){var t=this;return w(this,(function(e){return[2,this.singlePromise.run("getCredentials",(function(){return _(t,void 0,void 0,(function(){var t;return w(this,(function(e){switch(e.label){case 0:return P(this.credentials)?(t=this,[4,this.getStorageCredentials()]):[3,2];case 1:t.credentials=e.sent(),e.label=2;case 2:return[2,this.credentials]}}))}))}))]}))}))},t.prototype.getStorageCredentials=function(){return _(this,void 0,void 0,(function(){var t=this;return w(this,(function(e){return[2,this.singlePromise.run("_getStorageCredentials",(function(){return _(t,void 0,void 0,(function(){var t,e;return w(this,(function(n){switch(n.label){case 0:return t=null,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),t=null,[3,5];case 5:return[2,t]}}))}))}))]}))}))},t}(),U=function(){function t(e){this.singlePromise=new T,this.apiOrigin=e.apiOrigin,this.clientId=e.clientId,this.retry=this.formatRetry(e.retry,t.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=A,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||x,this.localCredentials=new N({tokenSectionName:"credentials_".concat(e.clientId),storage:this.storage}),this.clientSecret=e.clientSecret,this.wxCloud=e.wxCloud;try{g()&&void 0===this.wxCloud&&e.env&&(wx.cloud.init({env:e.env}),this.wxCloud=wx.cloud)}catch(t){}this.refreshTokenFunc=e.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=e.anonymousSignInFunc}return t.prototype.setCredentials=function(t){return this.localCredentials.setCredentials(t)},t.prototype.getAccessToken=function(){return _(this,void 0,void 0,(function(){var t,e;return w(this,(function(n){switch(n.label){case 0:return[4,this.getCredentials()];case 1:return(null==(t=n.sent())?void 0:t.access_token)?[2,Promise.resolve(t.access_token)]:(e={error:i.UNAUTHENTICATED},[2,Promise.reject(e)])}}))}))},t.prototype.request=function(e,n){return _(this,void 0,void 0,(function(){var r,o,s,a,u,c,h;return w(this,(function(l){switch(l.label){case 0:return n||(n={}),r=this.formatRetry(n.retry,this.retry),n.headers=n.headers||{},this.headers&&(n.headers=S(S({},this.headers),n.headers)),n.headers[R]||(n.headers[R]=C()),n.headers[I]?[3,2]:[4,this.getDeviceId()];case 1:o=l.sent(),n.headers[I]=o,l.label=2;case 2:return(null==n?void 0:n.withCredentials)?[4,this.getCredentials()]:[3,4];case 3:return(s=l.sent())&&(this.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token=".concat(s.access_token)):n.headers.Authorization="".concat(s.token_type," ").concat(s.access_token)),[3,5];case 4:this.clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id=".concat(this.clientId)),l.label=5;case 5:e.startsWith("/")&&(e=this.apiOrigin+e),a=null,u=r+1,c=0,l.label=6;case 6:if(!(c<u))return[3,18];l.label=7;case 7:return l.trys.push([7,12,,15]),n.useWxCloud?[4,this.wxCloudCallFunction(e,n)]:[3,9];case 8:return a=l.sent(),[3,11];case 9:return[4,this.baseRequest(e,n)];case 10:a=l.sent(),l.label=11;case 11:return[3,18];case 12:return h=l.sent(),n.withCredentials&&h&&h.error===i.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,14];case 13:return l.sent(),[2,Promise.reject(h)];case 14:return c!==r&&h&&"unreachable"===h.error?[3,15]:[2,Promise.reject(h)];case 15:return[4,this.sleep(t.retryInterval)];case 16:l.sent(),l.label=17;case 17:return c++,[3,6];case 18:return[2,a]}}))}))},t.prototype.wxCloudCallFunction=function(t,e){var n;return _(this,void 0,void 0,(function(){var r,o,s,a;return w(this,(function(u){switch(u.label){case 0:r=null,o=null,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:t,method:e.method,headers:S({origin:"https://servicewechat.com"},e.headers),body:e.body}})];case 2:return s=u.sent().result,(null===(n=null==s?void 0:s.body)||void 0===n?void 0:n.error_code)?(o=null==s?void 0:s.body).error_uri=m(t):r=null==s?void 0:s.body,[3,4];case 3:return a=u.sent(),o={error:i.UNREACHABLE,error_description:a.message,error_uri:m(t)},[3,4];case 4:if(o)throw o;return[2,r]}}))}))},t.prototype.getCredentials=function(){return _(this,void 0,void 0,(function(){var t,e,n;return w(this,(function(r){switch(r.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return P(t=r.sent())?t&&"anonymous"===t.scope?this.anonymousSignInFunc?[4,this.anonymousSignInFunc(t)]:[3,5]:[3,8]:[3,10];case 2:return e=r.sent(),(n=e)?[3,4]:[4,this.localCredentials.getCredentials()];case 3:n=r.sent(),r.label=4;case 4:return t=n,[3,7];case 5:return[4,this.anonymousSignIn(t)];case 6:t=r.sent(),r.label=7;case 7:return[3,10];case 8:return[4,this.refreshToken(t)];case 9:t=r.sent(),r.label=10;case 10:return[2,t]}}))}))},t.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},t.prototype.getCredentialsAsync=function(){return this.getCredentials()},t.prototype.getScope=function(){return _(this,void 0,void 0,(function(){var t;return w(this,(function(e){switch(e.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=e.sent())?[2,t.scope]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},t.prototype.getGroups=function(){return _(this,void 0,void 0,(function(){var t;return w(this,(function(e){switch(e.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=e.sent())?[2,t.groups]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},t.prototype.refreshToken=function(t){return _(this,void 0,void 0,(function(){var e=this;return w(this,(function(n){return[2,this.singlePromise.run("_refreshToken",(function(){return _(e,void 0,void 0,(function(){var e,n;return w(this,(function(r){switch(r.label){case 0:if(!t||!t.refresh_token)return[2,this.unAuthenticatedError("no refresh token found in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.refreshTokenFunc(t.refresh_token,t)];case 2:return e=r.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return r.sent(),[2,e];case 4:return(n=r.sent()).error!==i.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},t.prototype.checkRetry=function(e){var n=null;if(("number"!=typeof e||e<t.minRetry||e>t.maxRetry)&&(n={error:i.UNREACHABLE,error_description:"wrong options param: retry"}),n)throw n;return e},t.prototype.formatRetry=function(t,e){return void 0===t?e:this.checkRetry(t)},t.prototype.sleep=function(t){return _(this,void 0,void 0,(function(){return w(this,(function(e){return[2,new Promise((function(e){setTimeout((function(){e()}),t)}))]}))}))},t.prototype.anonymousSignIn=function(t){return _(this,void 0,void 0,(function(){var e=this;return w(this,(function(n){return[2,this.singlePromise.run("_anonymous",(function(){return _(e,void 0,void 0,(function(){var e,n;return w(this,(function(r){switch(r.label){case 0:if(!t||"anonymous"!==t.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.request("/auth/v1/signin/anonymously",{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret}})];case 2:return e=r.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return r.sent(),[2,e];case 4:return(n=r.sent()).error!==i.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},t.prototype.defaultRefreshTokenFunc=function(t,e){return _(this,void 0,void 0,(function(){var n,r;return w(this,(function(i){switch(i.label){case 0:return void 0===t||""===t?[2,this.unAuthenticatedError("refresh token not found")]:(n=o.AUTH_TOKEN_URL,"v2"===(null==e?void 0:e.version)&&(n=s.AUTH_TOKEN_URL),[4,this.request(n,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}})]);case 1:return r=i.sent(),[2,S(S({},r),{version:(null==e?void 0:e.version)||"v1"})]}}))}))},t.prototype.getDeviceId=function(){return _(this,void 0,void 0,(function(){var t;return w(this,(function(e){switch(e.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(D)];case 1:return"string"==typeof(t=e.sent())&&t.length>=16&&t.length<=48?[3,3]:(t=v(),[4,this.storage.setItem(D,t)]);case 2:e.sent(),e.label=3;case 3:return this.deviceID=t,[2,t]}}))}))},t.prototype.unAuthenticatedError=function(t){var e={error:i.UNAUTHENTICATED,error_description:t};return Promise.reject(e)},t.defaultRetry=2,t.minRetry=0,t.maxRetry=5,t.retryInterval=1e3,t}();function L(){var t=globalThis.wx;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}var V=!1;function B(){V=V||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{L()||(V=V||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?B():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",B,!1))}catch(t){}function k(){return V}var q=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},M=function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},H=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=x),this.config=t,this.tokenSectionName="captcha_".concat(t.clientId)}return t.prototype.request=function(t,e){return q(this,void 0,void 0,(function(){var n,r,i,o;return M(this,(function(s){switch(s.label){case 0:return e||(e={}),e.method||(e.method="GET"),n="".concat(e.method,":").concat(t),r=t,e.withCaptcha?[4,this.appendCaptchaTokenToURL(t,n,!1)]:[3,2];case 1:r=s.sent(),s.label=2;case 2:return s.trys.push([2,4,,7]),[4,this.config.request(r,e)];case 3:return i=s.sent(),[3,7];case 4:return(o=s.sent()).error!==u.CAPTCHA_REQUIRED&&o.error!==u.CAPTCHA_INVALID?[3,6]:[4,this.appendCaptchaTokenToURL(t,n,o.error===u.CAPTCHA_INVALID)];case 5:return t=s.sent(),[2,this.config.request(t,e)];case 6:return[2,Promise.reject(o)];case 7:return[2,i]}}))}))},t.prototype.getDefaultOpenURIWithCallback=function(){if(!L()&&!k()&&(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap"))){var t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((function(){document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback},t.prototype.defaultOpenURIWithCallback=function(t,e){return q(this,void 0,void 0,(function(){var n,r,i,o,s,a,c;return M(this,(function(h){return r=(n=e||{}).width,i=void 0===r?"355px":r,o=n.height,s=void 0===o?"355px":o,t.match(/^(data:.*)$/)?[2,Promise.reject({error:u.UNIMPLEMENTED,error_description:"need to impl captcha data"})]:(a=document.getElementById("captcha_panel_wrap"),c=document.createElement("iframe"),a.innerHTML="",c.setAttribute("src",t),c.setAttribute("id","review-panel-iframe"),c.style.cssText="min-width:".concat(i,";display:block;height:").concat(s,";margin:0 auto;background-color: rgb(255, 255, 255);border: none;"),a.appendChild(c),a.style.display="block",[2,new Promise((function(t,e){c.onload=function(){try{var n=window.location,r=c.contentWindow.location;if(r.host+r.pathname===n.host+n.pathname){a.style.display="none";var i=new URLSearchParams(r.search),o=i.get("captcha_token");return o?t({captcha_token:o,expires_in:Number(i.get("expires_in"))}):e({error:i.get("error"),error_description:i.get("error_description")})}a.style.display="block"}catch(t){a.style.display="block"}}}))])}))}))},t.prototype.getCaptchaToken=function(t,e){return q(this,void 0,void 0,(function(){var n,r,i,s,a,u;return M(this,(function(c){switch(c.label){case 0:return t?[3,2]:[4,this.findCaptchaToken()];case 1:if(n=c.sent())return[2,n];c.label=2;case 2:return L()||k()?[3,4]:(i="".concat(window.location.origin+window.location.pathname,"?__captcha=on"),[4,this.config.request(o.GET_CAPTCHA_URL,{method:"POST",body:{client_id:this.config.clientId,redirect_uri:i,state:e},withCredentials:!1})]);case 3:return(r=c.sent()).captcha_token?(s={captcha_token:r.captcha_token,expires_in:r.expires_in},this.saveCaptchaToken(s),[2,r.captcha_token]):[3,6];case 4:return[4,this.config.request(o.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:""},withCredentials:!1})];case 5:a=c.sent(),r={url:"".concat(a.data,"?state=").concat(encodeURIComponent(e),"&token=").concat(encodeURIComponent(a.token))},c.label=6;case 6:return[4,this.config.openURIWithCallback(r.url)];case 7:return u=c.sent(),this.saveCaptchaToken(u),[2,u.captcha_token]}}))}))},t.prototype.appendCaptchaTokenToURL=function(t,e,n){return q(this,void 0,void 0,(function(){var r;return M(this,(function(i){switch(i.label){case 0:return[4,this.getCaptchaToken(n,e)];case 1:return r=i.sent(),t.indexOf("?")>0?t+="&captcha_token=".concat(r):t+="?captcha_token=".concat(r),[2,t]}}))}))},t.prototype.saveCaptchaToken=function(t){return q(this,void 0,void 0,(function(){var e;return M(this,(function(n){switch(n.label){case 0:return t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10)),e=JSON.stringify(t),[4,this.config.storage.setItem(this.tokenSectionName,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.findCaptchaToken=function(){return q(this,void 0,void 0,(function(){var t,e;return M(this,(function(n){switch(n.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(t=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?[2,null]:[2,e.captcha_token];case 3:return n.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),[2,null];case 5:return[2,null]}}))}))},t}(),j=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),F="0123456789abcdefghijklmnopqrstuvwxyz";function G(t){return F.charAt(t)}function K(t,e){return t&e}function W(t,e){return t|e}function Y(t,e){return t^e}function z(t,e){return t&~e}function Q(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 Z(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",$="=";function X(t){var e,n,r="";for(e=0;e+3<=t.length;e+=3)n=parseInt(t.substring(e,e+3),16),r+=J.charAt(n>>6)+J.charAt(63&n);for(e+1==t.length?(n=parseInt(t.substring(e,e+1),16),r+=J.charAt(n<<2)):e+2==t.length&&(n=parseInt(t.substring(e,e+2),16),r+=J.charAt(n>>2)+J.charAt((3&n)<<4));(3&r.length)>0;)r+=$;return r}function tt(t){var e,n="",r=0,i=0;for(e=0;e<t.length&&t.charAt(e)!=$;++e){var o=J.indexOf(t.charAt(e));o<0||(0==r?(n+=G(o>>2),i=3&o,r=1):1==r?(n+=G(i<<2|o>>4),i=15&o,r=2):2==r?(n+=G(i),n+=G(o>>2),i=3&o,r=3):(n+=G(i<<2|o>>4),n+=G(15&o),r=0))}return 1==r&&(n+=G(i<<2)),n}var et,nt,rt={decode:function(t){var e;if(void 0===nt){var n="= \f\n\r\t \u2028\u2029";for(nt=Object.create(null),e=0;e<64;++e)nt["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<n.length;++e)nt[n.charAt(e)]=-1}var r=[],i=0,o=0;for(e=0;e<t.length;++e){var s=t.charAt(e);if("="==s)break;if(-1!=(s=nt[s])){if(void 0===s)throw new Error("Illegal character at offset "+e);i|=s,++o>=4?(r[r.length]=i>>16,r[r.length]=i>>8&255,r[r.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:r[r.length]=i>>10;break;case 3:r[r.length]=i>>16,r[r.length]=i>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=rt.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 rt.decode(t)}},it=1e13,ot=function(){function t(t){this.buf=[+t||0]}return t.prototype.mulAdd=function(t,e){var n,r,i=this.buf,o=i.length;for(n=0;n<o;++n)(r=i[n]*t+e)<it?e=0:r-=(e=0|r/it)*it,i[n]=r;e>0&&(i[n]=e)},t.prototype.sub=function(t){var e,n,r=this.buf,i=r.length;for(e=0;e<i;++e)(n=r[e]-t)<0?(n+=it,t=1):t=0,r[e]=n;for(;0===r[r.length-1];)r.pop()},t.prototype.toString=function(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,n=e[e.length-1].toString(),r=e.length-2;r>=0;--r)n+=(it+e[r]).toString().substring(1);return n},t.prototype.valueOf=function(){for(var t=this.buf,e=0,n=t.length-1;n>=0;--n)e=e*it+t[n];return e},t.prototype.simplify=function(){var t=this.buf;return 1==t.length?t[0]:this},t}(),st="…",at=/^(\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)?)?$/,ut=/^(\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 ct(t,e){return t.length>e&&(t=t.substring(0,e)+st),t}var ht,lt=function(){function t(e,n){this.hexDigits="0123456789ABCDEF",e instanceof t?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=n)}return t.prototype.get=function(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]},t.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},t.prototype.hexDump=function(t,e,n){for(var r="",i=t;i<e;++i)if(r+=this.hexByte(this.get(i)),!0!==n)switch(15&i){case 7:r+=" ";break;case 15:r+="\n";break;default:r+=" "}return r},t.prototype.isASCII=function(t,e){for(var n=t;n<e;++n){var r=this.get(n);if(r<32||r>176)return!1}return!0},t.prototype.parseStringISO=function(t,e){for(var n="",r=t;r<e;++r)n+=String.fromCharCode(this.get(r));return n},t.prototype.parseStringUTF=function(t,e){for(var n="",r=t;r<e;){var i=this.get(r++);n+=i<128?String.fromCharCode(i):i>191&&i<224?String.fromCharCode((31&i)<<6|63&this.get(r++)):String.fromCharCode((15&i)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return n},t.prototype.parseStringBMP=function(t,e){for(var n,r,i="",o=t;o<e;)n=this.get(o++),r=this.get(o++),i+=String.fromCharCode(n<<8|r);return i},t.prototype.parseTime=function(t,e,n){var r=this.parseStringISO(t,e),i=(n?at:ut).exec(r);return i?(n&&(i[1]=+i[1],i[1]+=+i[1]<70?2e3:1900),r=i[1]+"-"+i[2]+"-"+i[3]+" "+i[4],i[5]&&(r+=":"+i[5],i[6]&&(r+=":"+i[6],i[7]&&(r+="."+i[7]))),i[8]&&(r+=" UTC","Z"!=i[8]&&(r+=i[8],i[9]&&(r+=":"+i[9]))),r):"Unrecognized time: "+r},t.prototype.parseInteger=function(t,e){for(var n,r=this.get(t),i=r>127,o=i?255:0,s="";r==o&&++t<e;)r=this.get(t);if(0==(n=e-t))return i?-1:0;if(n>4){for(s=r,n<<=3;0==(128&(+s^o));)s=+s<<1,--n;s="("+n+" bit)\n"}i&&(r-=256);for(var a=new ot(r),u=t+1;u<e;++u)a.mulAdd(256,this.get(u));return s+a.toString()},t.prototype.parseBitString=function(t,e,n){for(var r=this.get(t),i="("+((e-t-1<<3)-r)+" bit)\n",o="",s=t+1;s<e;++s){for(var a=this.get(s),u=s==e-1?r:0,c=7;c>=u;--c)o+=a>>c&1?"1":"0";if(o.length>n)return i+ct(o,n)}return i+o},t.prototype.parseOctetString=function(t,e,n){if(this.isASCII(t,e))return ct(this.parseStringISO(t,e),n);var r=e-t,i="("+r+" byte)\n";r>(n/=2)&&(e=t+n);for(var o=t;o<e;++o)i+=this.hexByte(this.get(o));return r>n&&(i+=st),i},t.prototype.parseOID=function(t,e,n){for(var r="",i=new ot,o=0,s=t;s<e;++s){var a=this.get(s);if(i.mulAdd(128,127&a),o+=7,!(128&a)){if(""===r)if((i=i.simplify())instanceof ot)i.sub(80),r="2."+i.toString();else{var u=i<80?i<40?0:1:2;r=u+"."+(i-40*u)}else r+="."+i.toString();if(r.length>n)return ct(r,n);i=new ot,o=0}}return o>0&&(r+=".incomplete"),r},t}(),ft=function(){function t(t,e,n,r,i){if(!(r instanceof dt))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=n,this.tag=r,this.sub=i}return t.prototype.typeName=function(){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()}},t.prototype.content=function(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),n=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+n,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+n);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+n,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+n,t);case 6:return this.stream.parseOID(e,e+n,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return ct(this.stream.parseStringUTF(e,e+n),t);case 18:case 19:case 20:case 21:case 22:case 26:return ct(this.stream.parseStringISO(e,e+n),t);case 30:return ct(this.stream.parseStringBMP(e,e+n),t);case 23:case 24:return this.stream.parseTime(e,e+n,23==this.tag.tagNumber)}return null},t.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},t.prototype.toPrettyString=function(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 n=0,r=this.sub.length;n<r;++n)e+=this.sub[n].toPrettyString(t)}return e},t.prototype.posStart=function(){return this.stream.pos},t.prototype.posContent=function(){return this.stream.pos+this.header},t.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},t.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},t.decodeLength=function(t){var e=t.get(),n=127&e;if(n==e)return n;if(n>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===n)return null;e=0;for(var r=0;r<n;++r)e=256*e+t.get();return e},t.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,n=2*this.length;return t.substr(e,n)},t.decode=function(e){var n;n=e instanceof lt?e:new lt(e,0);var r=new lt(n),i=new dt(n),o=t.decodeLength(n),s=n.pos,a=s-r.pos,u=null,c=function(){var e=[];if(null!==o){for(var r=s+o;n.pos<r;)e[e.length]=t.decode(n);if(n.pos!=r)throw new Error("Content size is not correct for container starting at offset "+s)}else try{for(;;){var i=t.decode(n);if(i.tag.isEOC())break;e[e.length]=i}o=s-n.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return e};if(i.tagConstructed)u=c();else if(i.isUniversal()&&(3==i.tagNumber||4==i.tagNumber))try{if(3==i.tagNumber&&0!=n.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");u=c();for(var h=0;h<u.length;++h)if(u[h].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){u=null}if(null===u){if(null===o)throw new Error("We can't skip over an invalid tag with undefined length at offset "+s);n.pos=s+Math.abs(o)}return new t(r,a,o,i,u)},t}(),dt=function(){function t(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){var n=new ot;do{e=t.get(),n.mulAdd(128,127&e)}while(128&e);this.tagNumber=n.simplify()}}return t.prototype.isUniversal=function(){return 0===this.tagClass},t.prototype.isEOC=function(){return 0===this.tagClass&&0===this.tagNumber},t}(),pt=[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],gt=(1<<26)/pt[pt.length-1],vt=function(){function t(t,e,n){null!=t&&("number"==typeof t?this.fromNumber(t,e,n):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}return t.prototype.toString=function(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 n,r=(1<<e)-1,i=!1,o="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(n=this[s]>>a)>0&&(i=!0,o=G(n));s>=0;)a<e?(n=(this[s]&(1<<a)-1)<<e-a,n|=this[--s]>>(a+=this.DB-e)):(n=this[s]>>(a-=e)&r,a<=0&&(a+=this.DB,--s)),n>0&&(i=!0),i&&(o+=G(n));return i?o:"0"},t.prototype.negate=function(){var e=Tt();return t.ZERO.subTo(this,e),e},t.prototype.abs=function(){return this.s<0?this.negate():this},t.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var n=this.t;if(0!=(e=n-t.t))return this.s<0?-e:e;for(;--n>=0;)if(0!=(e=this[n]-t[n]))return e;return 0},t.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+At(this[this.t-1]^this.s&this.DM)},t.prototype.mod=function(e){var n=Tt();return this.abs().divRemTo(e,null,n),this.s<0&&n.compareTo(t.ZERO)>0&&e.subTo(n,n),n},t.prototype.modPowInt=function(t,e){var n;return n=t<256||e.isEven()?new mt(e):new bt(e),this.exp(t,n)},t.prototype.clone=function(){var t=Tt();return this.copyTo(t),t},t.prototype.intValue=function(){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]},t.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},t.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},t.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},t.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var n,r=this.DB-t*this.DB%8,i=0;if(t-- >0)for(r<this.DB&&(n=this[t]>>r)!=(this.s&this.DM)>>r&&(e[i++]=n|this.s<<this.DB-r);t>=0;)r<8?(n=(this[t]&(1<<r)-1)<<8-r,n|=this[--t]>>(r+=this.DB-8)):(n=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),0!=(128&n)&&(n|=-256),0==i&&(128&this.s)!=(128&n)&&++i,(i>0||n!=this.s)&&(e[i++]=n);return e},t.prototype.equals=function(t){return 0==this.compareTo(t)},t.prototype.min=function(t){return this.compareTo(t)<0?this:t},t.prototype.max=function(t){return this.compareTo(t)>0?this:t},t.prototype.and=function(t){var e=Tt();return this.bitwiseTo(t,K,e),e},t.prototype.or=function(t){var e=Tt();return this.bitwiseTo(t,W,e),e},t.prototype.xor=function(t){var e=Tt();return this.bitwiseTo(t,Y,e),e},t.prototype.andNot=function(t){var e=Tt();return this.bitwiseTo(t,z,e),e},t.prototype.not=function(){for(var t=Tt(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},t.prototype.shiftLeft=function(t){var e=Tt();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},t.prototype.shiftRight=function(t){var e=Tt();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},t.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+Q(this[t]);return this.s<0?this.t*this.DB:-1},t.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,n=0;n<this.t;++n)t+=Z(this[n]^e);return t},t.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},t.prototype.setBit=function(t){return this.changeBit(t,W)},t.prototype.clearBit=function(t){return this.changeBit(t,z)},t.prototype.flipBit=function(t){return this.changeBit(t,Y)},t.prototype.add=function(t){var e=Tt();return this.addTo(t,e),e},t.prototype.subtract=function(t){var e=Tt();return this.subTo(t,e),e},t.prototype.multiply=function(t){var e=Tt();return this.multiplyTo(t,e),e},t.prototype.divide=function(t){var e=Tt();return this.divRemTo(t,e,null),e},t.prototype.remainder=function(t){var e=Tt();return this.divRemTo(t,null,e),e},t.prototype.divideAndRemainder=function(t){var e=Tt(),n=Tt();return this.divRemTo(t,e,n),[e,n]},t.prototype.modPow=function(t,e){var n,r,i=t.bitLength(),o=Dt(1);if(i<=0)return o;n=i<18?1:i<48?3:i<144?4:i<768?5:6,r=i<8?new mt(e):e.isEven()?new Et(e):new bt(e);var s=[],a=3,u=n-1,c=(1<<n)-1;if(s[1]=r.convert(this),n>1){var h=Tt();for(r.sqrTo(s[1],h);a<=c;)s[a]=Tt(),r.mulTo(h,s[a-2],s[a]),a+=2}var l,f,d=t.t-1,p=!0,g=Tt();for(i=At(t[d])-1;d>=0;){for(i>=u?l=t[d]>>i-u&c:(l=(t[d]&(1<<i+1)-1)<<u-i,d>0&&(l|=t[d-1]>>this.DB+i-u)),a=n;0==(1&l);)l>>=1,--a;if((i-=a)<0&&(i+=this.DB,--d),p)s[l].copyTo(o),p=!1;else{for(;a>1;)r.sqrTo(o,g),r.sqrTo(g,o),a-=2;a>0?r.sqrTo(o,g):(f=o,o=g,g=f),r.mulTo(g,s[l],o)}for(;d>=0&&0==(t[d]&1<<i);)r.sqrTo(o,g),f=o,o=g,g=f,--i<0&&(i=this.DB-1,--d)}return r.revert(o)},t.prototype.modInverse=function(e){var n=e.isEven();if(this.isEven()&&n||0==e.signum())return t.ZERO;for(var r=e.clone(),i=this.clone(),o=Dt(1),s=Dt(0),a=Dt(0),u=Dt(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),n?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(e,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;i.isEven();)i.rShiftTo(1,i),n?(a.isEven()&&u.isEven()||(a.addTo(this,a),u.subTo(e,u)),a.rShiftTo(1,a)):u.isEven()||u.subTo(e,u),u.rShiftTo(1,u);r.compareTo(i)>=0?(r.subTo(i,r),n&&o.subTo(a,o),s.subTo(u,s)):(i.subTo(r,i),n&&a.subTo(o,a),u.subTo(s,u))}return 0!=i.compareTo(t.ONE)?t.ZERO:u.compareTo(e)>=0?u.subtract(e):u.signum()<0?(u.addTo(e,u),u.signum()<0?u.add(e):u):u},t.prototype.pow=function(t){return this.exp(t,new yt)},t.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(e.compareTo(n)<0){var r=e;e=n,n=r}var i=e.getLowestSetBit(),o=n.getLowestSetBit();if(o<0)return e;for(i<o&&(o=i),o>0&&(e.rShiftTo(o,e),n.rShiftTo(o,n));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=n.getLowestSetBit())>0&&n.rShiftTo(i,n),e.compareTo(n)>=0?(e.subTo(n,e),e.rShiftTo(1,e)):(n.subTo(e,n),n.rShiftTo(1,n));return o>0&&n.lShiftTo(o,n),n},t.prototype.isProbablePrime=function(t){var e,n=this.abs();if(1==n.t&&n[0]<=pt[pt.length-1]){for(e=0;e<pt.length;++e)if(n[0]==pt[e])return!0;return!1}if(n.isEven())return!1;for(e=1;e<pt.length;){for(var r=pt[e],i=e+1;i<pt.length&&r<gt;)r*=pt[i++];for(r=n.modInt(r);e<i;)if(r%pt[e++]==0)return!1}return n.millerRabin(t)},t.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},t.prototype.fromInt=function(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},t.prototype.fromString=function(e,n){var r;if(16==n)r=4;else if(8==n)r=3;else if(256==n)r=8;else if(2==n)r=1;else if(32==n)r=5;else{if(4!=n)return void this.fromRadix(e,n);r=2}this.t=0,this.s=0;for(var i=e.length,o=!1,s=0;--i>=0;){var a=8==r?255&+e[i]:It(e,i);a<0?"-"==e.charAt(i)&&(o=!0):(o=!1,0==s?this[this.t++]=a:s+r>this.DB?(this[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this[this.t++]=a>>this.DB-s):this[this.t-1]|=a<<s,(s+=r)>=this.DB&&(s-=this.DB))}8==r&&0!=(128&+e[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),o&&t.ZERO.subTo(this,this)},t.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},t.prototype.dlShiftTo=function(t,e){var n;for(n=this.t-1;n>=0;--n)e[n+t]=this[n];for(n=t-1;n>=0;--n)e[n]=0;e.t=this.t+t,e.s=this.s},t.prototype.drShiftTo=function(t,e){for(var n=t;n<this.t;++n)e[n-t]=this[n];e.t=Math.max(this.t-t,0),e.s=this.s},t.prototype.lShiftTo=function(t,e){for(var n=t%this.DB,r=this.DB-n,i=(1<<r)-1,o=Math.floor(t/this.DB),s=this.s<<n&this.DM,a=this.t-1;a>=0;--a)e[a+o+1]=this[a]>>r|s,s=(this[a]&i)<<n;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()},t.prototype.rShiftTo=function(t,e){e.s=this.s;var n=Math.floor(t/this.DB);if(n>=this.t)e.t=0;else{var r=t%this.DB,i=this.DB-r,o=(1<<r)-1;e[0]=this[n]>>r;for(var s=n+1;s<this.t;++s)e[s-n-1]|=(this[s]&o)<<i,e[s-n]=this[s]>>r;r>0&&(e[this.t-n-1]|=(this.s&o)<<i),e.t=this.t-n,e.clamp()}},t.prototype.subTo=function(t,e){for(var n=0,r=0,i=Math.min(t.t,this.t);n<i;)r+=this[n]-t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r-=t[n],e[n++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[n++]=this.DV+r:r>0&&(e[n++]=r),e.t=n,e.clamp()},t.prototype.multiplyTo=function(e,n){var r=this.abs(),i=e.abs(),o=r.t;for(n.t=o+i.t;--o>=0;)n[o]=0;for(o=0;o<i.t;++o)n[o+r.t]=r.am(0,i[o],n,o,0,r.t);n.s=0,n.clamp(),this.s!=e.s&&t.ZERO.subTo(n,n)},t.prototype.squareTo=function(t){for(var e=this.abs(),n=t.t=2*e.t;--n>=0;)t[n]=0;for(n=0;n<e.t-1;++n){var r=e.am(n,e[n],t,2*n,0,1);(t[n+e.t]+=e.am(n+1,2*e[n],t,2*n+1,r,e.t-n-1))>=e.DV&&(t[n+e.t]-=e.DV,t[n+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(n,e[n],t,2*n,0,1)),t.s=0,t.clamp()},t.prototype.divRemTo=function(e,n,r){var i=e.abs();if(!(i.t<=0)){var o=this.abs();if(o.t<i.t)return null!=n&&n.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=Tt());var s=Tt(),a=this.s,u=e.s,c=this.DB-At(i[i.t-1]);c>0?(i.lShiftTo(c,s),o.lShiftTo(c,r)):(i.copyTo(s),o.copyTo(r));var h=s.t,l=s[h-1];if(0!=l){var f=l*(1<<this.F1)+(h>1?s[h-2]>>this.F2:0),d=this.FV/f,p=(1<<this.F1)/f,g=1<<this.F2,v=r.t,y=v-h,m=null==n?Tt():n;for(s.dlShiftTo(y,m),r.compareTo(m)>=0&&(r[r.t++]=1,r.subTo(m,r)),t.ONE.dlShiftTo(h,m),m.subTo(s,s);s.t<h;)s[s.t++]=0;for(;--y>=0;){var b=r[--v]==l?this.DM:Math.floor(r[v]*d+(r[v-1]+g)*p);if((r[v]+=s.am(0,b,r,y,0,h))<b)for(s.dlShiftTo(y,m),r.subTo(m,r);r[v]<--b;)r.subTo(m,r)}null!=n&&(r.drShiftTo(h,n),a!=u&&t.ZERO.subTo(n,n)),r.t=h,r.clamp(),c>0&&r.rShiftTo(c,r),a<0&&t.ZERO.subTo(r,r)}}},t.prototype.invDigit=function(){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},t.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},t.prototype.exp=function(e,n){if(e>4294967295||e<1)return t.ONE;var r=Tt(),i=Tt(),o=n.convert(this),s=At(e)-1;for(o.copyTo(r);--s>=0;)if(n.sqrTo(r,i),(e&1<<s)>0)n.mulTo(i,o,r);else{var a=r;r=i,i=a}return n.revert(r)},t.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},t.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),n=Math.pow(t,e),r=Dt(n),i=Tt(),o=Tt(),s="";for(this.divRemTo(r,i,o);i.signum()>0;)s=(n+o.intValue()).toString(t).substr(1)+s,i.divRemTo(r,i,o);return o.intValue().toString(t)+s},t.prototype.fromRadix=function(e,n){this.fromInt(0),null==n&&(n=10);for(var r=this.chunkSize(n),i=Math.pow(n,r),o=!1,s=0,a=0,u=0;u<e.length;++u){var c=It(e,u);c<0?"-"==e.charAt(u)&&0==this.signum()&&(o=!0):(a=n*a+c,++s>=r&&(this.dMultiply(i),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(n,s)),this.dAddOffset(a,0)),o&&t.ZERO.subTo(this,this)},t.prototype.fromNumber=function(e,n,r){if("number"==typeof n)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),W,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(n);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(t.ONE.shiftLeft(e-1),this);else{var i=[],o=7&e;i.length=1+(e>>3),n.nextBytes(i),o>0?i[0]&=(1<<o)-1:i[0]=0,this.fromString(i,256)}},t.prototype.bitwiseTo=function(t,e,n){var r,i,o=Math.min(t.t,this.t);for(r=0;r<o;++r)n[r]=e(this[r],t[r]);if(t.t<this.t){for(i=t.s&this.DM,r=o;r<this.t;++r)n[r]=e(this[r],i);n.t=this.t}else{for(i=this.s&this.DM,r=o;r<t.t;++r)n[r]=e(i,t[r]);n.t=t.t}n.s=e(this.s,t.s),n.clamp()},t.prototype.changeBit=function(e,n){var r=t.ONE.shiftLeft(e);return this.bitwiseTo(r,n,r),r},t.prototype.addTo=function(t,e){for(var n=0,r=0,i=Math.min(t.t,this.t);n<i;)r+=this[n]+t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r+=t[n],e[n++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[n++]=r:r<-1&&(e[n++]=this.DV+r),e.t=n,e.clamp()},t.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},t.prototype.dAddOffset=function(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]}},t.prototype.multiplyLowerTo=function(t,e,n){var r=Math.min(this.t+t.t,e);for(n.s=0,n.t=r;r>0;)n[--r]=0;for(var i=n.t-this.t;r<i;++r)n[r+this.t]=this.am(0,t[r],n,r,0,this.t);for(i=Math.min(t.t,e);r<i;++r)this.am(0,t[r],n,r,0,e-r);n.clamp()},t.prototype.multiplyUpperTo=function(t,e,n){--e;var r=n.t=this.t+t.t-e;for(n.s=0;--r>=0;)n[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)n[this.t+r-e]=this.am(e-r,t[r],n,0,0,this.t+r-e);n.clamp(),n.drShiftTo(1,n)},t.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,n=this.s<0?t-1:0;if(this.t>0)if(0==e)n=this[0]%t;else for(var r=this.t-1;r>=0;--r)n=(e*n+this[r])%t;return n},t.prototype.millerRabin=function(e){var n=this.subtract(t.ONE),r=n.getLowestSetBit();if(r<=0)return!1;var i=n.shiftRight(r);(e=e+1>>1)>pt.length&&(e=pt.length);for(var o=Tt(),s=0;s<e;++s){o.fromInt(pt[Math.floor(Math.random()*pt.length)]);var a=o.modPow(i,this);if(0!=a.compareTo(t.ONE)&&0!=a.compareTo(n)){for(var u=1;u++<r&&0!=a.compareTo(n);)if(0==(a=a.modPowInt(2,this)).compareTo(t.ONE))return!1;if(0!=a.compareTo(n))return!1}}return!0},t.prototype.square=function(){var t=Tt();return this.squareTo(t),t},t.prototype.gcda=function(t,e){var n=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(n.compareTo(r)<0){var i=n;n=r,r=i}var o=n.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)e(n);else{o<s&&(s=o),s>0&&(n.rShiftTo(s,n),r.rShiftTo(s,r));var a=function(){(o=n.getLowestSetBit())>0&&n.rShiftTo(o,n),(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),n.compareTo(r)>=0?(n.subTo(r,n),n.rShiftTo(1,n)):(r.subTo(n,r),r.rShiftTo(1,r)),n.signum()>0?setTimeout(a,0):(s>0&&r.lShiftTo(s,r),setTimeout((function(){e(r)}),0))};setTimeout(a,10)}},t.prototype.fromNumberAsync=function(e,n,r,i){if("number"==typeof n)if(e<2)this.fromInt(1);else{this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),W,this),this.isEven()&&this.dAddOffset(1,0);var o=this,s=function(){o.dAddOffset(2,0),o.bitLength()>e&&o.subTo(t.ONE.shiftLeft(e-1),o),o.isProbablePrime(n)?setTimeout((function(){i()}),0):setTimeout(s,0)};setTimeout(s,0)}else{var a=[],u=7&e;a.length=1+(e>>3),n.nextBytes(a),u>0?a[0]&=(1<<u)-1:a[0]=0,this.fromString(a,256)}},t}(),yt=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),mt=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,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),bt=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=Tt();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(vt.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=Tt();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 n=32767&t[e],r=n*this.mpl+((n*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[n=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[n]>=t.DV;)t[n]-=t.DV,t[++n]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),Et=function(){function t(t){this.m=t,this.r2=Tt(),this.q3=Tt(),vt.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=Tt();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,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function Tt(){return new vt(null)}function St(t,e){return new vt(t,e)}"Microsoft Internet Explorer"==(null===navigator||void 0===navigator?void 0:navigator.appName)?(vt.prototype.am=function(t,e,n,r,i,o){for(var s=32767&e,a=e>>15;--o>=0;){var u=32767&this[t],c=this[t++]>>15,h=a*u+c*s;i=((u=s*u+((32767&h)<<15)+n[r]+(1073741823&i))>>>30)+(h>>>15)+a*c+(i>>>30),n[r++]=1073741823&u}return i},ht=30):"Netscape"!=(null===navigator||void 0===navigator?void 0:navigator.appName)?(vt.prototype.am=function(t,e,n,r,i,o){for(;--o>=0;){var s=e*this[t++]+n[r]+i;i=Math.floor(s/67108864),n[r++]=67108863&s}return i},ht=26):(vt.prototype.am=function(t,e,n,r,i,o){for(var s=16383&e,a=e>>14;--o>=0;){var u=16383&this[t],c=this[t++]>>14,h=a*u+c*s;i=((u=s*u+((16383&h)<<14)+n[r]+i)>>28)+(h>>14)+a*c,n[r++]=268435455&u}return i},ht=28),vt.prototype.DB=ht,vt.prototype.DM=(1<<ht)-1,vt.prototype.DV=1<<ht,vt.prototype.FV=Math.pow(2,52),vt.prototype.F1=52-ht,vt.prototype.F2=2*ht-52;var _t,wt,Rt=[];for(_t="0".charCodeAt(0),wt=0;wt<=9;++wt)Rt[_t++]=wt;for(_t="a".charCodeAt(0),wt=10;wt<36;++wt)Rt[_t++]=wt;for(_t="A".charCodeAt(0),wt=10;wt<36;++wt)Rt[_t++]=wt;function It(t,e){var n=Rt[t.charCodeAt(e)];return null==n?-1:n}function Dt(t){var e=Tt();return e.fromInt(t),e}function At(t){var e,n=1;return 0!=(e=t>>>16)&&(t=e,n+=16),0!=(e=t>>8)&&(t=e,n+=8),0!=(e=t>>4)&&(t=e,n+=4),0!=(e=t>>2)&&(t=e,n+=2),0!=(e=t>>1)&&(t=e,n+=1),n}vt.ZERO=Dt(0),vt.ONE=Dt(1);var Ot,Ct,xt=function(){function t(){this.i=0,this.j=0,this.S=[]}return t.prototype.init=function(t){var e,n,r;for(e=0;e<256;++e)this.S[e]=e;for(n=0,e=0;e<256;++e)n=n+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[n],this.S[n]=r;this.i=0,this.j=0},t.prototype.next=function(){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]},t}(),Pt=256,Nt=null;if(null==Nt){Nt=[],Ct=0;var Ut=void 0;if((null===window||void 0===window?void 0:window.crypto)&&(null===window||void 0===window?void 0:window.crypto.getRandomValues)){var Lt=new Uint32Array(256);for(null===window||void 0===window||window.crypto.getRandomValues(Lt),Ut=0;Ut<Lt.length;++Ut)Nt[Ct++]=255&Lt[Ut]}var Vt=function(t){if(this.count=this.count||0,this.count>=256||Ct>=Pt)(null===window||void 0===window?void 0:window.removeEventListener)?null===window||void 0===window||window.removeEventListener("mousemove",Vt,!1):(null===window||void 0===window?void 0:window.detachEvent)&&(null===window||void 0===window||window.detachEvent("onmousemove",Vt));else try{var e=t.x+t.y;Nt[Ct++]=255&e,this.count+=1}catch(t){}};(null===window||void 0===window?void 0:window.addEventListener)?null===window||void 0===window||window.addEventListener("mousemove",Vt,!1):(null===window||void 0===window?void 0:window.attachEvent)&&(null===window||void 0===window||window.attachEvent("onmousemove",Vt))}function Bt(){if(null==Ot){for(Ot=new xt;Ct<Pt;){var t=Math.floor(65536*Math.random());Nt[Ct++]=255&t}for(Ot.init(Nt),Ct=0;Ct<Nt.length;++Ct)Nt[Ct]=0;Ct=0}return Ot.next()}var kt=function(){function t(){}return t.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=Bt()},t}(),qt=function(){function t(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}return t.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},t.prototype.doPrivate=function(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),n=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(n)<0;)e=e.add(this.p);return e.subtract(n).multiply(this.coeff).mod(this.p).multiply(this.q).add(n)},t.prototype.setPublic=function(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=St(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")},t.prototype.encrypt=function(t){var e=function(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var n=[],r=t.length-1;r>=0&&e>0;){var i=t.charCodeAt(r--);i<128?n[--e]=i:i>127&&i<2048?(n[--e]=63&i|128,n[--e]=i>>6|192):(n[--e]=63&i|128,n[--e]=i>>6&63|128,n[--e]=i>>12|224)}n[--e]=0;for(var o=new kt,s=[];e>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);n[--e]=s[0]}return n[--e]=2,n[--e]=0,new vt(n)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var n=this.doPublic(e);if(null==n)return null;var r=n.toString(16);return 0==(1&r.length)?r:"0"+r},t.prototype.encryptLong=function(t){var e=this,n=(this.n.bitLength()+7>>3)-11;try{var r="";return t.length>n?(t.match(/.{1,117}/g).forEach((function(t){var n=e.encrypt(t);r+=n})),X(r)):X(this.encrypt(t))}catch(t){return!1}},t.prototype.decryptLong=function(t){var e=this,n=this.n.bitLength()+7>>3;t=tt(t);try{if(t.length>n){var r="";return t.match(/.{1,256}/g).forEach((function(t){var n=e.decrypt(t);r+=n})),r}return this.decrypt(t)}catch(t){return!1}},t.prototype.setPrivate=function(t,e,n){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=St(t,16),this.e=parseInt(e,16),this.d=St(n,16)):console.error("Invalid RSA private key")},t.prototype.setPrivateEx=function(t,e,n,r,i,o,s,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=St(t,16),this.e=parseInt(e,16),this.d=St(n,16),this.p=St(r,16),this.q=St(i,16),this.dmp1=St(o,16),this.dmq1=St(s,16),this.coeff=St(a,16)):console.error("Invalid RSA private key")},t.prototype.generate=function(t,e){var n=new kt,r=t>>1;this.e=parseInt(e,16);for(var i=new vt(e,16);;){for(;this.p=new vt(t-r,1,n),0!=this.p.subtract(vt.ONE).gcd(i).compareTo(vt.ONE)||!this.p.isProbablePrime(10););for(;this.q=new vt(r,1,n),0!=this.q.subtract(vt.ONE).gcd(i).compareTo(vt.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(vt.ONE),a=this.q.subtract(vt.ONE),u=s.multiply(a);if(0==u.gcd(i).compareTo(vt.ONE)){this.n=this.p.multiply(this.q),this.d=i.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}},t.prototype.decrypt=function(t){var e=St(t,16),n=this.doPrivate(e);return null==n?null:function(t,e){for(var n=t.toByteArray(),r=0;r<n.length&&0==n[r];)++r;if(n.length-r!=e-1||2!=n[r])return null;for(++r;0!=n[r];)if(++r>=n.length)return null;for(var i="";++r<n.length;){var o=255&n[r];o<128?i+=String.fromCharCode(o):o>191&&o<224?(i+=String.fromCharCode((31&o)<<6|63&n[r+1]),++r):(i+=String.fromCharCode((15&o)<<12|(63&n[r+1])<<6|63&n[r+2]),r+=2)}return i}(n,this.n.bitLength()+7>>3)},t.prototype.generateAsync=function(t,e,n){var r=new kt,i=t>>1;this.e=parseInt(e,16);var o=new vt(e,16),s=this,a=function(){var e=function(){if(s.p.compareTo(s.q)<=0){var t=s.p;s.p=s.q,s.q=t}var e=s.p.subtract(vt.ONE),r=s.q.subtract(vt.ONE),i=e.multiply(r);0==i.gcd(o).compareTo(vt.ONE)?(s.n=s.p.multiply(s.q),s.d=o.modInverse(i),s.dmp1=s.d.mod(e),s.dmq1=s.d.mod(r),s.coeff=s.q.modInverse(s.p),setTimeout((function(){n()}),0)):setTimeout(a,0)},u=function(){s.q=Tt(),s.q.fromNumberAsync(i,1,r,(function(){s.q.subtract(vt.ONE).gcda(o,(function(t){0==t.compareTo(vt.ONE)&&s.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(u,0)}))}))},c=function(){s.p=Tt(),s.p.fromNumberAsync(t-i,1,r,(function(){s.p.subtract(vt.ONE).gcda(o,(function(t){0==t.compareTo(vt.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)}))}))};setTimeout(c,0)};setTimeout(a,0)},t.prototype.sign=function(t,e,n){var r=function(t,e){if(e<t.length+22)return console.error("Message too long for RSA"),null;for(var n=e-t.length-6,r="",i=0;i<n;i+=2)r+="ff";return St("0001"+r+"00"+t,16)}((Mt[n]||"")+e(t).toString(),this.n.bitLength()/4);if(null==r)return null;var i=this.doPrivate(r);if(null==i)return null;var o=i.toString(16);return 0==(1&o.length)?o:"0"+o},t.prototype.verify=function(t,e,n){var r=St(e,16),i=this.doPublic(r);return null==i?null:function(t){for(var e in Mt)if(Mt.hasOwnProperty(e)){var n=Mt[e],r=n.length;if(t.substr(0,r)==n)return t.substr(r)}return t}(i.toString(16).replace(/^1f+00/,""))==n(t).toString()},t}(),Mt={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"},Ht={};Ht.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var i;for(i in n)t.prototype[i]=n[i];var o=function(){},s=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(o=function(t,e){for(i=0;i<s.length;i+=1){var n=s[i],r=e[n];"function"==typeof r&&r!=Object.prototype[n]&&(t[n]=r)}})}catch(t){}o(t.prototype,n)}}};var jt={};void 0!==jt.asn1&&jt.asn1||(jt.asn1={}),jt.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var n=e.substr(1).length;n%2==1?n+=1:e.match(/^[0-7]/)||(n+=2);for(var r="",i=0;i<n;i++)r+="f";e=new vt(r,16).xor(t).add(vt.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=jt.asn1,n=e.DERBoolean,r=e.DERInteger,i=e.DERBitString,o=e.DEROctetString,s=e.DERNull,a=e.DERObjectIdentifier,u=e.DEREnumerated,c=e.DERUTF8String,h=e.DERNumericString,l=e.DERPrintableString,f=e.DERTeletexString,d=e.DERIA5String,p=e.DERUTCTime,g=e.DERGeneralizedTime,v=e.DERSequence,y=e.DERSet,m=e.DERTaggedObject,b=e.ASN1Util.newObject,E=Object.keys(t);if(1!=E.length)throw"key of param shall be only one.";var T=E[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+T+":"))throw"undefined key: "+T;if("bool"==T)return new n(t[T]);if("int"==T)return new r(t[T]);if("bitstr"==T)return new i(t[T]);if("octstr"==T)return new o(t[T]);if("null"==T)return new s(t[T]);if("oid"==T)return new a(t[T]);if("enum"==T)return new u(t[T]);if("utf8str"==T)return new c(t[T]);if("numstr"==T)return new h(t[T]);if("prnstr"==T)return new l(t[T]);if("telstr"==T)return new f(t[T]);if("ia5str"==T)return new d(t[T]);if("utctime"==T)return new p(t[T]);if("gentime"==T)return new g(t[T]);if("seq"==T){for(var S=t[T],_=[],w=0;w<S.length;w++){var R=b(S[w]);_.push(R)}return new v({array:_})}if("set"==T){for(S=t[T],_=[],w=0;w<S.length;w++)R=b(S[w]),_.push(R);return new y({array:_})}if("tag"==T){var I=t[T];if("[object Array]"===Object.prototype.toString.call(I)&&3==I.length){var D=b(I[2]);return new m({tag:I[0],explicit:I[1],obj:D})}var A={};if(void 0!==I.explicit&&(A.explicit=I.explicit),void 0!==I.tag&&(A.tag=I.tag),void 0===I.obj)throw"obj shall be specified for 'tag'.";return A.obj=b(I.obj),new m(A)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},jt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",n=parseInt(t.substr(0,2),16),r=(e=Math.floor(n/40)+"."+n%40,""),i=2;i<t.length;i+=2){var o=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);r+=o.substr(1,7),"0"==o.substr(0,1)&&(e=e+"."+new vt(r,2).toString(10),r="")}return e},jt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},n=function(t){var n="",r=new vt(t,10).toString(2),i=7-r.length%7;7==i&&(i=0);for(var o="",s=0;s<i;s++)o+="0";for(r=o+r,s=0;s<r.length-1;s+=7){var a=r.substr(s,7);s!=r.length-7&&(a="1"+a),n+=e(parseInt(a,2))}return n};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var r="",i=t.split("."),o=40*parseInt(i[0])+parseInt(i[1]);r+=e(o),i.splice(0,2);for(var s=0;s<i.length;s++)r+=n(i[s]);return r},jt.asn1.ASN1Object=function(){this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+"".length+",v="+this.hV;var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var n=e.length/2;if(n>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+n).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},jt.asn1.DERAbstractString=function(t){jt.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},Ht.lang.extend(jt.asn1.DERAbstractString,jt.asn1.ASN1Object),jt.asn1.DERAbstractTime=function(t){jt.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,n){var r=this.zeroPadding,i=this.localDateToUTC(t),o=String(i.getFullYear());"utc"==e&&(o=o.substr(2,2));var s=o+r(String(i.getMonth()+1),2)+r(String(i.getDate()),2)+r(String(i.getHours()),2)+r(String(i.getMinutes()),2)+r(String(i.getSeconds()),2);if(!0===n){var a=i.getMilliseconds();if(0!=a){var u=r(String(a),3);s=s+"."+(u=u.replace(/[0]+$/,""))}}return s+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,n,r,i,o){var s=new Date(Date.UTC(t,e-1,n,r,i,o,0));this.setByDate(s)},this.getFreshValueHex=function(){return this.hV}},Ht.lang.extend(jt.asn1.DERAbstractTime,jt.asn1.ASN1Object),jt.asn1.DERAbstractStructured=function(t){jt.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},Ht.lang.extend(jt.asn1.DERAbstractStructured,jt.asn1.ASN1Object),jt.asn1.DERBoolean=function(){jt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},Ht.lang.extend(jt.asn1.DERBoolean,jt.asn1.ASN1Object),jt.asn1.DERInteger=function(t){jt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=jt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new vt(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},Ht.lang.extend(jt.asn1.DERInteger,jt.asn1.ASN1Object),jt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=jt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}jt.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var n="0"+t;this.hTLV=null,this.isModified=!0,this.hV=n+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var n=0;n<=e;n++)t+="0";var r="";for(n=0;n<t.length-1;n+=8){var i=t.substr(n,8),o=parseInt(i,2).toString(16);1==o.length&&(o="0"+o),r+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",n=0;n<t.length;n++)1==t[n]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},Ht.lang.extend(jt.asn1.DERBitString,jt.asn1.ASN1Object),jt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=jt.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}jt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Ht.lang.extend(jt.asn1.DEROctetString,jt.asn1.DERAbstractString),jt.asn1.DERNull=function(){jt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Ht.lang.extend(jt.asn1.DERNull,jt.asn1.ASN1Object),jt.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},n=function(t){var n="",r=new vt(t,10).toString(2),i=7-r.length%7;7==i&&(i=0);for(var o="",s=0;s<i;s++)o+="0";for(r=o+r,s=0;s<r.length-1;s+=7){var a=r.substr(s,7);s!=r.length-7&&(a="1"+a),n+=e(parseInt(a,2))}return n};jt.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var r="",i=t.split("."),o=40*parseInt(i[0])+parseInt(i[1]);r+=e(o),i.splice(0,2);for(var s=0;s<i.length;s++)r+=n(i[s]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=r},this.setValueName=function(t){var e=jt.asn1.x509.OID.name2oid(t);if(""===e)throw"DERObjectIdentifier oidName undefined: "+t;this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t):void 0!==t.oid?this.setValueOidString(t.oid):void 0!==t.hex?this.setValueHex(t.hex):void 0!==t.name&&this.setValueName(t.name))},Ht.lang.extend(jt.asn1.DERObjectIdentifier,jt.asn1.ASN1Object),jt.asn1.DEREnumerated=function(t){jt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=jt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new vt(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},Ht.lang.extend(jt.asn1.DEREnumerated,jt.asn1.ASN1Object),jt.asn1.DERUTF8String=function(t){jt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Ht.lang.extend(jt.asn1.DERUTF8String,jt.asn1.DERAbstractString),jt.asn1.DERNumericString=function(t){jt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Ht.lang.extend(jt.asn1.DERNumericString,jt.asn1.DERAbstractString),jt.asn1.DERPrintableString=function(t){jt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Ht.lang.extend(jt.asn1.DERPrintableString,jt.asn1.DERAbstractString),jt.asn1.DERTeletexString=function(t){jt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Ht.lang.extend(jt.asn1.DERTeletexString,jt.asn1.DERAbstractString),jt.asn1.DERIA5String=function(t){jt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Ht.lang.extend(jt.asn1.DERIA5String,jt.asn1.DERAbstractString),jt.asn1.DERUTCTime=function(t){jt.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},Ht.lang.extend(jt.asn1.DERUTCTime,jt.asn1.DERAbstractTime),jt.asn1.DERGeneralizedTime=function(t){jt.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},Ht.lang.extend(jt.asn1.DERGeneralizedTime,jt.asn1.DERAbstractTime),jt.asn1.DERSequence=function(t){jt.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].getEncodedHex();return this.hV=t,this.hV}},Ht.lang.extend(jt.asn1.DERSequence,jt.asn1.DERAbstractStructured),jt.asn1.DERSet=function(t){jt.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var n=this.asn1Array[e];t.push(n.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},Ht.lang.extend(jt.asn1.DERSet,jt.asn1.DERAbstractStructured),jt.asn1.DERTaggedObject=function(t){jt.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,n){this.hT=e,this.isExplicit=t,this.asn1Object=n,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=n.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.tag&&(this.hT=t.tag),void 0!==t.explicit&&(this.isExplicit=t.explicit),void 0!==t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},Ht.lang.extend(jt.asn1.DERTaggedObject,jt.asn1.ASN1Object);var Ft=function(t){function e(t){void 0===t&&(t="");var e=this;return t&&("string"==typeof t?e.parseKey(t):(e.hasPrivateKeyProperty(t)||e.hasPublicKeyProperty(t))&&e.parsePropertiesFrom(t)),e}return j(e,t),e.prototype.parseKey=function(t){try{var e=0,n=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?function(t){var e;if(void 0===et){var n="0123456789ABCDEF",r=" \f\n\r\t \u2028\u2029";for(et={},e=0;e<16;++e)et[n.charAt(e)]=e;for(n=n.toLowerCase(),e=10;e<16;++e)et[n.charAt(e)]=e;for(e=0;e<r.length;++e)et[r.charAt(e)]=-1}var i=[],o=0,s=0;for(e=0;e<t.length;++e){var a=t.charAt(e);if("="==a)break;if(-1!=(a=et[a])){if(void 0===a)throw new Error("Illegal character at offset "+e);o|=a,++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}(t):rt.unarmor(t),i=ft.decode(r);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=St(e,16),n=i.sub[2].getHexStringValue(),this.e=parseInt(n,16);var o=i.sub[3].getHexStringValue();this.d=St(o,16);var s=i.sub[4].getHexStringValue();this.p=St(s,16);var a=i.sub[5].getHexStringValue();this.q=St(a,16);var u=i.sub[6].getHexStringValue();this.dmp1=St(u,16);var c=i.sub[7].getHexStringValue();this.dmq1=St(c,16);var h=i.sub[8].getHexStringValue();this.coeff=St(h,16)}else{if(2!==i.sub.length)return!1;var l=i.sub[1].sub[0];e=l.sub[0].getHexStringValue(),this.n=St(e,16),n=l.sub[1].getHexStringValue(),this.e=parseInt(n,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new jt.asn1.DERInteger({int:0}),new jt.asn1.DERInteger({bigint:this.n}),new jt.asn1.DERInteger({int:this.e}),new jt.asn1.DERInteger({bigint:this.d}),new jt.asn1.DERInteger({bigint:this.p}),new jt.asn1.DERInteger({bigint:this.q}),new jt.asn1.DERInteger({bigint:this.dmp1}),new jt.asn1.DERInteger({bigint:this.dmq1}),new jt.asn1.DERInteger({bigint:this.coeff})]};return new jt.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return X(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new jt.asn1.DERSequence({array:[new jt.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new jt.asn1.DERNull]}),e=new jt.asn1.DERSequence({array:[new jt.asn1.DERInteger({bigint:this.n}),new jt.asn1.DERInteger({int:this.e})]}),n=new jt.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new jt.asn1.DERSequence({array:[t,n]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return X(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(void 0===e&&(e=void 0),!t)return t;var n="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(n,"g")).join("\n")},e.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return(t+=e.wordwrap(this.getPrivateBaseKeyB64())+"\n")+"-----END RSA PRIVATE KEY-----"},e.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return(t+=e.wordwrap(this.getPublicBaseKeyB64())+"\n")+"-----END PUBLIC KEY-----"},e.prototype.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},e.prototype.hasPrivateKeyProperty=function(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")},e.prototype.parsePropertiesFrom=function(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)},e}(qt);function Gt(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}Gt.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new Ft(t)},Gt.prototype.setPrivateKey=function(t){this.setKey(t)},Gt.prototype.setPublicKey=function(t){this.setKey(t)},Gt.prototype.decrypt=function(t){try{return this.getKey().decrypt(tt(t))}catch(t){return!1}},Gt.prototype.encrypt=function(t){try{return X(this.getKey().encrypt(t))}catch(t){return!1}},Gt.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",n=this.getKey().decryptLong(e)||"",r=0,i=/null$/g;i.test(n)&&(r++,e=this.getKey().encryptLong(t)||"",n=this.getKey().decryptLong(e)||"",!(r>10)););return e}catch(t){return!1}},Gt.prototype.decryptLong=function(t){try{return this.getKey().decryptLong(t)}catch(t){return!1}},Gt.prototype.sign=function(t,e,n){try{return X(this.getKey().sign(t,e,n))}catch(t){return!1}},Gt.prototype.verify=function(t,e,n){try{return this.getKey().verify(t,tt(e),n)}catch(t){return!1}},Gt.prototype.getKey=function(t){if(!this.key){if(this.key=new Ft,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},Gt.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},Gt.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},Gt.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},Gt.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},Gt.version="3.1.4";const Kt=Gt;var Wt=function(t){var e=void 0===t?{}:t,n=e.publicKey,r=void 0===n?"":n,i=e.payload,o=void 0===i?{}:i;if(!r)return"";try{var s=y(o),a=new Kt;return a.setPublicKey(r),a.encryptLong(JSON.stringify(s))}catch(t){}return""},Yt=function(){return Yt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Yt.apply(this,arguments)},zt=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},Qt=function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=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++,r=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],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Zt=function(){function t(t){var e=t.request,n=t.credentialsClient;if(!n){var r={apiOrigin:t.apiOrigin,clientId:t.clientId,storage:t.storage,env:t.env,wxCloud:t.wxCloud};n=new U(r)}if(!e){var i=n.request.bind(n),o=new H(Yt({clientId:t.clientId,request:i,storage:t.storage},t.captchaOptions));e=o.request.bind(o)}this.config={env:t.env,apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:n,storage:t.storage||x}}return t.parseParamsToSearch=function(t){return Object.keys(t).forEach((function(e){t[e]||delete t[e]})),new URLSearchParams(t).toString()},t.prototype.getParamsByVersion=function(t,e){var n,r=y(t),i=(null===(n={v2:s}[null==r?void 0:r.version])||void 0===n?void 0:n[e])||o[e];return r&&delete r.version,{params:r,url:i}},t.prototype.signIn=function(t){return zt(this,void 0,void 0,(function(){var e,n,r,i;return Qt(this,(function(o){switch(o.label){case 0:return e=t.version||"v1",(n=this.getParamsByVersion(t,"AUTH_SIGN_IN_URL")).params.query&&delete n.params.query,[4,this.getEncryptParams(n.params)];case 1:return r=o.sent(),[4,this.config.request(n.url,{method:"POST",body:r})];case 2:return i=o.sent(),[4,this.config.credentialsClient.setCredentials(Yt(Yt({},i),{version:e}))];case 3:return o.sent(),[2,Promise.resolve(i)]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),zt(this,void 0,void 0,(function(){var e;return Qt(this,(function(n){switch(n.label){case 0:return[4,this.config.request(o.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signUp=function(t){return zt(this,void 0,void 0,(function(){var e;return Qt(this,(function(n){switch(n.label){case 0:return[4,this.config.request(o.AUTH_SIGN_UP_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signOut=function(){return zt(this,void 0,void 0,(function(){var t,e;return Qt(this,(function(n){switch(n.label){case 0:return[4,this.config.credentialsClient.getAccessToken()];case 1:return t=n.sent(),[4,this.config.request(o.AUTH_REVOKE_URL,{method:"POST",body:{token:t}})];case 2:return e=n.sent(),[4,this.config.credentialsClient.setCredentials()];case 3:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.getVerification=function(t){return zt(this,void 0,void 0,(function(){var e;return Qt(this,(function(n){switch(n.label){case 0:return e=!1,"CUR_USER"!==t.target?[3,1]:(e=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:n.sent()&&(e=!0),n.label=3;case 3:return[2,this.config.request(o.VERIFICATION_URL,{method:"POST",body:t,withCredentials:e})]}}))}))},t.prototype.verify=function(t){return zt(this,void 0,void 0,(function(){var e,n;return Qt(this,(function(r){switch(r.label){case 0:return e=this.getParamsByVersion(t,"VERIFY_URL"),[4,this.config.request(e.url,{method:"POST",body:e.params})];case 1:return n=r.sent(),"v2"!==(null==t?void 0:t.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(Yt(Yt({},n),{version:"v2"}))];case 2:r.sent(),r.label=3;case 3:return[2,n]}}))}))},t.prototype.genProviderRedirectUri=function(t){return zt(this,void 0,void 0,(function(){var e,n;return Qt(this,(function(r){return e="".concat(o.PROVIDER_URI_URL,"?client_id=").concat(this.config.clientId,"&provider_id=").concat(t.provider_id,"&redirect_uri=").concat(encodeURIComponent(t.provider_redirect_uri),"&state=").concat(t.state),(n=t.other_params)&&"string"==typeof n.sign_out_uri&&n.sign_out_uri.length>0&&(e+="&other_params[sign_out_uri]=".concat(n.sign_out_uri)),[2,this.config.request(e,{method:"GET"})]}))}))},t.prototype.grantProviderToken=function(t,e){return void 0===e&&(e=!1),zt(this,void 0,void 0,(function(){return Qt(this,(function(n){return[2,this.config.request(o.PROVIDER_TOKEN_URL,{method:"POST",body:t,useWxCloud:e})]}))}))},t.prototype.patchProviderToken=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request(o.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]}))}))},t.prototype.signInWithProvider=function(t,e){return void 0===e&&(e=!1),zt(this,void 0,void 0,(function(){var n,r;return Qt(this,(function(i){switch(i.label){case 0:return n=this.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(n.url,{method:"POST",body:n.params,useWxCloud:e})];case 1:return r=i.sent(),[4,this.config.credentialsClient.setCredentials(Yt(Yt({},r),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return i.sent(),[2,Promise.resolve(r)]}}))}))},t.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),zt(this,void 0,void 0,(function(){var e;return Qt(this,(function(n){switch(n.label){case 0:return[4,this.config.request(o.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.bindWithProvider=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request(o.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.getUserProfile=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.getUserInfo(t)]}))}))},t.prototype.getUserInfo=function(t){var e;return void 0===t&&(t={}),zt(this,void 0,void 0,(function(){var n,r,i;return Qt(this,(function(o){switch(o.label){case 0:return n=this.getParamsByVersion(t,"USER_ME_URL"),(null===(e=n.params)||void 0===e?void 0:e.query)&&(r=new URLSearchParams(n.params.query),n.url+="?".concat(r.toString())),[4,this.config.request(n.url,{method:"GET",withCredentials:!0})];case 1:return(i=o.sent()).sub&&(i.uid=i.sub),[2,i]}}))}))},t.prototype.getWedaUserInfo=function(){return zt(this,void 0,void 0,(function(){return Qt(this,(function(t){switch(t.label){case 0:return[4,this.config.request(o.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,t.sent()]}}))}))},t.prototype.deleteMe=function(e){return zt(this,void 0,void 0,(function(){var n,r;return Qt(this,(function(i){return n=this.getParamsByVersion(e,"USER_ME_URL"),r="".concat(n.url,"?").concat(t.parseParamsToSearch(n.params)),[2,this.config.request(r,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.hasLoginState=function(){return zt(this,void 0,void 0,(function(){return Qt(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},t.prototype.getLoginState=function(){return zt(this,void 0,void 0,(function(){return Qt(this,(function(t){return[2,this.config.credentialsClient.getCredentialsAsync()]}))}))},t.prototype.transByProvider=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request(o.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.grantToken=function(t){return zt(this,void 0,void 0,(function(){var e;return Qt(this,(function(n){return e=this.getParamsByVersion(t,"AUTH_TOKEN_URL"),[2,this.config.request(e.url,{method:"POST",body:e.params})]}))}))},t.prototype.getProviders=function(){return zt(this,void 0,void 0,(function(){return Qt(this,(function(t){return[2,this.config.request(o.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},t.prototype.unbindProvider=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request("".concat(o.PROVIDER_UNBIND_URL,"/").concat(t.provider_id),{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.checkPassword=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request("".concat(o.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.bindPhone=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request("".concat(o.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.bindEmail=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request("".concat(o.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.setPassword=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request("".concat(o.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.updatePasswordByOld=function(t){return zt(this,void 0,void 0,(function(){var e;return Qt(this,(function(n){switch(n.label){case 0:return[4,this.sudo({password:t.old_password})];case 1:return e=n.sent(),[2,this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})]}}))}))},t.prototype.sudo=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request("".concat(o.SUDO_URL),{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.getCurUserVerification=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return t.target="CUR_USER",[2,this.config.request(o.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]}))}))},t.prototype.changeBindedProvider=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request("".concat(o.PROVIDER_LIST,"/").concat(t.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})]}))}))},t.prototype.setUserProfile=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request(o.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.updateUserBasicInfo=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request(o.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.queryUserProfile=function(t){return zt(this,void 0,void 0,(function(){var e;return Qt(this,(function(n){return e=new URLSearchParams(t),[2,this.config.request("".concat(o.USER_QUERY_URL,"?").concat(e.toString()),{method:"GET",withCredentials:!0})]}))}))},t.prototype.setCustomSignFunc=function(t){this.getCustomSignTicketFn=t},t.prototype.signInWithCustomTicket=function(t){return zt(this,void 0,void 0,(function(){var e;return Qt(this,(function(n){switch(n.label){case 0:return[4,this.getCustomSignTicketFn()];case 1:return e=n.sent(),[2,this.signInWithProvider(Yt(Yt({},t),{provider_id:"custom",provider_token:e}))]}}))}))},t.prototype.resetPassword=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request(o.AUTH_RESET_PASSWORD,{method:"POST",body:t})]}))}))},t.prototype.deviceAuthorize=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request(o.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.checkUsername=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request(o.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]}))}))},t.prototype.checkIfUserExist=function(t){return zt(this,void 0,void 0,(function(){var e;return Qt(this,(function(n){return e=new URLSearchParams(t),[2,this.config.request("".concat(o.CHECK_IF_USER_EXIST,"?").concat(e.toString()),{method:"GET"})]}))}))},t.prototype.loginScope=function(){return zt(this,void 0,void 0,(function(){return Qt(this,(function(t){return[2,this.config.credentialsClient.getScope()]}))}))},t.prototype.loginGroups=function(){return zt(this,void 0,void 0,(function(){return Qt(this,(function(t){return[2,this.config.credentialsClient.getGroups()]}))}))},t.prototype.refreshTokenForce=function(t){return zt(this,void 0,void 0,(function(){var e;return Qt(this,(function(n){switch(n.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return e=n.sent(),[4,this.config.credentialsClient.refreshToken(Yt(Yt({},e),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return[2,n.sent()]}}))}))},t.prototype.getCredentials=function(){return zt(this,void 0,void 0,(function(){return Qt(this,(function(t){return[2,this.config.credentialsClient.getCredentials()]}))}))},t.prototype.getPublicKey=function(){return zt(this,void 0,void 0,(function(){return Qt(this,(function(t){return[2,this.config.request(s.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]}))}))},t.prototype.getEncryptParams=function(t){return zt(this,void 0,void 0,(function(){var e,n,r,i;return Qt(this,(function(o){switch(o.label){case 0:if(!(e=y(t)).isEncrypt)return[2,t];n="",r="",o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.getPublicKey()];case 2:return i=o.sent(),n=i.public_key,r=i.public_key_thumbprint,[3,4];case 3:return o.sent(),[3,4];case 4:if(!n||!r)throw new Error("public_key or public_key_thumbprint is empty");return delete e.isEncrypt,[2,{params:Wt({publicKey:n,payload:e}),public_key_thumbprint:r}]}}))}))},t.prototype.getProviderSubType=function(){return zt(this,void 0,void 0,(function(){return Qt(this,(function(t){return[2,this.config.request(o.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})]}))}))},t.prototype.verifyCaptchaData=function(t){var e=t.token,n=t.key;return zt(this,void 0,void 0,(function(){return Qt(this,(function(t){return[2,this.config.request(o.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:e,key:n},withCredentials:!1})]}))}))},t.prototype.createCaptchaData=function(t){var e=t.state,n=t.redirect_uri,r=void 0===n?void 0:n;return zt(this,void 0,void 0,(function(){return Qt(this,(function(t){return[2,this.config.request(o.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:r},withCredentials:!1})]}))}))},t.prototype.getMiniProgramCode=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request(o.GET_MINIPROGRAM_QRCODE,{method:"POST",body:t})]}))}))},t.prototype.checkMiniProgramCode=function(t){return zt(this,void 0,void 0,(function(){return Qt(this,(function(e){return[2,this.config.request(o.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:t})]}))}))},t}(),Jt=function(){},$t=function(){return $t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},$t.apply(this,arguments)},Xt=function(t){var e=t.apiOrigin,n=t.clientId,r=t.env,i=t.storage,o=t.request,s=t.baseRequest,a=t.anonymousSignInFunc,u=t.wxCloud;this.oauth2client=new U({apiOrigin:e,clientId:n,env:r,storage:i,baseRequest:s||o,anonymousSignInFunc:a,wxCloud:u}),this.authApi=new Zt($t($t({credentialsClient:this.oauth2client},t),{request:o?this.oauth2client.request.bind(this.oauth2client):void 0}))}},118:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(549),e)}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={exports:{}};return t[r].call(o.exports,o,o.exports,n),o.exports}return n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(118)})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_oauth",[],e):"object"==typeof exports?exports.cloudbase_oauth=e():t.cloudbase_oauth=e()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var t={256:(t,e,r)=>{r.r(e),r.d(e,{Auth:()=>A,CloudbaseOAuth:()=>O,authModels:()=>u});var i,s,n,o,a,h,u={};function c(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}r.r(u),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"}(i||(i={})),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"}(s||(s={})),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"}(n||(n={})),(h=o||(o={})).UNREACHABLE="unreachable",h.LOCAL="local",h.CANCELLED="cancelled",h.UNKNOWN="unknown",h.UNAUTHENTICATED="unauthenticated",h.RESOURCE_EXHAUSTED="resource_exhausted",h.FAILED_PRECONDITION="failed_precondition",h.INVALID_ARGUMENT="invalid_argument",h.DEADLINE_EXCEEDED="deadline_exceeded",h.NOT_FOUND="not_found",h.ALREADY_EXISTS="already_exists",h.PERMISSION_DENIED="permission_denied",h.ABORTED="aborted",h.OUT_OF_RANGE="out_of_range",h.UNIMPLEMENTED="unimplemented",h.INTERNAL="internal",h.UNAVAILABLE="unavailable",h.DATA_LOSS="data_loss",h.INVALID_PASSWORD="invalid_password",h.PASSWORD_NOT_SET="password_not_set",h.INVALID_STATUS="invalid_status",h.USER_PENDING="user_pending",h.USER_BLOCKED="user_blocked",h.INVALID_VERIFICATION_CODE="invalid_verification_code",h.TWO_FACTOR_REQUIRED="two_factor_required",h.INVALID_TWO_FACTOR="invalid_two_factor",h.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",h.UNDER_REVIEW="under_review",h.INVALID_REQUEST="invalid_request",h.UNAUTHORIZED_CLIENT="unauthorized_client",h.ACCESS_DENIED="access_denied",h.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",h.INVALID_SCOPE="invalid_scope",h.INVALID_GRANT="invalid_grant",h.SERVER_ERROR="server_error",h.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",h.INTERACTION_REQUIRED="interaction_required",h.LOGIN_REQUIRED="login_required",h.ACCOUNT_SELECTION_REQUIRED="account_selection_required",h.CONSENT_REQUIRED="consent_required",h.INVALID_REQUEST_URI="invalid_request_uri",h.INVALID_REQUEST_OBJECT="invalid_request_object",h.REQUEST_NOT_SUPPORTED="request_not_supported",h.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",h.REGISTRATION_NOT_SUPPORTED="registration_not_supported",h.CAPTCHA_REQUIRED="captcha_required",h.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 l=r(479);class d{constructor(){this.fnPromiseMap=new Map}async run(t,e){let r=this.fnPromiseMap.get(t);return await r||(r=new Promise(((r,i)=>{(async()=>{try{await this.runIdlePromise();const t=e();r(await t)}catch(t){i(t)}finally{this.fnPromiseMap.delete(t)}})()})),this.fnPromiseMap.set(t,r)),r}runIdlePromise(){return Promise.resolve()}}const f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",g="x-request-id",p="x-device-id",m="device_id",_=async function(t,e){let r=null,i=null;try{const s=Object.assign({},e);s.method||(s.method="GET"),s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));const n=await fetch(t,s),o=await n.json();o?.error?(i=o,i.error_uri=new URL(t).pathname):r=o}catch(e){i={error:o.UNREACHABLE,error_description:e.message,error_uri:new URL(t).pathname}}if(i)throw i;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 v(t){let e=!0;return t?.expires_at&&t?.access_token&&(e=t.expires_at<new Date),e}class T{constructor(t){this.credentials=null,this.singlePromise=new d,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()=>(v(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 E{constructor(t){this.singlePromise=new d,this.apiOrigin=t.apiOrigin,this.clientId=t.clientId,this.retry=this.formatRetry(t.retry,E.defaultRetry),t.baseRequest?this.baseRequest=t.baseRequest:this.baseRequest=_,this.tokenInURL=t.tokenInURL,this.headers=t.headers,this.storage=t.storage||y,this.localCredentials=new T({tokenSectionName:`credentials_${t.clientId}`,storage:this.storage}),this.clientSecret=t.clientSecret,""!==t.clientId&&(this.basicAuth=`Basic ${function(t){let e,r,i,s,n="",o=0;const a=(t=String(t)).length%3;for(;o<t.length;){if((r=t.charCodeAt(o++))>255||(i=t.charCodeAt(o++))>255||(s=t.charCodeAt(o++))>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|i<<8|s,n+=f.charAt(e>>18&63)+f.charAt(e>>12&63)+f.charAt(e>>6&63)+f.charAt(63&e)}return a?n.slice(0,a-3)+"===".substring(a):n}(`${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:o.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[g]||(e.headers[g]=c()),!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 i=null;const s=r+1;for(let n=0;n<s;n++){try{i=e.useWxCloud?await this.wxCloudCallFunction(t,e):await this.baseRequest(t,e);break}catch(t){if(e.withCredentials&&t&&t.error===o.UNAUTHENTICATED)return await this.setCredentials(null),Promise.reject(t);if(n===r||!t||"unreachable"!==t.error)return Promise.reject(t)}await this.sleep(E.retryInterval)}return i}async wxCloudCallFunction(t,e){let r=null,i=null;try{const{result:s}=await this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:t,method:e.method,headers:{origin:"https://servicewechat.com",...e.headers},body:e.body}});s?.body?.error_code?(i=s?.body,i.error_uri=(0,l.y)(t)):r=s?.body}catch(e){i={error:o.UNREACHABLE,error_description:e.message,error_uri:(0,l.y)(t)}}if(i)throw i;return r}async getCredentials(){let t=await this.localCredentials.getCredentials();return t?(v(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===o.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<E.minRetry||t>E.maxRetry)&&(e={error:o.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(i.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}});return await this.localCredentials.setCredentials(t),t}catch(t){return t.error===o.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=i.AUTH_TOKEN_URL;return"v2"===e?.version&&(r=s.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(m);return"string"==typeof t&&t.length>=16&&t.length<=48||(t=c(),await this.storage.setItem(m,t)),this.deviceID=t,t}unAuthenticatedError(t){const e={error:o.UNAUTHENTICATED,error_description:t};return Promise.reject(e)}}function S(){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}E.defaultRetry=2,E.minRetry=0,E.maxRetry=5,E.retryInterval=1e3;let w=!1;function I(){w=w||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{S()||(w=w||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?I():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",I,!1))}catch(t){}function R(){return w}class b{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 i,s=t;e.withCaptcha&&(s=await this.appendCaptchaTokenToURL(t,r,!1));try{i=await this.config.request(s,e)}catch(i){return i.error===o.CAPTCHA_REQUIRED||i.error===o.CAPTCHA_INVALID?(t=await this.appendCaptchaTokenToURL(t,r,i.error===o.CAPTCHA_INVALID),this.config.request(t,e)):Promise.reject(i)}return i}getDefaultOpenURIWithCallback(){if(!S()&&!R()&&(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:i="355px"}=e||{};if(t.match(/^(data:.*)$/))return Promise.reject({error:o.UNIMPLEMENTED,error_description:"need to impl captcha data"});const s=document.getElementById("captcha_panel_wrap"),n=document.createElement("iframe");return s.innerHTML="",n.setAttribute("src",t),n.setAttribute("id","review-panel-iframe"),n.style.cssText=`min-width:${r};display:block;height:${i};margin:0 auto;background-color: rgb(255, 255, 255);border: none;`,s.appendChild(n),s.style.display="block",new Promise(((t,e)=>{n.onload=function(){try{const r=window.location,i=n.contentWindow.location;if(i.host+i.pathname===r.host+r.pathname){s.style.display="none";const r=new URLSearchParams(i.search),n=r.get("captcha_token");return n?t({captcha_token:n,expires_in:Number(r.get("expires_in"))}):e({error:r.get("error"),error_description:r.get("error_description")})}s.style.display="block"}catch(t){s.style.display="block"}}}))}async getCaptchaToken(t,e){if(!t){const t=await this.findCaptchaToken();if(t)return t}let r;if(S()||R()){const t=await this.config.request(i.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(i.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 s=await this.config.openURIWithCallback(r.url);return this.saveCaptchaToken(s),s.captcha_token}async appendCaptchaTokenToURL(t,e,r){const i=await this.getCaptchaToken(r,e);return t.indexOf("?")>0?t+=`&captcha_token=${i}`:t+=`?captcha_token=${i}`,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 C(t){if(!globalThis.IS_MP_BUILD&&t)return r(443)}class A{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 E(e)}if(!e){const i=r.request.bind(r),s=new b({clientId:t.clientId,request:i,storage:t.storage,...t.captchaOptions});e=s.request.bind(s)}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,l.I)(t),n={v2:s}[r?.version]?.[e]||i[e];return r&&delete r.version,{params:r,url:n}}async signIn(t){const e=t.version||"v1",r=this.getParamsByVersion(t,"AUTH_SIGN_IN_URL");r.params.query&&delete r.params.query;const i=await this.getEncryptParams(r.params),s=await this.config.request(r.url,{method:"POST",body:i});return await this.config.credentialsClient.setCredentials({...s,version:e}),Promise.resolve(s)}async signInAnonymously(t={}){const e=await this.config.request(i.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(i.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(i.AUTH_REVOKE_URL,{method:"POST",body:{token:t}});return await this.config.credentialsClient.setCredentials(),Promise.resolve(e)}async revokeAllDevices(){await this.config.request(i.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})}async revokeDevice(t){await this.config.request(i.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(i.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=`${i.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(i.PROVIDER_TOKEN_URL,{method:"POST",body:t,useWxCloud:e})}async patchProviderToken(t){return this.config.request(i.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})}async signInWithProvider(t,e=!1){const r=this.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),i=await this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:e});return await this.config.credentialsClient.setCredentials({...i,version:t?.version||"v1"}),Promise.resolve(i)}async signInWithWechat(t={}){const e=await this.config.request(i.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(i.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(i.WEDA_USER_URL,{method:"GET",withCredentials:!0})}async deleteMe(t){const e=this.getParamsByVersion(t,"USER_ME_URL"),r=`${e.url}?${A.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(i.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(i.PROVIDER_LIST,{method:"GET",withCredentials:!0})}async unbindProvider(t){return this.config.request(`${i.PROVIDER_UNBIND_URL}/${t.provider_id}`,{method:"DELETE",withCredentials:!0})}async checkPassword(t){return this.config.request(`${i.CHECK_PWD_URL}`,{method:"POST",withCredentials:!0,body:t})}async editContact(t){return this.config.request(`${i.BIND_CONTACT_URL}`,{method:"PATCH",withCredentials:!0,body:t})}async setPassword(t){return this.config.request(`${i.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(`${i.SUDO_URL}`,{method:"POST",withCredentials:!0,body:t})}async sendVerificationCodeToCurrentUser(t){return t.target="CUR_USER",this.config.request(i.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})}async changeBoundProvider(t){return this.config.request(`${i.PROVIDER_LIST}/${t.provider_id}/trans`,{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})}async setUserProfile(t){return this.config.request(i.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})}async updateUserBasicInfo(t){return this.config.request(i.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:t})}async queryUserProfile(t){const e=new URLSearchParams(t);return this.config.request(`${i.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(i.AUTH_RESET_PASSWORD,{method:"POST",body:t})}async authorize(t){return this.config.request(i.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:t})}async authorizeDevice(t){return this.config.request(i.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:t})}async deviceAuthorize(t){return this.config.request(i.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})}async authorizeInfo(t){const e=`${i.AUTHORIZE_INFO_URL}?${A.parseParamsToSearch(t)}`;let r=!0,s=!1;return await this.hasLoginState()&&(s=!0,r=!1),this.config.request(e,{method:"GET",withBasicAuth:r,withCredentials:s})}async checkUsername(t){return this.config.request(i.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})}async checkIfUserExist(t){const e=new URLSearchParams(t);return this.config.request(`${i.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(s.AUTH_PUBLIC_KEY,{method:"POST",body:{}})}async getEncryptParams(t){const{isEncrypt:e}=t;delete t.isEncrypt;const r=(0,l.I)(t),i=C(e);if(!i)return t;let s="",n="";try{const t=await this.getPublicKey();s=t.public_key,n=t.public_key_thumbprint}catch(t){}if(!s||!n)throw new Error("public_key or public_key_thumbprint is empty");return{params:i.getEncryptInfo({publicKey:s,payload:r}),public_key_thumbprint:n}}async getProviderSubType(){return this.config.request(i.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})}async verifyCaptchaData({token:t,key:e}){return this.config.request(i.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:e},withCredentials:!1})}async createCaptchaData({state:t,redirect_uri:e}){return this.config.request(i.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:e},withCredentials:!1})}async getMiniProgramCode(t){return this.config.request(i.GET_MINIPROGRAM_QRCODE,{method:"POST",body:t})}async getMiniProgramQrCodeStatus(t){return this.config.request(i.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:t})}async getUserBehaviorLog(t){const e=`${i.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 s=C(!0);if(!s)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 n=t.password?s.getEncryptInfo({publicKey:e,payload:t.password}):"",o=s.getEncryptInfo({publicKey:e,payload:t.new_password});return this.config.request(i.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:t.user_id,encrypt_password:n,encrypt_new_password:o,public_key_thumbprint:r}})}}class O{constructor(t){const{apiOrigin:e,clientId:r,env:i,storage:s,request:n,baseRequest:o,anonymousSignInFunc:a,wxCloud:h}=t;this.oauth2client=new E({apiOrigin:e,clientId:r,env:i,storage:s,baseRequest:o||n,anonymousSignInFunc:a,wxCloud:h}),this.authApi=new A({credentialsClient:this.oauth2client,...t,request:n?this.oauth2client.request.bind(this.oauth2client):void 0})}}},443:(t,e,r)=>{let i;if(r.r(e),r.d(e,{getEncryptInfo:()=>L}),!globalThis.IS_MP_BUILD){const x="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;var s="0123456789abcdefghijklmnopqrstuvwxyz";function k(t){return s.charAt(t)}function q(t,e){return t&e}function B(t,e){return t|e}function V(t,e){return t^e}function H(t,e){return t&~e}function M(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 G(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o="=";function F(t){var e,r,i="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),i+=n.charAt(r>>6)+n.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),i+=n.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),i+=n.charAt(r>>2)+n.charAt((3&r)<<4));(3&i.length)>0;)i+=o;return i}function $(t){var e,r="",i=0,s=0;for(e=0;e<t.length&&t.charAt(e)!=o;++e){var a=n.indexOf(t.charAt(e));a<0||(0==i?(r+=k(a>>2),s=3&a,i=1):1==i?(r+=k(s<<2|a>>4),s=15&a,i=2):2==i?(r+=k(s),r+=k(a>>2),s=3&a,i=3):(r+=k(s<<2|a>>4),r+=k(15&a),i=0))}return 1==i&&(r+=k(s<<2)),r}var a,h,u={decode:function(t){var e;if(void 0===a){var r="0123456789ABCDEF",i=" \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<i.length;++e)a[i.charAt(e)]=-1}var s=[],n=0,o=0;for(e=0;e<t.length;++e){var h=t.charAt(e);if("="==h)break;if(-1!=(h=a[h])){if(void 0===h)throw new Error("Illegal character at offset "+e);n|=h,++o>=2?(s[s.length]=n,n=0,o=0):n<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return s}},c={decode:function(t){var e;if(void 0===h){var r="= \f\n\r\t \u2028\u2029";for(h=Object.create(null),e=0;e<64;++e)h["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<r.length;++e)h[r.charAt(e)]=-1}var i=[],s=0,n=0;for(e=0;e<t.length;++e){var o=t.charAt(e);if("="==o)break;if(-1!=(o=h[o])){if(void 0===o)throw new Error("Illegal character at offset "+e);s|=o,++n>=4?(i[i.length]=s>>16,i[i.length]=s>>8&255,i[i.length]=255&s,s=0,n=0):s<<=6}}switch(n){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:i[i.length]=s>>10;break;case 3:i[i.length]=s>>16,i[i.length]=s>>8&255}return i},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=c.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 c.decode(t)}},l=1e13;class K{constructor(t){this.buf=[+t||0]}mulAdd(t,e){var r,i,s=this.buf,n=s.length;for(r=0;r<n;++r)(i=s[r]*t+e)<l?e=0:i-=(e=0|i/l)*l,s[r]=i;e>0&&(s[r]=e)}sub(t){var e,r,i=this.buf,s=i.length;for(e=0;e<s;++e)(r=i[e]-t)<0?(r+=l,t=1):t=0,i[e]=r;for(;0===i[i.length-1];)i.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(),i=e.length-2;i>=0;--i)r+=(l+e[i]).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="…",g=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,p=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function W(t,e){return t.length>e&&(t=t.substring(0,e)+f),t}class j{constructor(t,e){this.hexDigits="0123456789ABCDEF",t instanceof j?(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 i="",s=t;s<e;++s)if(i+=this.hexByte(this.get(s)),!0!==r)switch(15&s){case 7:i+=" ";break;case 15:i+="\n";break;default:i+=" "}return i}isASCII(t,e){for(var r=t;r<e;++r){var i=this.get(r);if(i<32||i>176)return!1}return!0}parseStringISO(t,e){for(var r="",i=t;i<e;++i)r+=String.fromCharCode(this.get(i));return r}parseStringUTF(t,e){for(var r="",i=t;i<e;){var s=this.get(i++);r+=s<128?String.fromCharCode(s):s>191&&s<224?String.fromCharCode((31&s)<<6|63&this.get(i++)):String.fromCharCode((15&s)<<12|(63&this.get(i++))<<6|63&this.get(i++))}return r}parseStringBMP(t,e){for(var r,i,s="",n=t;n<e;)r=this.get(n++),i=this.get(n++),s+=String.fromCharCode(r<<8|i);return s}parseTime(t,e,r){var i=this.parseStringISO(t,e),s=(r?g:p).exec(i);return s?(r&&(s[1]=+s[1],s[1]+=+s[1]<70?2e3:1900),i=s[1]+"-"+s[2]+"-"+s[3]+" "+s[4],s[5]&&(i+=":"+s[5],s[6]&&(i+=":"+s[6],s[7]&&(i+="."+s[7]))),s[8]&&(i+=" UTC","Z"!=s[8]&&(i+=s[8],s[9]&&(i+=":"+s[9]))),i):"Unrecognized time: "+i}parseInteger(t,e){for(var r,i=this.get(t),s=i>127,n=s?255:0,o="";i==n&&++t<e;)i=this.get(t);if(0==(r=e-t))return s?-1:0;if(r>4){for(o=i,r<<=3;0==(128&(+o^n));)o=+o<<1,--r;o="("+r+" bit)\n"}s&&(i-=256);for(var a=new K(i),h=t+1;h<e;++h)a.mulAdd(256,this.get(h));return o+a.toString()}parseBitString(t,e,r){for(var i=this.get(t),s="("+((e-t-1<<3)-i)+" bit)\n",n="",o=t+1;o<e;++o){for(var a=this.get(o),h=o==e-1?i:0,u=7;u>=h;--u)n+=a>>u&1?"1":"0";if(n.length>r)return s+W(n,r)}return s+n}parseOctetString(t,e,r){if(this.isASCII(t,e))return W(this.parseStringISO(t,e),r);var i=e-t,s="("+i+" byte)\n";i>(r/=2)&&(e=t+r);for(var n=t;n<e;++n)s+=this.hexByte(this.get(n));return i>r&&(s+=f),s}parseOID(t,e,r){for(var i="",s=new K,n=0,o=t;o<e;++o){var a=this.get(o);if(s.mulAdd(128,127&a),n+=7,!(128&a)){if(""===i)if((s=s.simplify())instanceof K)s.sub(80),i="2."+s.toString();else{var h=s<80?s<40?0:1:2;i=h+"."+(s-40*h)}else i+="."+s.toString();if(i.length>r)return W(i,r);s=new K,n=0}}return n>0&&(i+=".incomplete"),i}}class Y{constructor(t,e,r,i,s){if(!(i instanceof z))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=i,this.sub=s}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 W(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return W(this.stream.parseStringISO(e,e+r),t);case 30:return W(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,i=this.sub.length;r<i;++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 i=0;i<r;++i)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 j?t:new j(t,0);var r=new j(e),i=new z(e),s=Y.decodeLength(e),n=e.pos,o=n-r.pos,a=null,h=function(){var t=[];if(null!==s){for(var r=n+s;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 "+n)}else try{for(;;){var i=Y.decode(e);if(i.tag.isEOC())break;t[t.length]=i}s=n-e.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(i.tagConstructed)a=h();else if(i.isUniversal()&&(3==i.tagNumber||4==i.tagNumber))try{if(3==i.tagNumber&&0!=e.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=h();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===s)throw new Error("We can't skip over an invalid tag with undefined length at offset "+n);e.pos=n+Math.abs(s)}return new Y(r,o,s,i,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 K;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 m=[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],_=(1<<26)/m[m.length-1];class Z{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,i=(1<<e)-1,s=!1,n="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(s=!0,n=k(r));o>=0;)a<e?(r=(this[o]&(1<<a)-1)<<e-a,r|=this[--o]>>(a+=this.DB-e)):(r=this[o]>>(a-=e)&i,a<=0&&(a+=this.DB,--o)),r>0&&(s=!0),s&&(n+=k(r));return s?n:"0"}negate(){var t=Q();return Z.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)+st(this[this.t-1]^this.s&this.DM)}mod(t){var e=Q();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(Z.ZERO)>0&&t.subTo(e,e),e}modPowInt(t,e){var r;return r=t<256||e.isEven()?new v(e):new T(e),this.exp(t,r)}clone(){var t=Q();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,i=this.DB-t*this.DB%8,s=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[s++]=r|this.s<<this.DB-i);t>=0;)i<8?(r=(this[t]&(1<<i)-1)<<8-i,r|=this[--t]>>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==s&&(128&this.s)!=(128&r)&&++s,(s>0||r!=this.s)&&(e[s++]=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=Q();return this.bitwiseTo(t,q,e),e}or(t){var e=Q();return this.bitwiseTo(t,B,e),e}xor(t){var e=Q();return this.bitwiseTo(t,V,e),e}andNot(t){var e=Q();return this.bitwiseTo(t,H,e),e}not(){for(var t=Q(),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=Q();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}shiftRight(t){var e=Q();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+M(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+=G(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,B)}clearBit(t){return this.changeBit(t,H)}flipBit(t){return this.changeBit(t,V)}add(t){var e=Q();return this.addTo(t,e),e}subtract(t){var e=Q();return this.subTo(t,e),e}multiply(t){var e=Q();return this.multiplyTo(t,e),e}divide(t){var e=Q();return this.divRemTo(t,e,null),e}remainder(t){var e=Q();return this.divRemTo(t,null,e),e}divideAndRemainder(t){var e=Q(),r=Q();return this.divRemTo(t,e,r),[e,r]}modPow(t,e){var r,i,s=t.bitLength(),n=it(1);if(s<=0)return n;r=s<18?1:s<48?3:s<144?4:s<768?5:6,i=s<8?new v(e):e.isEven()?new E(e):new T(e);var o=[],a=3,h=r-1,u=(1<<r)-1;if(o[1]=i.convert(this),r>1){var c=Q();for(i.sqrTo(o[1],c);a<=u;)o[a]=Q(),i.mulTo(c,o[a-2],o[a]),a+=2}var l,d,f=t.t-1,g=!0,p=Q();for(s=st(t[f])-1;f>=0;){for(s>=h?l=t[f]>>s-h&u:(l=(t[f]&(1<<s+1)-1)<<h-s,f>0&&(l|=t[f-1]>>this.DB+s-h)),a=r;0==(1&l);)l>>=1,--a;if((s-=a)<0&&(s+=this.DB,--f),g)o[l].copyTo(n),g=!1;else{for(;a>1;)i.sqrTo(n,p),i.sqrTo(p,n),a-=2;a>0?i.sqrTo(n,p):(d=n,n=p,p=d),i.mulTo(p,o[l],n)}for(;f>=0&&0==(t[f]&1<<s);)i.sqrTo(n,p),d=n,n=p,p=d,--s<0&&(s=this.DB-1,--f)}return i.revert(n)}modInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return Z.ZERO;for(var r=t.clone(),i=this.clone(),s=it(1),n=it(0),o=it(0),a=it(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(s.isEven()&&n.isEven()||(s.addTo(this,s),n.subTo(t,n)),s.rShiftTo(1,s)):n.isEven()||n.subTo(t,n),n.rShiftTo(1,n);for(;i.isEven();)i.rShiftTo(1,i),e?(o.isEven()&&a.isEven()||(o.addTo(this,o),a.subTo(t,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(i)>=0?(r.subTo(i,r),e&&s.subTo(o,s),n.subTo(a,n)):(i.subTo(r,i),e&&o.subTo(s,o),a.subTo(n,a))}return 0!=i.compareTo(Z.ONE)?Z.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 y)}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 i=e;e=r,r=i}var s=e.getLowestSetBit(),n=r.getLowestSetBit();if(n<0)return e;for(s<n&&(n=s),n>0&&(e.rShiftTo(n,e),r.rShiftTo(n,r));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return n>0&&r.lShiftTo(n,r),r}isProbablePrime(t){var e,r=this.abs();if(1==r.t&&r[0]<=m[m.length-1]){for(e=0;e<m.length;++e)if(r[0]==m[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<m.length;){for(var i=m[e],s=e+1;s<m.length&&i<_;)i*=m[s++];for(i=r.modInt(i);e<s;)if(i%m[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 i=t.length,s=!1,n=0;--i>=0;){var o=8==r?255&+t[i]:rt(t,i);o<0?"-"==t.charAt(i)&&(s=!0):(s=!1,0==n?this[this.t++]=o:n+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-n)-1)<<n,this[this.t++]=o>>this.DB-n):this[this.t-1]|=o<<n,(n+=r)>=this.DB&&(n-=this.DB))}8==r&&0!=(128&+t[0])&&(this.s=-1,n>0&&(this[this.t-1]|=(1<<this.DB-n)-1<<n)),this.clamp(),s&&Z.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,i=this.DB-r,s=(1<<i)-1,n=Math.floor(t/this.DB),o=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+n+1]=this[a]>>i|o,o=(this[a]&s)<<r;for(a=n-1;a>=0;--a)e[a]=0;e[n]=o,e.t=this.t+n+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 i=t%this.DB,s=this.DB-i,n=(1<<i)-1;e[0]=this[r]>>i;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&n)<<s,e[o-r]=this[o]>>i;i>0&&(e[this.t-r-1]|=(this.s&n)<<s),e.t=this.t-r,e.clamp()}}subTo(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()}multiplyTo(t,e){var r=this.abs(),i=t.abs(),s=r.t;for(e.t=s+i.t;--s>=0;)e[s]=0;for(s=0;s<i.t;++s)e[s+r.t]=r.am(0,i[s],e,s,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&Z.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 i=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,i,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 i=t.abs();if(!(i.t<=0)){var s=this.abs();if(s.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=Q());var n=Q(),o=this.s,a=t.s,h=this.DB-st(i[i.t-1]);h>0?(i.lShiftTo(h,n),s.lShiftTo(h,r)):(i.copyTo(n),s.copyTo(r));var u=n.t,c=n[u-1];if(0!=c){var l=c*(1<<this.F1)+(u>1?n[u-2]>>this.F2:0),d=this.FV/l,f=(1<<this.F1)/l,g=1<<this.F2,p=r.t,m=p-u,_=null==e?Q():e;for(n.dlShiftTo(m,_),r.compareTo(_)>=0&&(r[r.t++]=1,r.subTo(_,r)),Z.ONE.dlShiftTo(u,_),_.subTo(n,n);n.t<u;)n[n.t++]=0;for(;--m>=0;){var y=r[--p]==c?this.DM:Math.floor(r[p]*d+(r[p-1]+g)*f);if((r[p]+=n.am(0,y,r,m,0,u))<y)for(n.dlShiftTo(m,_),r.subTo(_,r);r[p]<--y;)r.subTo(_,r)}null!=e&&(r.drShiftTo(u,e),o!=a&&Z.ZERO.subTo(e,e)),r.t=u,r.clamp(),h>0&&r.rShiftTo(h,r),o<0&&Z.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 Z.ONE;var r=Q(),i=Q(),s=e.convert(this),n=st(t)-1;for(s.copyTo(r);--n>=0;)if(e.sqrTo(r,i),(t&1<<n)>0)e.mulTo(i,s,r);else{var o=r;r=i,i=o}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),i=it(r),s=Q(),n=Q(),o="";for(this.divRemTo(i,s,n);s.signum()>0;)o=(r+n.intValue()).toString(t).substr(1)+o,s.divRemTo(i,s,n);return n.intValue().toString(t)+o}fromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),s=!1,n=0,o=0,a=0;a<t.length;++a){var h=rt(t,a);h<0?"-"==t.charAt(a)&&0==this.signum()&&(s=!0):(o=e*o+h,++n>=r&&(this.dMultiply(i),this.dAddOffset(o,0),n=0,o=0))}n>0&&(this.dMultiply(Math.pow(e,n)),this.dAddOffset(o,0)),s&&Z.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(Z.ONE.shiftLeft(t-1),B,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(Z.ONE.shiftLeft(t-1),this);else{var i=[],s=7&t;i.length=1+(t>>3),e.nextBytes(i),s>0?i[0]&=(1<<s)-1:i[0]=0,this.fromString(i,256)}}bitwiseTo(t,e,r){var i,s,n=Math.min(t.t,this.t);for(i=0;i<n;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(s=t.s&this.DM,i=n;i<this.t;++i)r[i]=e(this[i],s);r.t=this.t}else{for(s=this.s&this.DM,i=n;i<t.t;++i)r[i]=e(s,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}changeBit(t,e){var r=Z.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}addTo(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),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 i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(var s=r.t-this.t;i<s;++i)r[i+this.t]=this.am(0,t[i],r,i,0,this.t);for(s=Math.min(t.t,e);i<s;++i)this.am(0,t[i],r,i,0,e-i);r.clamp()}multiplyUpperTo(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-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 i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r}millerRabin(t){var e=this.subtract(Z.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var i=e.shiftRight(r);(t=t+1>>1)>m.length&&(t=m.length);for(var s=Q(),n=0;n<t;++n){s.fromInt(m[Math.floor(Math.random()*m.length)]);var o=s.modPow(i,this);if(0!=o.compareTo(Z.ONE)&&0!=o.compareTo(e)){for(var a=1;a++<r&&0!=o.compareTo(e);)if(0==(o=o.modPowInt(2,this)).compareTo(Z.ONE))return!1;if(0!=o.compareTo(e))return!1}}return!0}square(){var t=Q();return this.squareTo(t),t}gcda(t,e){var r=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(r.compareTo(i)<0){var s=r;r=i,i=s}var n=r.getLowestSetBit(),o=i.getLowestSetBit();if(o<0)e(r);else{n<o&&(o=n),o>0&&(r.rShiftTo(o,r),i.rShiftTo(o,i));var a=()=>{(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),r.compareTo(i)>=0?(r.subTo(i,r),r.rShiftTo(1,r)):(i.subTo(r,i),i.rShiftTo(1,i)),r.signum()>0?setTimeout(a,0):(o>0&&i.lShiftTo(o,i),setTimeout((function(){e(i)}),0))};setTimeout(a,10)}}fromNumberAsync(t,e,r,i){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(Z.ONE.shiftLeft(t-1),B,this),this.isEven()&&this.dAddOffset(1,0);var s=this,n=function(){s.dAddOffset(2,0),s.bitLength()>t&&s.subTo(Z.ONE.shiftLeft(t-1),s),s.isProbablePrime(e)?setTimeout((function(){i()}),0):setTimeout(n,0)};setTimeout(n,0)}else{var o=[],a=7&t;o.length=1+(t>>3),e.nextBytes(o),a>0?o[0]&=(1<<a)-1:o[0]=0,this.fromString(o,256)}}}var y=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}(),v=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}(),T=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=Q();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(Z.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=Q();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],i=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,i,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}(),E=function(){function t(t){this.m=t,this.r2=Q(),this.q3=Q(),Z.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=Q();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 Q(){return new Z(null)}function J(t,e){return new Z(t,e)}function X(t,e,r,i,s,n){for(;--n>=0;){var o=e*this[t++]+r[i]+s;s=Math.floor(o/67108864),r[i++]=67108863&o}return s}function tt(t,e,r,i,s,n){for(var o=32767&e,a=e>>15;--n>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;s=((h=o*h+((32767&c)<<15)+r[i]+(1073741823&s))>>>30)+(c>>>15)+a*u+(s>>>30),r[i++]=1073741823&h}return s}function et(t,e,r,i,s,n){for(var o=16383&e,a=e>>14;--n>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;s=((h=o*h+((16383&c)<<14)+r[i]+s)>>28)+(c>>14)+a*u,r[i++]=268435455&h}return s}void 0!==x&&"Microsoft Internet Explorer"==x?.appName?(Z.prototype.am=tt,d=30):"Netscape"!=x?.appName?(Z.prototype.am=X,d=26):(Z.prototype.am=et,d=28),Z.prototype.DB=d,Z.prototype.DM=(1<<d)-1,Z.prototype.DV=1<<d,Z.prototype.FV=Math.pow(2,52),Z.prototype.F1=52-d,Z.prototype.F2=2*d-52;var S,w,I=[];for(S="0".charCodeAt(0),w=0;w<=9;++w)I[S++]=w;for(S="a".charCodeAt(0),w=10;w<36;++w)I[S++]=w;for(S="A".charCodeAt(0),w=10;w<36;++w)I[S++]=w;function rt(t,e){var r=I[t.charCodeAt(e)];return null==r?-1:r}function it(t){var e=Q();return e.fromInt(t),e}function st(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}Z.ZERO=it(0),Z.ONE=it(1);class nt{constructor(){this.i=0,this.j=0,this.S=[]}init(t){var e,r,i;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,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;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 R,b,C=256,A=null;if(null==A){A=[],b=0;var O=void 0;if(window?.crypto&&window?.crypto.getRandomValues){var U=new Uint32Array(256);for(window?.crypto.getRandomValues(U),O=0;O<U.length;++O)A[b++]=255&U[O]}var P=function(t){if(this.count=this.count||0,this.count>=256||b>=C)window?.removeEventListener?window?.removeEventListener("mousemove",P,!1):window?.detachEvent&&window?.detachEvent("onmousemove",P);else try{var e=t.x+t.y;A[b++]=255&e,this.count+=1}catch(t){}};window?.addEventListener?window?.addEventListener("mousemove",P,!1):window?.attachEvent&&window?.attachEvent("onmousemove",P)}function ot(){if(null==R){for(R=new nt;b<C;){var t=Math.floor(65536*Math.random());A[b++]=255&t}for(R.init(A),b=0;b<A.length;++b)A[b]=0;b=0}return R.next()}class at{constructor(){}nextBytes(t){for(var e=0;e<t.length;++e)t[e]=ot()}}function ht(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var r=[],i=t.length-1;i>=0&&e>0;){var s=t.charCodeAt(i--);s<128?r[--e]=s:s>127&&s<2048?(r[--e]=63&s|128,r[--e]=s>>6|192):(r[--e]=63&s|128,r[--e]=s>>6&63|128,r[--e]=s>>12|224)}r[--e]=0;for(var n=new at,o=[];e>2;){for(o[0]=0;0==o[0];)n.nextBytes(o);r[--e]=o[0]}return r[--e]=2,r[--e]=0,new Z(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=ht(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var i=r.toString(16);return 0==(1&i.length)?i:"0"+i}encryptLong(t){var e=this,r=(this.n.bitLength()+7>>3)-11;try{var i="";return t.length>r?(t.match(/.{1,117}/g).forEach((function(t){var r=e.encrypt(t);i+=r})),F(i)):F(this.encrypt(t))}catch(t){return!1}}decryptLong(t){var e=this,r=this.n.bitLength()+7>>3;t=$(t);try{if(t.length>r){var i="";return t.match(/.{1,256}/g).forEach((function(t){var r=e.decrypt(t);i+=r})),i}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,i,s,n,o,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(i,16),this.q=J(s,16),this.dmp1=J(n,16),this.dmq1=J(o,16),this.coeff=J(a,16)):console.error("Invalid RSA private key")}generate(t,e){var r=new at,i=t>>1;this.e=parseInt(e,16);for(var s=new Z(e,16);;){for(;this.p=new Z(t-i,1,r),0!=this.p.subtract(Z.ONE).gcd(s).compareTo(Z.ONE)||!this.p.isProbablePrime(10););for(;this.q=new Z(i,1,r),0!=this.q.subtract(Z.ONE).gcd(s).compareTo(Z.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var n=this.p;this.p=this.q,this.q=n}var o=this.p.subtract(Z.ONE),a=this.q.subtract(Z.ONE),h=o.multiply(a);if(0==h.gcd(s).compareTo(Z.ONE)){this.n=this.p.multiply(this.q),this.d=s.modInverse(h),this.dmp1=this.d.mod(o),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:ct(r,this.n.bitLength()+7>>3)}generateAsync(t,e,r){var i=new at,s=t>>1;this.e=parseInt(e,16);var n=new Z(e,16),o=this,a=()=>{var e=()=>{if(o.p.compareTo(o.q)<=0){var t=o.p;o.p=o.q,o.q=t}var e=o.p.subtract(Z.ONE),i=o.q.subtract(Z.ONE),s=e.multiply(i);0==s.gcd(n).compareTo(Z.ONE)?(o.n=o.p.multiply(o.q),o.d=n.modInverse(s),o.dmp1=o.d.mod(e),o.dmq1=o.d.mod(i),o.coeff=o.q.modInverse(o.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},h=()=>{o.q=Q(),o.q.fromNumberAsync(s,1,i,(function(){o.q.subtract(Z.ONE).gcda(n,(function(t){0==t.compareTo(Z.ONE)&&o.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(h,0)}))}))},u=()=>{o.p=Q(),o.p.fromNumberAsync(t-s,1,i,(function(){o.p.subtract(Z.ONE).gcda(n,(function(t){0==t.compareTo(Z.ONE)&&o.p.isProbablePrime(10)?setTimeout(h,0):setTimeout(u,0)}))}))};setTimeout(u,0)};setTimeout(a,0)}}function ct(t,e){for(var r=t.toByteArray(),i=0;i<r.length&&0==r[i];)++i;if(r.length-i!=e-1||2!=r[i])return null;for(++i;0!=r[i];)if(++i>=r.length)return null;for(var s="";++i<r.length;){var n=255&r[i];n<128?s+=String.fromCharCode(n):n>191&&n<224?(s+=String.fromCharCode((31&n)<<6|63&r[i+1]),++i):(s+=String.fromCharCode((15&n)<<12|(63&r[i+1])<<6|63&r[i+2]),i+=2)}return s}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,i=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?u.decode(t):c.unarmor(t),s=Y.decode(i);if(3===s.sub.length&&(s=s.sub[2].sub[0]),9===s.sub.length){e=s.sub[1].getHexStringValue(),this.n=J(e,16),r=s.sub[2].getHexStringValue(),this.e=parseInt(r,16);var n=s.sub[3].getHexStringValue();this.d=J(n,16);var o=s.sub[4].getHexStringValue();this.p=J(o,16);var a=s.sub[5].getHexStringValue();this.q=J(a,16);var h=s.sub[6].getHexStringValue();this.dmp1=J(h,16);var l=s.sub[7].getHexStringValue();this.dmq1=J(l,16);var d=s.sub[8].getHexStringValue();this.coeff=J(d,16)}else{if(2!==s.sub.length)return!1;var f=s.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)}}i=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},i.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new lt(t)},i.prototype.setPrivateKey=function(t){this.setKey(t)},i.prototype.setPublicKey=function(t){this.setKey(t)},i.prototype.decrypt=function(t){try{return this.getKey().decrypt($(t))}catch(t){return!1}},i.prototype.encrypt=function(t){try{return F(this.getKey().encrypt(t))}catch(t){return!1}},i.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",i=0,s=/null$/g;s.test(r)&&(i++,e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",!(i>10)););return e}catch(t){return!1}},i.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},i.version="3.1.4"}const N=i;var D=r(479);const L=({publicKey:t="",payload:e={}}={})=>{if(!t)return"";try{const r=(0,D.I)(e),i=new N({});return i.setPublicKey(t),i.encryptLong("object"==typeof r?JSON.stringify(r):r)}catch(t){}return""}},479:(t,e,r)=>{r.d(e,{I:()=>i,y:()=>s});const i=t=>{const e=e=>{for(const r in t)t.hasOwnProperty(r)&&(e[r]=i(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}},s=t=>{const e=t.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return e&&e[2]||""}},118:function(t,e,r){var i=this&&this.__createBinding||(Object.create?function(t,e,r,i){void 0===i&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){void 0===i&&(i=r),t[i]=e[r]}),s=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||i(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),s(r(256),e)}},e={};function r(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={exports:{}};return t[i].call(n.exports,n,n.exports,r),n.exports}return r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},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})},r(118)})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/js-sdk",
3
- "version": "2.6.3-beta.0",
3
+ "version": "2.6.4-beta.0",
4
4
  "description": "cloudbase javascript sdk",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -46,21 +46,21 @@
46
46
  "license": "Apache-2.0",
47
47
  "dependencies": {
48
48
  "@cloudbase/adapter-interface": "^0.4.1",
49
- "@cloudbase/analytics": "^2.6.3-beta.0",
50
- "@cloudbase/app": "^2.6.3-beta.0",
51
- "@cloudbase/auth": "^2.6.3-beta.0",
49
+ "@cloudbase/analytics": "^2.6.4-beta.0",
50
+ "@cloudbase/app": "^2.6.4-beta.0",
51
+ "@cloudbase/auth": "^2.6.4-beta.0",
52
52
  "@cloudbase/database": "0.9.21",
53
- "@cloudbase/functions": "^2.6.3-beta.0",
54
- "@cloudbase/model": "^2.6.3-beta.0",
55
- "@cloudbase/realtime": "^2.6.3-beta.0",
56
- "@cloudbase/storage": "^2.6.3-beta.0",
57
- "@cloudbase/types": "^2.6.3-beta.0",
58
- "@cloudbase/utilities": "^2.6.3-beta.0"
53
+ "@cloudbase/functions": "^2.6.4-beta.0",
54
+ "@cloudbase/model": "^2.6.4-beta.0",
55
+ "@cloudbase/realtime": "^2.6.4-beta.0",
56
+ "@cloudbase/storage": "^2.6.4-beta.0",
57
+ "@cloudbase/types": "^2.6.4-beta.0",
58
+ "@cloudbase/utilities": "^2.6.4-beta.0"
59
59
  },
60
60
  "browserslist": [
61
61
  "last 2 version",
62
62
  "> 1%",
63
63
  "chrome 53"
64
64
  ],
65
- "gitHead": "6cd55ade54a1525b59471b4bfd3d774fa73bea6f"
65
+ "gitHead": "7c46fbf109625501a87f420a2cebc2f5a5bf4705"
66
66
  }