@cloudbase/js-sdk 2.5.39-beta.0 → 2.5.41-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,2 +1 @@
1
- /*! For license information please see oauth.js.LICENSE.txt */
2
- !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,(()=>(()=>{var t={550:function(t,e){!function(t){"use strict";var e="0123456789abcdefghijklmnopqrstuvwxyz";function r(t){return e.charAt(t)}function n(t,e){return t&e}function i(t,e){return t|e}function s(t,e){return t^e}function o(t,e){return t&~e}function a(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 u(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c="=";function l(t){var e,r,n="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),n+=h.charAt(r>>6)+h.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=h.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=h.charAt(r>>2)+h.charAt((3&r)<<4));(3&n.length)>0;)n+=c;return n}function f(t){var e,n="",i=0,s=0;for(e=0;e<t.length&&t.charAt(e)!=c;++e){var o=h.indexOf(t.charAt(e));o<0||(0==i?(n+=r(o>>2),s=3&o,i=1):1==i?(n+=r(s<<2|o>>4),s=15&o,i=2):2==i?(n+=r(s),n+=r(o>>2),s=3&o,i=3):(n+=r(s<<2|o>>4),n+=r(15&o),i=0))}return 1==i&&(n+=r(s<<2)),n}var p,d=function(t,e){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},d(t,e)};var g,v=function(t){var e;if(void 0===p){var r="0123456789ABCDEF",n=" \f\n\r\t \u2028\u2029";for(p={},e=0;e<16;++e)p[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)p[r.charAt(e)]=e;for(e=0;e<n.length;++e)p[n.charAt(e)]=-1}var i=[],s=0,o=0;for(e=0;e<t.length;++e){var a=t.charAt(e);if("="==a)break;if(-1!=(a=p[a])){if(void 0===a)throw new Error("Illegal character at offset "+e);s|=a,++o>=2?(i[i.length]=s,s=0,o=0):s<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return i},y={decode:function(t){var e;if(void 0===g){var r="= \f\n\r\t \u2028\u2029";for(g=Object.create(null),e=0;e<64;++e)g["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<r.length;++e)g[r.charAt(e)]=-1}var n=[],i=0,s=0;for(e=0;e<t.length;++e){var o=t.charAt(e);if("="==o)break;if(-1!=(o=g[o])){if(void 0===o)throw new Error("Illegal character at offset "+e);i|=o,++s>=4?(n[n.length]=i>>16,n[n.length]=i>>8&255,n[n.length]=255&i,i=0,s=0):i<<=6}}switch(s){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=i>>10;break;case 3:n[n.length]=i>>16,n[n.length]=i>>8&255}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=y.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 y.decode(t)}},m=1e13,b=function(){function t(t){this.buf=[+t||0]}return t.prototype.mulAdd=function(t,e){var r,n,i=this.buf,s=i.length;for(r=0;r<s;++r)(n=i[r]*t+e)<m?e=0:n-=(e=0|n/m)*m,i[r]=n;e>0&&(i[r]=e)},t.prototype.sub=function(t){var e,r,n=this.buf,i=n.length;for(e=0;e<i;++e)(r=n[e]-t)<0?(r+=m,t=1):t=0,n[e]=r;for(;0===n[n.length-1];)n.pop()},t.prototype.toString=function(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),n=e.length-2;n>=0;--n)r+=(m+e[n]).toString().substring(1);return r},t.prototype.valueOf=function(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*m+t[r];return e},t.prototype.simplify=function(){var t=this.buf;return 1==t.length?t[0]:this},t}(),E="…",T=/^(\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)?)?$/,S=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function _(t,e){return t.length>e&&(t=t.substring(0,e)+E),t}var R,w=function(){function t(e,r){this.hexDigits="0123456789ABCDEF",e instanceof t?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=r)}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,r){for(var n="",i=t;i<e;++i)if(n+=this.hexByte(this.get(i)),!0!==r)switch(15&i){case 7:n+=" ";break;case 15:n+="\n";break;default:n+=" "}return n},t.prototype.isASCII=function(t,e){for(var r=t;r<e;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0},t.prototype.parseStringISO=function(t,e){for(var r="",n=t;n<e;++n)r+=String.fromCharCode(this.get(n));return r},t.prototype.parseStringUTF=function(t,e){for(var r="",n=t;n<e;){var i=this.get(n++);r+=i<128?String.fromCharCode(i):i>191&&i<224?String.fromCharCode((31&i)<<6|63&this.get(n++)):String.fromCharCode((15&i)<<12|(63&this.get(n++))<<6|63&this.get(n++))}return r},t.prototype.parseStringBMP=function(t,e){for(var r,n,i="",s=t;s<e;)r=this.get(s++),n=this.get(s++),i+=String.fromCharCode(r<<8|n);return i},t.prototype.parseTime=function(t,e,r){var n=this.parseStringISO(t,e),i=(r?T:S).exec(n);return i?(r&&(i[1]=+i[1],i[1]+=+i[1]<70?2e3:1900),n=i[1]+"-"+i[2]+"-"+i[3]+" "+i[4],i[5]&&(n+=":"+i[5],i[6]&&(n+=":"+i[6],i[7]&&(n+="."+i[7]))),i[8]&&(n+=" UTC","Z"!=i[8]&&(n+=i[8],i[9]&&(n+=":"+i[9]))),n):"Unrecognized time: "+n},t.prototype.parseInteger=function(t,e){for(var r,n=this.get(t),i=n>127,s=i?255:0,o="";n==s&&++t<e;)n=this.get(t);if(0==(r=e-t))return i?-1:0;if(r>4){for(o=n,r<<=3;0==(128&(+o^s));)o=+o<<1,--r;o="("+r+" bit)\n"}i&&(n-=256);for(var a=new b(n),u=t+1;u<e;++u)a.mulAdd(256,this.get(u));return o+a.toString()},t.prototype.parseBitString=function(t,e,r){for(var n=this.get(t),i="("+((e-t-1<<3)-n)+" bit)\n",s="",o=t+1;o<e;++o){for(var a=this.get(o),u=o==e-1?n:0,h=7;h>=u;--h)s+=a>>h&1?"1":"0";if(s.length>r)return i+_(s,r)}return i+s},t.prototype.parseOctetString=function(t,e,r){if(this.isASCII(t,e))return _(this.parseStringISO(t,e),r);var n=e-t,i="("+n+" byte)\n";n>(r/=2)&&(e=t+r);for(var s=t;s<e;++s)i+=this.hexByte(this.get(s));return n>r&&(i+=E),i},t.prototype.parseOID=function(t,e,r){for(var n="",i=new b,s=0,o=t;o<e;++o){var a=this.get(o);if(i.mulAdd(128,127&a),s+=7,!(128&a)){if(""===n)if((i=i.simplify())instanceof b)i.sub(80),n="2."+i.toString();else{var u=i<80?i<40?0:1:2;n=u+"."+(i-40*u)}else n+="."+i.toString();if(n.length>r)return _(n,r);i=new b,s=0}}return s>0&&(n+=".incomplete"),n},t}(),I=function(){function t(t,e,r,n,i){if(!(n instanceof D))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=n,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(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+r,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);case 6:return this.stream.parseOID(e,e+r,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return _(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return _(this.stream.parseStringISO(e,e+r),t);case 30:return _(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+r,23==this.tag.tagNumber)}return null},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 r=0,n=this.sub.length;r<n;++r)e+=this.sub[r].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(),r=127&e;if(r==e)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var n=0;n<r;++n)e=256*e+t.get();return e},t.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)},t.decode=function(e){var r;r=e instanceof w?e:new w(e,0);var n=new w(r),i=new D(r),s=t.decodeLength(r),o=r.pos,a=o-n.pos,u=null,h=function(){var e=[];if(null!==s){for(var n=o+s;r.pos<n;)e[e.length]=t.decode(r);if(r.pos!=n)throw new Error("Content size is not correct for container starting at offset "+o)}else try{for(;;){var i=t.decode(r);if(i.tag.isEOC())break;e[e.length]=i}s=o-r.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return e};if(i.tagConstructed)u=h();else if(i.isUniversal()&&(3==i.tagNumber||4==i.tagNumber))try{if(3==i.tagNumber&&0!=r.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");u=h();for(var c=0;c<u.length;++c)if(u[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){u=null}if(null===u){if(null===s)throw new Error("We can't skip over an invalid tag with undefined length at offset "+o);r.pos=o+Math.abs(s)}return new t(n,a,s,i,u)},t}(),D=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 r=new b;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}return t.prototype.isUniversal=function(){return 0===this.tagClass},t.prototype.isEOC=function(){return 0===this.tagClass&&0===this.tagNumber},t}(),O=[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],A=(1<<26)/O[O.length-1],N=function(){function t(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))}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,i=(1<<e)-1,s=!1,o="",a=this.t,u=this.DB-a*this.DB%e;if(a-- >0)for(u<this.DB&&(n=this[a]>>u)>0&&(s=!0,o=r(n));a>=0;)u<e?(n=(this[a]&(1<<u)-1)<<e-u,n|=this[--a]>>(u+=this.DB-e)):(n=this[a]>>(u-=e)&i,u<=0&&(u+=this.DB,--a)),n>0&&(s=!0),s&&(o+=r(n));return s?o:"0"},t.prototype.negate=function(){var e=L();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 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},t.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+j(this[this.t-1]^this.s&this.DM)},t.prototype.mod=function(e){var r=L();return this.abs().divRemTo(e,null,r),this.s<0&&r.compareTo(t.ZERO)>0&&e.subTo(r,r),r},t.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new P(e):new C(e),this.exp(t,r)},t.prototype.clone=function(){var t=L();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 r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},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=L();return this.bitwiseTo(t,n,e),e},t.prototype.or=function(t){var e=L();return this.bitwiseTo(t,i,e),e},t.prototype.xor=function(t){var e=L();return this.bitwiseTo(t,s,e),e},t.prototype.andNot=function(t){var e=L();return this.bitwiseTo(t,o,e),e},t.prototype.not=function(){for(var t=L(),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=L();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},t.prototype.shiftRight=function(t){var e=L();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+a(this[t]);return this.s<0?this.t*this.DB:-1},t.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=u(this[r]^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,i)},t.prototype.clearBit=function(t){return this.changeBit(t,o)},t.prototype.flipBit=function(t){return this.changeBit(t,s)},t.prototype.add=function(t){var e=L();return this.addTo(t,e),e},t.prototype.subtract=function(t){var e=L();return this.subTo(t,e),e},t.prototype.multiply=function(t){var e=L();return this.multiplyTo(t,e),e},t.prototype.divide=function(t){var e=L();return this.divRemTo(t,e,null),e},t.prototype.remainder=function(t){var e=L();return this.divRemTo(t,null,e),e},t.prototype.divideAndRemainder=function(t){var e=L(),r=L();return this.divRemTo(t,e,r),[e,r]},t.prototype.modPow=function(t,e){var r,n,i=t.bitLength(),s=M(1);if(i<=0)return s;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new P(e):e.isEven()?new U(e):new C(e);var o=[],a=3,u=r-1,h=(1<<r)-1;if(o[1]=n.convert(this),r>1){var c=L();for(n.sqrTo(o[1],c);a<=h;)o[a]=L(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,p=t.t-1,d=!0,g=L();for(i=j(t[p])-1;p>=0;){for(i>=u?l=t[p]>>i-u&h:(l=(t[p]&(1<<i+1)-1)<<u-i,p>0&&(l|=t[p-1]>>this.DB+i-u)),a=r;0==(1&l);)l>>=1,--a;if((i-=a)<0&&(i+=this.DB,--p),d)o[l].copyTo(s),d=!1;else{for(;a>1;)n.sqrTo(s,g),n.sqrTo(g,s),a-=2;a>0?n.sqrTo(s,g):(f=s,s=g,g=f),n.mulTo(g,o[l],s)}for(;p>=0&&0==(t[p]&1<<i);)n.sqrTo(s,g),f=s,s=g,g=f,--i<0&&(i=this.DB-1,--p)}return n.revert(s)},t.prototype.modInverse=function(e){var r=e.isEven();if(this.isEven()&&r||0==e.signum())return t.ZERO;for(var n=e.clone(),i=this.clone(),s=M(1),o=M(0),a=M(0),u=M(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),r?(s.isEven()&&o.isEven()||(s.addTo(this,s),o.subTo(e,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;i.isEven();)i.rShiftTo(1,i),r?(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);n.compareTo(i)>=0?(n.subTo(i,n),r&&s.subTo(a,s),o.subTo(u,o)):(i.subTo(n,i),r&&a.subTo(s,a),u.subTo(o,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 x)},t.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i<s&&(s=i),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},t.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=O[O.length-1]){for(e=0;e<O.length;++e)if(r[0]==O[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<O.length;){for(var n=O[e],i=e+1;i<O.length&&n<A;)n*=O[i++];for(n=r.modInt(n);e<i;)if(n%O[e++]==0)return!1}return r.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,r){var n;if(16==r)n=4;else if(8==r)n=3;else if(256==r)n=8;else if(2==r)n=1;else if(32==r)n=5;else{if(4!=r)return void this.fromRadix(e,r);n=2}this.t=0,this.s=0;for(var i=e.length,s=!1,o=0;--i>=0;){var a=8==n?255&+e[i]:H(e,i);a<0?"-"==e.charAt(i)&&(s=!0):(s=!1,0==o?this[this.t++]=a:o+n>this.DB?(this[this.t-1]|=(a&(1<<this.DB-o)-1)<<o,this[this.t++]=a>>this.DB-o):this[this.t-1]|=a<<o,(o+=n)>=this.DB&&(o-=this.DB))}8==n&&0!=(128&+e[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),s&&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 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},t.prototype.drShiftTo=function(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},t.prototype.lShiftTo=function(t,e){for(var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,s=Math.floor(t/this.DB),o=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+s+1]=this[a]>>n|o,o=(this[a]&i)<<r;for(a=s-1;a>=0;--a)e[a]=0;e[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()},t.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<<n)-1;e[0]=this[r]>>n;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&s)<<i,e[o-r]=this[o]>>n;n>0&&(e[this.t-r-1]|=(this.s&s)<<i),e.t=this.t-r,e.clamp()}},t.prototype.subTo=function(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},t.prototype.multiplyTo=function(e,r){var n=this.abs(),i=e.abs(),s=n.t;for(r.t=s+i.t;--s>=0;)r[s]=0;for(s=0;s<i.t;++s)r[s+n.t]=n.am(0,i[s],r,s,0,n.t);r.s=0,r.clamp(),this.s!=e.s&&t.ZERO.subTo(r,r)},t.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},t.prototype.divRemTo=function(e,r,n){var i=e.abs();if(!(i.t<=0)){var s=this.abs();if(s.t<i.t)return null!=r&&r.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=L());var o=L(),a=this.s,u=e.s,h=this.DB-j(i[i.t-1]);h>0?(i.lShiftTo(h,o),s.lShiftTo(h,n)):(i.copyTo(o),s.copyTo(n));var c=o.t,l=o[c-1];if(0!=l){var f=l*(1<<this.F1)+(c>1?o[c-2]>>this.F2:0),p=this.FV/f,d=(1<<this.F1)/f,g=1<<this.F2,v=n.t,y=v-c,m=null==r?L():r;for(o.dlShiftTo(y,m),n.compareTo(m)>=0&&(n[n.t++]=1,n.subTo(m,n)),t.ONE.dlShiftTo(c,m),m.subTo(o,o);o.t<c;)o[o.t++]=0;for(;--y>=0;){var b=n[--v]==l?this.DM:Math.floor(n[v]*p+(n[v-1]+g)*d);if((n[v]+=o.am(0,b,n,y,0,c))<b)for(o.dlShiftTo(y,m),n.subTo(m,n);n[v]<--b;)n.subTo(m,n)}null!=r&&(n.drShiftTo(c,r),a!=u&&t.ZERO.subTo(r,r)),n.t=c,n.clamp(),h>0&&n.rShiftTo(h,n),a<0&&t.ZERO.subTo(n,n)}}},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,r){if(e>4294967295||e<1)return t.ONE;var n=L(),i=L(),s=r.convert(this),o=j(e)-1;for(s.copyTo(n);--o>=0;)if(r.sqrTo(n,i),(e&1<<o)>0)r.mulTo(i,s,n);else{var a=n;n=i,i=a}return r.revert(n)},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),r=Math.pow(t,e),n=M(r),i=L(),s=L(),o="";for(this.divRemTo(n,i,s);i.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,i.divRemTo(n,i,s);return s.intValue().toString(t)+o},t.prototype.fromRadix=function(e,r){this.fromInt(0),null==r&&(r=10);for(var n=this.chunkSize(r),i=Math.pow(r,n),s=!1,o=0,a=0,u=0;u<e.length;++u){var h=H(e,u);h<0?"-"==e.charAt(u)&&0==this.signum()&&(s=!0):(a=r*a+h,++o>=n&&(this.dMultiply(i),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(r,o)),this.dAddOffset(a,0)),s&&t.ZERO.subTo(this,this)},t.prototype.fromNumber=function(e,r,n){if("number"==typeof r)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),i,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(r);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(t.ONE.shiftLeft(e-1),this);else{var s=[],o=7&e;s.length=1+(e>>3),r.nextBytes(s),o>0?s[0]&=(1<<o)-1:s[0]=0,this.fromString(s,256)}},t.prototype.bitwiseTo=function(t,e,r){var n,i,s=Math.min(t.t,this.t);for(n=0;n<s;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(i=t.s&this.DM,n=s;n<this.t;++n)r[n]=e(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=s;n<t.t;++n)r[n]=e(i,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},t.prototype.changeBit=function(e,r){var n=t.ONE.shiftLeft(e);return this.bitwiseTo(n,r,n),n},t.prototype.addTo=function(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},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,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(var i=r.t-this.t;n<i;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()},t.prototype.multiplyUpperTo=function(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)},t.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},t.prototype.millerRabin=function(e){var r=this.subtract(t.ONE),n=r.getLowestSetBit();if(n<=0)return!1;var i=r.shiftRight(n);(e=e+1>>1)>O.length&&(e=O.length);for(var s=L(),o=0;o<e;++o){s.fromInt(O[Math.floor(Math.random()*O.length)]);var a=s.modPow(i,this);if(0!=a.compareTo(t.ONE)&&0!=a.compareTo(r)){for(var u=1;u++<n&&0!=a.compareTo(r);)if(0==(a=a.modPowInt(2,this)).compareTo(t.ONE))return!1;if(0!=a.compareTo(r))return!1}}return!0},t.prototype.square=function(){var t=L();return this.squareTo(t),t},t.prototype.gcda=function(t,e){var r=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(r.compareTo(n)<0){var i=r;r=n,n=i}var s=r.getLowestSetBit(),o=n.getLowestSetBit();if(o<0)e(r);else{s<o&&(o=s),o>0&&(r.rShiftTo(o,r),n.rShiftTo(o,n));var a=function(){(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),(s=n.getLowestSetBit())>0&&n.rShiftTo(s,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n)),r.signum()>0?setTimeout(a,0):(o>0&&n.lShiftTo(o,n),setTimeout((function(){e(n)}),0))};setTimeout(a,10)}},t.prototype.fromNumberAsync=function(e,r,n,s){if("number"==typeof r)if(e<2)this.fromInt(1);else{this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),i,this),this.isEven()&&this.dAddOffset(1,0);var o=this,a=function(){o.dAddOffset(2,0),o.bitLength()>e&&o.subTo(t.ONE.shiftLeft(e-1),o),o.isProbablePrime(r)?setTimeout((function(){s()}),0):setTimeout(a,0)};setTimeout(a,0)}else{var u=[],h=7&e;u.length=1+(e>>3),r.nextBytes(u),h>0?u[0]&=(1<<h)-1:u[0]=0,this.fromString(u,256)}},t}(),x=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}(),P=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}(),C=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=L();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(N.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=L();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),U=function(){function t(t){this.m=t,this.r2=L(),this.q3=L(),N.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=L();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 L(){return new N(null)}function V(t,e){return new N(t,e)}"Microsoft Internet Explorer"==navigator.appName?(N.prototype.am=function(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;--s>=0;){var u=32767&this[t],h=this[t++]>>15,c=a*u+h*o;i=((u=o*u+((32767&c)<<15)+r[n]+(1073741823&i))>>>30)+(c>>>15)+a*h+(i>>>30),r[n++]=1073741823&u}return i},R=30):"Netscape"!=navigator.appName?(N.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var o=e*this[t++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},R=26):(N.prototype.am=function(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var u=16383&this[t],h=this[t++]>>14,c=a*u+h*o;i=((u=o*u+((16383&c)<<14)+r[n]+i)>>28)+(c>>14)+a*h,r[n++]=268435455&u}return i},R=28),N.prototype.DB=R,N.prototype.DM=(1<<R)-1,N.prototype.DV=1<<R;N.prototype.FV=Math.pow(2,52),N.prototype.F1=52-R,N.prototype.F2=2*R-52;var B,k,q=[];for(B="0".charCodeAt(0),k=0;k<=9;++k)q[B++]=k;for(B="a".charCodeAt(0),k=10;k<36;++k)q[B++]=k;for(B="A".charCodeAt(0),k=10;k<36;++k)q[B++]=k;function H(t,e){var r=q[t.charCodeAt(e)];return null==r?-1:r}function M(t){var e=L();return e.fromInt(t),e}function j(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}N.ZERO=M(0),N.ONE=M(1);var F=function(){function t(){this.i=0,this.j=0,this.S=[]}return t.prototype.init=function(t){var e,r,n;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,n=this.S[e],this.S[e]=this.S[r],this.S[r]=n;this.i=0,this.j=0},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}();var K,G,W=256,Y=null;if(null==Y){Y=[],G=0;var z=void 0;if(window.crypto&&window.crypto.getRandomValues){var Z=new Uint32Array(256);for(window.crypto.getRandomValues(Z),z=0;z<Z.length;++z)Y[G++]=255&Z[z]}var Q=function(t){if(this.count=this.count||0,this.count>=256||G>=W)window.removeEventListener?window.removeEventListener("mousemove",Q,!1):window.detachEvent&&window.detachEvent("onmousemove",Q);else try{var e=t.x+t.y;Y[G++]=255&e,this.count+=1}catch(t){}};window.addEventListener?window.addEventListener("mousemove",Q,!1):window.attachEvent&&window.attachEvent("onmousemove",Q)}function J(){if(null==K){for(K=new F;G<W;){var t=Math.floor(65536*Math.random());Y[G++]=255&t}for(K.init(Y),G=0;G<Y.length;++G)Y[G]=0;G=0}return K.next()}var $=function(){function t(){}return t.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=J()},t}();var X=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),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)},t.prototype.setPublic=function(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=V(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 r=[],n=t.length-1;n>=0&&e>0;){var i=t.charCodeAt(n--);i<128?r[--e]=i:i>127&&i<2048?(r[--e]=63&i|128,r[--e]=i>>6|192):(r[--e]=63&i|128,r[--e]=i>>6&63|128,r[--e]=i>>12|224)}r[--e]=0;for(var s=new $,o=[];e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);r[--e]=o[0]}return r[--e]=2,r[--e]=0,new N(r)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var n=r.toString(16);return 0==(1&n.length)?n:"0"+n},t.prototype.encryptLong=function(t){var e=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return t.length>r?(t.match(/.{1,117}/g).forEach((function(t){var r=e.encrypt(t);n+=r})),l(n)):l(this.encrypt(t))}catch(t){return!1}},t.prototype.decryptLong=function(t){var e=this,r=this.n.bitLength()+7>>3;t=f(t);try{if(t.length>r){var n="";return t.match(/.{1,256}/g).forEach((function(t){var r=e.decrypt(t);n+=r})),n}return this.decrypt(t)}catch(t){return!1}},t.prototype.setPrivate=function(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=V(t,16),this.e=parseInt(e,16),this.d=V(r,16)):console.error("Invalid RSA private key")},t.prototype.setPrivateEx=function(t,e,r,n,i,s,o,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=V(t,16),this.e=parseInt(e,16),this.d=V(r,16),this.p=V(n,16),this.q=V(i,16),this.dmp1=V(s,16),this.dmq1=V(o,16),this.coeff=V(a,16)):console.error("Invalid RSA private key")},t.prototype.generate=function(t,e){var r=new $,n=t>>1;this.e=parseInt(e,16);for(var i=new N(e,16);;){for(;this.p=new N(t-n,1,r),0!=this.p.subtract(N.ONE).gcd(i).compareTo(N.ONE)||!this.p.isProbablePrime(10););for(;this.q=new N(n,1,r),0!=this.q.subtract(N.ONE).gcd(i).compareTo(N.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(N.ONE),a=this.q.subtract(N.ONE),u=o.multiply(a);if(0==u.gcd(i).compareTo(N.ONE)){this.n=this.p.multiply(this.q),this.d=i.modInverse(u),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}},t.prototype.decrypt=function(t){var e=V(t,16),r=this.doPrivate(e);return null==r?null:function(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var i="";++n<r.length;){var s=255&r[n];s<128?i+=String.fromCharCode(s):s>191&&s<224?(i+=String.fromCharCode((31&s)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&s)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}(r,this.n.bitLength()+7>>3)},t.prototype.generateAsync=function(t,e,r){var n=new $,i=t>>1;this.e=parseInt(e,16);var s=new N(e,16),o=this,a=function(){var e=function(){if(o.p.compareTo(o.q)<=0){var t=o.p;o.p=o.q,o.q=t}var e=o.p.subtract(N.ONE),n=o.q.subtract(N.ONE),i=e.multiply(n);0==i.gcd(s).compareTo(N.ONE)?(o.n=o.p.multiply(o.q),o.d=s.modInverse(i),o.dmp1=o.d.mod(e),o.dmq1=o.d.mod(n),o.coeff=o.q.modInverse(o.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},u=function(){o.q=L(),o.q.fromNumberAsync(i,1,n,(function(){o.q.subtract(N.ONE).gcda(s,(function(t){0==t.compareTo(N.ONE)&&o.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(u,0)}))}))},h=function(){o.p=L(),o.p.fromNumberAsync(t-i,1,n,(function(){o.p.subtract(N.ONE).gcda(s,(function(t){0==t.compareTo(N.ONE)&&o.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(h,0)}))}))};setTimeout(h,0)};setTimeout(a,0)},t.prototype.sign=function(t,e,r){var n=function(t,e){if(e<t.length+22)return console.error("Message too long for RSA"),null;for(var r=e-t.length-6,n="",i=0;i<r;i+=2)n+="ff";return V("0001"+n+"00"+t,16)}((tt[r]||"")+e(t).toString(),this.n.bitLength()/4);if(null==n)return null;var i=this.doPrivate(n);if(null==i)return null;var s=i.toString(16);return 0==(1&s.length)?s:"0"+s},t.prototype.verify=function(t,e,r){var n=V(e,16),i=this.doPublic(n);return null==i?null:function(t){for(var e in tt)if(tt.hasOwnProperty(e)){var r=tt[e],n=r.length;if(t.substr(0,n)==r)return t.substr(n)}return t}(i.toString(16).replace(/^1f+00/,""))==r(t).toString()},t}();var tt={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"};var et={};et.lang={extend:function(t,e,r){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var n=function(){};if(n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),r){var i;for(i in r)t.prototype[i]=r[i];var s=function(){},o=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(s=function(t,e){for(i=0;i<o.length;i+=1){var r=o[i],n=e[r];"function"==typeof n&&n!=Object.prototype[r]&&(t[r]=n)}})}catch(t){}s(t.prototype,r)}}};var rt={};void 0!==rt.asn1&&rt.asn1||(rt.asn1={}),rt.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 r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i<r;i++)n+="f";e=new N(n,16).xor(t).add(N.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=rt.asn1,r=e.DERBoolean,n=e.DERInteger,i=e.DERBitString,s=e.DEROctetString,o=e.DERNull,a=e.DERObjectIdentifier,u=e.DEREnumerated,h=e.DERUTF8String,c=e.DERNumericString,l=e.DERPrintableString,f=e.DERTeletexString,p=e.DERIA5String,d=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 r(t[T]);if("int"==T)return new n(t[T]);if("bitstr"==T)return new i(t[T]);if("octstr"==T)return new s(t[T]);if("null"==T)return new o(t[T]);if("oid"==T)return new a(t[T]);if("enum"==T)return new u(t[T]);if("utf8str"==T)return new h(t[T]);if("numstr"==T)return new c(t[T]);if("prnstr"==T)return new l(t[T]);if("telstr"==T)return new f(t[T]);if("ia5str"==T)return new p(t[T]);if("utctime"==T)return new d(t[T]);if("gentime"==T)return new g(t[T]);if("seq"==T){for(var S=t[T],_=[],R=0;R<S.length;R++){var w=b(S[R]);_.push(w)}return new v({array:_})}if("set"==T){for(S=t[T],_=[],R=0;R<S.length;R++)w=b(S[R]),_.push(w);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 O={};if(void 0!==I.explicit&&(O.explicit=I.explicit),void 0!==I.tag&&(O.tag=I.tag),void 0===I.obj)throw"obj shall be specified for 'tag'.";return O.obj=b(I.obj),new m(O)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},rt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),n=(e=Math.floor(r/40)+"."+r%40,""),i=2;i<t.length;i+=2){var s=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);n+=s.substr(1,7),"0"==s.substr(0,1)&&(e=e+"."+new N(n,2).toString(10),n="")}return e},rt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new N(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";for(n=s+n,o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",i=t.split("."),s=40*parseInt(i[0])+parseInt(i[1]);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n},rt.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 r=e.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+r).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""}},rt.asn1.DERAbstractString=function(t){rt.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))},et.lang.extend(rt.asn1.DERAbstractString,rt.asn1.ASN1Object),rt.asn1.DERAbstractTime=function(t){rt.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,r){var n=this.zeroPadding,i=this.localDateToUTC(t),s=String(i.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var a=i.getMilliseconds();if(0!=a){var u=n(String(a),3);o=o+"."+(u=u.replace(/[0]+$/,""))}}return o+"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,r,n,i,s){var o=new Date(Date.UTC(t,e-1,r,n,i,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},et.lang.extend(rt.asn1.DERAbstractTime,rt.asn1.ASN1Object),rt.asn1.DERAbstractStructured=function(t){rt.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)},et.lang.extend(rt.asn1.DERAbstractStructured,rt.asn1.ASN1Object),rt.asn1.DERBoolean=function(){rt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},et.lang.extend(rt.asn1.DERBoolean,rt.asn1.ASN1Object),rt.asn1.DERInteger=function(t){rt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=rt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new N(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))},et.lang.extend(rt.asn1.DERInteger,rt.asn1.ASN1Object),rt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=rt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}rt.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 r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var r=0;r<=e;r++)t+="0";var n="";for(r=0;r<t.length-1;r+=8){var i=t.substr(r,8),s=parseInt(i,2).toString(16);1==s.length&&(s="0"+s),n+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+n},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!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))},et.lang.extend(rt.asn1.DERBitString,rt.asn1.ASN1Object),rt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=rt.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}rt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},et.lang.extend(rt.asn1.DEROctetString,rt.asn1.DERAbstractString),rt.asn1.DERNull=function(){rt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},et.lang.extend(rt.asn1.DERNull,rt.asn1.ASN1Object),rt.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new N(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";for(n=s+n,o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};rt.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 n="",i=t.split("."),s=40*parseInt(i[0])+parseInt(i[1]);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.setValueName=function(t){var e=rt.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))},et.lang.extend(rt.asn1.DERObjectIdentifier,rt.asn1.ASN1Object),rt.asn1.DEREnumerated=function(t){rt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=rt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new N(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))},et.lang.extend(rt.asn1.DEREnumerated,rt.asn1.ASN1Object),rt.asn1.DERUTF8String=function(t){rt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},et.lang.extend(rt.asn1.DERUTF8String,rt.asn1.DERAbstractString),rt.asn1.DERNumericString=function(t){rt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},et.lang.extend(rt.asn1.DERNumericString,rt.asn1.DERAbstractString),rt.asn1.DERPrintableString=function(t){rt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},et.lang.extend(rt.asn1.DERPrintableString,rt.asn1.DERAbstractString),rt.asn1.DERTeletexString=function(t){rt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},et.lang.extend(rt.asn1.DERTeletexString,rt.asn1.DERAbstractString),rt.asn1.DERIA5String=function(t){rt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},et.lang.extend(rt.asn1.DERIA5String,rt.asn1.DERAbstractString),rt.asn1.DERUTCTime=function(t){rt.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))},et.lang.extend(rt.asn1.DERUTCTime,rt.asn1.DERAbstractTime),rt.asn1.DERGeneralizedTime=function(t){rt.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))},et.lang.extend(rt.asn1.DERGeneralizedTime,rt.asn1.DERAbstractTime),rt.asn1.DERSequence=function(t){rt.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}},et.lang.extend(rt.asn1.DERSequence,rt.asn1.DERAbstractStructured),rt.asn1.DERSet=function(t){rt.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 r=this.asn1Array[e];t.push(r.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)},et.lang.extend(rt.asn1.DERSet,rt.asn1.DERAbstractStructured),rt.asn1.DERTaggedObject=function(t){rt.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,r){this.hT=e,this.isExplicit=t,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.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)))},et.lang.extend(rt.asn1.DERTaggedObject,rt.asn1.ASN1Object);var nt=function(t){function e(r){var n=t.call(this)||this;return r&&("string"==typeof r?n.parseKey(r):(e.hasPrivateKeyProperty(r)||e.hasPublicKeyProperty(r))&&n.parsePropertiesFrom(r)),n}return function(t,e){function r(){this.constructor=t}d(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.parseKey=function(t){try{var e=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?v(t):y.unarmor(t),i=I.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=V(e,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var s=i.sub[3].getHexStringValue();this.d=V(s,16);var o=i.sub[4].getHexStringValue();this.p=V(o,16);var a=i.sub[5].getHexStringValue();this.q=V(a,16);var u=i.sub[6].getHexStringValue();this.dmp1=V(u,16);var h=i.sub[7].getHexStringValue();this.dmq1=V(h,16);var c=i.sub[8].getHexStringValue();this.coeff=V(c,16)}else{if(2!==i.sub.length)return!1;var l=i.sub[1].sub[0];e=l.sub[0].getHexStringValue(),this.n=V(e,16),r=l.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new rt.asn1.DERInteger({int:0}),new rt.asn1.DERInteger({bigint:this.n}),new rt.asn1.DERInteger({int:this.e}),new rt.asn1.DERInteger({bigint:this.d}),new rt.asn1.DERInteger({bigint:this.p}),new rt.asn1.DERInteger({bigint:this.q}),new rt.asn1.DERInteger({bigint:this.dmp1}),new rt.asn1.DERInteger({bigint:this.dmq1}),new rt.asn1.DERInteger({bigint:this.coeff})]};return new rt.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return l(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new rt.asn1.DERSequence({array:[new rt.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new rt.asn1.DERNull]}),e=new rt.asn1.DERSequence({array:[new rt.asn1.DERInteger({bigint:this.n}),new rt.asn1.DERInteger({int:this.e})]}),r=new rt.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new rt.asn1.DERSequence({array:[t,r]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return l(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(!t)return t;var r="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(r,"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.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},e.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}(X),it=function(){function t(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}return t.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new nt(t)},t.prototype.setPrivateKey=function(t){this.setKey(t)},t.prototype.setPublicKey=function(t){this.setKey(t)},t.prototype.decrypt=function(t){try{return this.getKey().decrypt(f(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return l(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",n=0,i=/null$/g;i.test(r)&&(n++,e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",!(n>10)););return e}catch(t){return!1}},t.prototype.decryptLong=function(t){try{return this.getKey().decryptLong(t)}catch(t){return!1}},t.prototype.sign=function(t,e,r){try{return l(this.getKey().sign(t,e,r))}catch(t){return!1}},t.prototype.verify=function(t,e,r){try{return this.getKey().verify(t,f(e),r)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new nt,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},t.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},t.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},t.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},t.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},t.version="3.1.4",t}();window.JSEncrypt=it,t.JSEncrypt=it,t.default=it,Object.defineProperty(t,"__esModule",{value:!0})}(e)},261:(t,e,r)=>{"use strict";r.r(e),r.d(e,{Auth:()=>B,AuthClient:()=>k,CloudbaseOAuth:()=>H,ErrorType:()=>i,OAuth2Client:()=>I,Syntax:()=>n,authModels:()=>h,defaultRequest:()=>E,defaultStorage:()=>_,generateRequestId:()=>S,toResponseError:()=>T});var n,i,s,o,a,u,h={};function c(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}r.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"}(n||(n={})),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_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_TRANS_BY_PROVIDER_URL="/auth/v1/user/trans/by/provider",t.VERIFICATION_URL="/auth/v1/verification",t.VERIFY_URL="/auth/v1/verification/verify",t.PROVIDER_LIST="/auth/v1/user/provider",t.PROVIDER_UNBIND_URL="/auth/v1/user/provider",t.CHECK_PWD_URL="/auth/v1/user/sudo",t.SUDO_URL="/auth/v1/user/sudo",t.BIND_CONTACT_URL="/auth/v1/user/contact",t.AUTH_SET_PASSWORD="/auth/v1/user/password",t.AUTH_RESET_PASSWORD="/auth/v1/reset",t.AUTH_GET_DEVICE_CODE="/auth/v1/device/code",t.CHECK_USERNAME="/auth/v1/checkUsername",t.CHECK_IF_USER_EXIST="/auth/v1/checkIfUserExist"}(s||(s={})),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"}(o||(o={})),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={}));var l=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))},f=function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},p=function(){function t(){this.fnPromiseMap=new Map}return t.prototype.run=function(t,e){return l(this,void 0,void 0,(function(){var r,n=this;return f(this,(function(i){switch(i.label){case 0:return[4,r=this.fnPromiseMap.get(t)];case 1:return i.sent()||(r=new Promise((function(r,i){l(n,void 0,void 0,(function(){var n,s,o;return f(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return a.sent(),n=e(),s=r,[4,n];case 2:return s.apply(void 0,[a.sent()]),[3,5];case 3:return o=a.sent(),i(o),[3,5];case 4:return this.fnPromiseMap.delete(t),[7];case 5:return[2]}}))}))})),this.fnPromiseMap.set(t,r)),[2,r]}}))}))},t.prototype.runIdlePromise=function(){return Promise.resolve()},t}(),d=function(){return d=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},d.apply(this,arguments)},g=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))},v=function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},y="x-request-id",m="x-device-id",b="device_id",E=function(t,e){return g(this,void 0,void 0,(function(){var r,n,s,o,a;return v(this,(function(u){switch(u.label){case 0:r=null,n=null,u.label=1;case 1:return u.trys.push([1,4,,5]),(s=Object.assign({},e)).method||(s.method="GET"),s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body)),[4,fetch(t,s)];case 2:return[4,u.sent().json()];case 3:return(null==(o=u.sent())?void 0:o.error)?(n=o).error_uri=new URL(t).pathname:r=o,[3,5];case 4:return a=u.sent(),n={error:i.UNREACHABLE,error_description:a.message,error_uri:new URL(t).pathname},[3,5];case 5:if(n)throw n;return[2,r]}}))}))},T=function(t,e){var r,n=e||{};if(t instanceof Error)r={error:n.error||i.LOCAL,error_description:n.error_description||t.message,error_uri:n.error_uri,details:n.details||t.stack};else{var s=t||{};r={error:n.error||s.error||i.LOCAL,error_description:n.error_description||s.error_description,error_uri:n.error_uri||s.error_uri,details:n.details||s.details}}return r};function S(){return c()}var _=new(function(){function t(){}return t.prototype.getItem=function(t){return g(this,void 0,void 0,(function(){return v(this,(function(e){return[2,window.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return g(this,void 0,void 0,(function(){return v(this,(function(e){return window.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return g(this,void 0,void 0,(function(){return v(this,(function(r){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 R(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 w=function(){function t(t){this.credentials=null,this.singlePromise=new p,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 g(this,void 0,void 0,(function(){var e;return v(this,(function(r){switch(r.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:r.sent(),r.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:r.sent(),r.label=5;case 5:this.credentials=null,r.label=6;case 6:return[2]}}))}))},t.prototype.getCredentials=function(){return g(this,void 0,void 0,(function(){var t=this;return v(this,(function(e){return[2,this.singlePromise.run("getCredentials",(function(){return g(t,void 0,void 0,(function(){var t;return v(this,(function(e){switch(e.label){case 0:return R(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 g(this,void 0,void 0,(function(){var t=this;return v(this,(function(e){return[2,this.singlePromise.run("_getStorageCredentials",(function(){return g(t,void 0,void 0,(function(){var t,e;return v(this,(function(r){switch(r.label){case 0:return t=null,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=r.sent()))return[3,5];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),[3,5];case 3:return r.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),t=null,[3,5];case 5:return[2,t]}}))}))}))]}))}))},t}(),I=function(){function t(e){this.singlePromise=new p,this.apiOrigin=e.apiOrigin,this.clientId=e.clientId,this.retry=this.formatRetry(e.retry,t.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=E,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||_,this.localCredentials=new w({tokenSectionName:"credentials_".concat(e.clientId),storage:this.storage}),this.clientSecret=e.clientSecret,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 g(this,void 0,void 0,(function(){var t,e;return v(this,(function(r){switch(r.label){case 0:return[4,this.getCredentials()];case 1:return(null==(t=r.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,r){return g(this,void 0,void 0,(function(){var n,s,o,a,u,h,c;return v(this,(function(l){switch(l.label){case 0:return r||(r={}),n=this.formatRetry(r.retry,this.retry),r.headers=r.headers||{},this.headers&&(r.headers=d(d({},this.headers),r.headers)),r.headers[y]||(r.headers[y]=S()),r.headers[m]?[3,2]:[4,this.getDeviceId()];case 1:s=l.sent(),r.headers[m]=s,l.label=2;case 2:return(null==r?void 0:r.withCredentials)?[4,this.getCredentials()]:[3,4];case 3:return(o=l.sent())&&(this.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token=".concat(o.access_token)):r.headers.Authorization="".concat(o.token_type," ").concat(o.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=n+1,h=0,l.label=6;case 6:if(!(h<u))return[3,15];l.label=7;case 7:return l.trys.push([7,9,,12]),[4,this.baseRequest(e,r)];case 8:return a=l.sent(),[3,15];case 9:return c=l.sent(),r.withCredentials&&c&&c.error===i.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,11];case 10:return l.sent(),[2,Promise.reject(c)];case 11:return h!==n&&c&&"unreachable"===c.error?[3,12]:[2,Promise.reject(c)];case 12:return[4,this.sleep(t.retryInterval)];case 13:l.sent(),l.label=14;case 14:return h++,[3,6];case 15:return[2,a]}}))}))},t.prototype.getCredentials=function(){return g(this,void 0,void 0,(function(){var t,e,r;return v(this,(function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return R(t=n.sent())?t&&"anonymous"===t.scope?this.anonymousSignInFunc?[4,this.anonymousSignInFunc(t)]:[3,5]:[3,8]:[3,10];case 2:return e=n.sent(),(r=e)?[3,4]:[4,this.localCredentials.getCredentials()];case 3:r=n.sent(),n.label=4;case 4:return t=r,[3,7];case 5:return[4,this.anonymousSignIn(t)];case 6:t=n.sent(),n.label=7;case 7:return[3,10];case 8:return[4,this.refreshToken(t)];case 9:t=n.sent(),n.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 g(this,void 0,void 0,(function(){var t;return v(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 g(this,void 0,void 0,(function(){var t;return v(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 g(this,void 0,void 0,(function(){var e=this;return v(this,(function(r){return[2,this.singlePromise.run("_refreshToken",(function(){return g(e,void 0,void 0,(function(){var e,r;return v(this,(function(n){switch(n.label){case 0:if(!t||!t.refresh_token)return[2,this.unAuthenticatedError("no refresh token found in credentials")];n.label=1;case 1:return n.trys.push([1,4,,7]),[4,this.refreshTokenFunc(t.refresh_token,t)];case 2:return e=n.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return n.sent(),[2,e];case 4:return(r=n.sent()).error!==i.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return n.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}}))}))}))]}))}))},t.prototype.checkRetry=function(e){var r=null;if(("number"!=typeof e||e<t.minRetry||e>t.maxRetry)&&(r={error:i.UNREACHABLE,error_description:"wrong options param: retry"}),r)throw r;return e},t.prototype.formatRetry=function(t,e){return void 0===t?e:this.checkRetry(t)},t.prototype.sleep=function(t){return g(this,void 0,void 0,(function(){return v(this,(function(e){return[2,new Promise((function(e){setTimeout((function(){e()}),t)}))]}))}))},t.prototype.anonymousSignIn=function(t){return g(this,void 0,void 0,(function(){var e=this;return v(this,(function(r){return[2,this.singlePromise.run("_anonymous",(function(){return g(e,void 0,void 0,(function(){var e,r;return v(this,(function(n){switch(n.label){case 0:if(!t||"anonymous"!==t.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];n.label=1;case 1:return n.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=n.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return n.sent(),[2,e];case 4:return(r=n.sent()).error!==i.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return n.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}}))}))}))]}))}))},t.prototype.defaultRefreshTokenFunc=function(t,e){return g(this,void 0,void 0,(function(){var r,n;return v(this,(function(i){switch(i.label){case 0:return void 0===t||""===t?[2,this.unAuthenticatedError("refresh token not found")]:(r=s.AUTH_TOKEN_URL,"v2"===(null==e?void 0:e.version)&&(r=o.AUTH_TOKEN_URL),[4,this.request(r,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}})]);case 1:return n=i.sent(),[2,d(d({},n),{version:(null==e?void 0:e.version)||"v1"})]}}))}))},t.prototype.getDeviceId=function(){return g(this,void 0,void 0,(function(){var t;return v(this,(function(e){switch(e.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(b)];case 1:return"string"==typeof(t=e.sent())&&t.length>=16&&t.length<=48?[3,3]:(t=c(),[4,this.storage.setItem(b,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}(),D=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))},O=function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},A=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=_),this.config=t,this.tokenSectionName="captcha_".concat(t.clientId)}return t.prototype.request=function(t,e){return D(this,void 0,void 0,(function(){var r,n,i,s;return O(this,(function(o){switch(o.label){case 0:return e||(e={}),e.method||(e.method="GET"),r="".concat(e.method,":").concat(t),n=t,e.withCaptcha?[4,this.appendCaptchaTokenToURL(t,r,!1)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return o.trys.push([2,4,,7]),[4,this.config.request(n,e)];case 3:return i=o.sent(),[3,7];case 4:return"captcha_required"!==(s=o.sent()).error&&"captcha_invalid"!==s.error?[3,6]:[4,this.appendCaptchaTokenToURL(t,r,"captcha_invalid"===s.error)];case 5:return t=o.sent(),[2,this.config.request(t,e)];case 6:return[2,Promise.reject(s)];case 7:return[2,i]}}))}))},t.prototype.getDefaultOpenURIWithCallback=function(){if(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap")){var t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((function(){document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback},t.prototype.defaultOpenURIWithCallback=function(t){return D(this,void 0,void 0,(function(){var e,r;return O(this,(function(n){return e=document.getElementById("captcha_panel_wrap"),r=document.createElement("iframe"),e.innerHTML="",r.setAttribute("src",t),r.setAttribute("id","review-panel-iframe"),r.style.cssText="min-width:355px;display:block;height:355px;margin:0 auto;background-color: rgb(255, 255, 255);border: none;",e.appendChild(r),e.style.display="block",[2,new Promise((function(t,n){r.onload=function(){try{var i=window.location,s=r.contentWindow.location;if(s.host+s.pathname===i.host+i.pathname){e.style.display="none";var o=new URLSearchParams(s.search),a=o.get("captcha_token");return a?t({captcha_token:a,expires_in:Number(o.get("expires_in"))}):n({error:o.get("error"),error_description:o.get("error_description")})}e.style.display="block"}catch(t){e.style.display="block"}}}))]}))}))},t.prototype.getCaptchaToken=function(t,e){return D(this,void 0,void 0,(function(){var r,n,i,s,o;return O(this,(function(a){switch(a.label){case 0:return t?[3,2]:[4,this.findCaptchaToken()];case 1:if(r=a.sent())return[2,r];a.label=2;case 2:return n="".concat(window.location.origin+window.location.pathname,"?__captcha=on"),[4,this.config.request("/auth/v1/captcha/init",{method:"POST",body:{client_id:this.config.clientId,redirect_uri:n,state:e},withCredentials:!1})];case 3:return(i=a.sent()).captcha_token?(s={captcha_token:i.captcha_token,expires_in:i.expires_in},this.saveCaptchaToken(s),[2,i.captcha_token]):[4,this.config.openURIWithCallback(i.url)];case 4:return o=a.sent(),this.saveCaptchaToken(o),[2,o.captcha_token]}}))}))},t.prototype.appendCaptchaTokenToURL=function(t,e,r){return D(this,void 0,void 0,(function(){var n;return O(this,(function(i){switch(i.label){case 0:return[4,this.getCaptchaToken(r,e)];case 1:return n=i.sent(),t.indexOf("?")>0?t+="&captcha_token=".concat(n):t+="?captcha_token=".concat(n),[2,t]}}))}))},t.prototype.saveCaptchaToken=function(t){return D(this,void 0,void 0,(function(){var e;return O(this,(function(r){switch(r.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 r.sent(),[2]}}))}))},t.prototype.findCaptchaToken=function(){return D(this,void 0,void 0,(function(){var t,e;return O(this,(function(r){switch(r.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(t=r.sent()))return[3,5];r.label=2;case 2:return r.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 r.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),[2,null];case 5:return[2,null]}}))}))},t}(),N=function(t){var e=function(e){for(var r in t)t.hasOwnProperty(r)&&(e[r]=N(t[r]));return e},r=null==t?"NullOrUndefined":Object.prototype.toString.call(t).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return t.slice();switch(r){case"Object":return e(Object.create(Object.getPrototypeOf(t)));case"Array":return e([]);case"Date":return new Date(t.valueOf());case"RegExp":return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""));default:return t}},x=r(550),P=r.n(x),C=function(t){var e=void 0===t?{}:t,r=e.publicKey,n=void 0===r?"":r,i=e.payload,s=void 0===i?{}:i;if(!n)return"";try{var o=N(s),a=new(P());return a.setPublicKey(n),a.encryptLong(JSON.stringify(o))}catch(t){}return""},U=function(){return U=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},U.apply(this,arguments)},L=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))},V=function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},B=function(){function t(t){var e=t.request,r=t.credentialsClient;if(!r){var n={apiOrigin:t.apiOrigin,clientId:t.clientId,storage:t.storage};r=new I(n)}if(!e){var i=r.request.bind(r),s=new A({clientId:t.clientId,request:i,storage:t.storage});e=s.request.bind(s)}this.config={apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:r,storage:t.storage||_}}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 r,n=N(t),i=(null===(r={v2:o}[null==n?void 0:n.version])||void 0===r?void 0:r[e])||s[e];return n&&delete n.version,{params:n,url:i}},t.prototype.signIn=function(t){return L(this,void 0,void 0,(function(){var e,r,n,i;return V(this,(function(s){switch(s.label){case 0:return e=t.version||"v1",(r=this.getParamsByVersion(t,"AUTH_SIGN_IN_URL")).params.query&&delete r.params.query,[4,this.getEncryptParams(r.params)];case 1:return n=s.sent(),[4,this.config.request(r.url,{method:"POST",body:n})];case 2:return i=s.sent(),[4,this.config.credentialsClient.setCredentials(U(U({},i),{version:e}))];case 3:return s.sent(),[2,Promise.resolve(i)]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),L(this,void 0,void 0,(function(){var e;return V(this,(function(r){switch(r.label){case 0:return[4,this.config.request(s.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t})];case 1:return e=r.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return r.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signUp=function(t){return L(this,void 0,void 0,(function(){var e;return V(this,(function(r){switch(r.label){case 0:return[4,this.config.request(s.AUTH_SIGN_UP_URL,{method:"POST",body:t})];case 1:return e=r.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return r.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signOut=function(){return L(this,void 0,void 0,(function(){var t,e;return V(this,(function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getAccessToken()];case 1:return t=r.sent(),[4,this.config.request(s.AUTH_REVOKE_URL,{method:"POST",body:{token:t}})];case 2:return e=r.sent(),[4,this.config.credentialsClient.setCredentials()];case 3:return r.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.getVerification=function(t){return L(this,void 0,void 0,(function(){var e;return V(this,(function(r){switch(r.label){case 0:return e=!1,"CUR_USER"!==t.target?[3,1]:(e=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:r.sent()&&(e=!0),r.label=3;case 3:return[2,this.config.request(s.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:!0,withCredentials:e})]}}))}))},t.prototype.verify=function(t){return L(this,void 0,void 0,(function(){var e,r;return V(this,(function(n){switch(n.label){case 0:return e=this.getParamsByVersion(t,"VERIFY_URL"),[4,this.config.request(e.url,{method:"POST",body:e.params})];case 1:return r=n.sent(),"v2"!==(null==t?void 0:t.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(U(U({},r),{version:"v2"}))];case 2:n.sent(),n.label=3;case 3:return[2,r]}}))}))},t.prototype.genProviderRedirectUri=function(t){return L(this,void 0,void 0,(function(){var e,r;return V(this,(function(n){return e="".concat(s.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),(r=t.other_params)&&"string"==typeof r.sign_out_uri&&r.sign_out_uri.length>0&&(e+="&other_params[sign_out_uri]=".concat(r.sign_out_uri)),[2,this.config.request(e,{method:"GET"})]}))}))},t.prototype.grantProviderToken=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request(s.PROVIDER_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.patchProviderToken=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request(s.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]}))}))},t.prototype.signInWithProvider=function(t){return L(this,void 0,void 0,(function(){var e,r;return V(this,(function(n){switch(n.label){case 0:return e=this.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(e.url,{method:"POST",body:e.params})];case 1:return r=n.sent(),[4,this.config.credentialsClient.setCredentials(U(U({},r),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return n.sent(),[2,Promise.resolve(r)]}}))}))},t.prototype.bindWithProvider=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request(s.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.getUserProfile=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.getUserInfo(t)]}))}))},t.prototype.getUserInfo=function(t){var e;return void 0===t&&(t={}),L(this,void 0,void 0,(function(){var r,n,i;return V(this,(function(s){switch(s.label){case 0:return r=this.getParamsByVersion(t,"USER_ME_URL"),(null===(e=r.params)||void 0===e?void 0:e.query)&&(n=new URLSearchParams(r.params.query),r.url+="?".concat(n.toString())),[4,this.config.request(r.url,{method:"GET",withCredentials:!0})];case 1:return(i=s.sent()).sub&&(i.uid=i.sub),[2,i]}}))}))},t.prototype.getWedaUserInfo=function(){return L(this,void 0,void 0,(function(){return V(this,(function(t){switch(t.label){case 0:return[4,this.config.request(s.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,t.sent()]}}))}))},t.prototype.deleteMe=function(e){return L(this,void 0,void 0,(function(){var r,n;return V(this,(function(i){return r=this.getParamsByVersion(e,"USER_ME_URL"),n="".concat(r.url,"?").concat(t.parseParamsToSearch(r.params)),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.hasLoginState=function(){return L(this,void 0,void 0,(function(){return V(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 L(this,void 0,void 0,(function(){return V(this,(function(t){return[2,this.config.credentialsClient.getCredentialsAsync()]}))}))},t.prototype.transByProvider=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request(s.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.grantToken=function(t){return L(this,void 0,void 0,(function(){var e;return V(this,(function(r){return e=this.getParamsByVersion(t,"AUTH_TOKEN_URL"),[2,this.config.request(e.url,{method:"POST",body:e.params})]}))}))},t.prototype.getProviders=function(){return L(this,void 0,void 0,(function(){return V(this,(function(t){return[2,this.config.request(s.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},t.prototype.unbindProvider=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request("".concat(s.PROVIDER_UNBIND_URL,"/").concat(t.provider_id),{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.checkPassword=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request("".concat(s.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.bindPhone=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request("".concat(s.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.bindEmail=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request("".concat(s.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.setPassword=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request("".concat(s.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.updatePasswordByOld=function(t){return L(this,void 0,void 0,(function(){var e;return V(this,(function(r){switch(r.label){case 0:return[4,this.sudo({password:t.old_password})];case 1:return e=r.sent(),[2,this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})]}}))}))},t.prototype.sudo=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request("".concat(s.SUDO_URL),{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.getCurUserVerification=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return t.target="CUR_USER",[2,this.config.request(s.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]}))}))},t.prototype.changeBindedProvider=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request("".concat(s.PROVIDER_LIST,"/").concat(t.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})]}))}))},t.prototype.setUserProfile=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request(s.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.queryUserProfile=function(t){return L(this,void 0,void 0,(function(){var e;return V(this,(function(r){return e=new URLSearchParams(t),[2,this.config.request("".concat(s.USER_QUERY_URL,"?").concat(e.toString()),{method:"GET",withCredentials:!0})]}))}))},t.prototype.setCustomSignFunc=function(t){this.getCustomSignTicketFn=t},t.prototype.signInWithCustomTicket=function(t){return L(this,void 0,void 0,(function(){var e;return V(this,(function(r){switch(r.label){case 0:return[4,this.getCustomSignTicketFn()];case 1:return e=r.sent(),[2,this.signInWithProvider(U(U({},t),{provider_id:"custom",provider_token:e}))]}}))}))},t.prototype.resetPassword=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request(s.AUTH_RESET_PASSWORD,{method:"POST",body:t})]}))}))},t.prototype.deviceAuthorize=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request(s.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.checkUsername=function(t){return L(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this.config.request(s.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]}))}))},t.prototype.checkIfUserExist=function(t){return L(this,void 0,void 0,(function(){var e;return V(this,(function(r){return e=new URLSearchParams(t),[2,this.config.request("".concat(s.CHECK_IF_USER_EXIST,"?").concat(e.toString()),{method:"GET"})]}))}))},t.prototype.loginScope=function(){return L(this,void 0,void 0,(function(){return V(this,(function(t){return[2,this.config.credentialsClient.getScope()]}))}))},t.prototype.loginGroups=function(){return L(this,void 0,void 0,(function(){return V(this,(function(t){return[2,this.config.credentialsClient.getGroups()]}))}))},t.prototype.refreshTokenForce=function(t){return L(this,void 0,void 0,(function(){var e;return V(this,(function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return e=r.sent(),[4,this.config.credentialsClient.refreshToken(U(U({},e),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return[2,r.sent()]}}))}))},t.prototype.getCredentials=function(){return L(this,void 0,void 0,(function(){return V(this,(function(t){return[2,this.config.credentialsClient.getCredentials()]}))}))},t.prototype.getPublicKey=function(){return L(this,void 0,void 0,(function(){return V(this,(function(t){return[2,this.config.request(o.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]}))}))},t.prototype.getEncryptParams=function(t){return L(this,void 0,void 0,(function(){var e,r,n,i;return V(this,(function(s){switch(s.label){case 0:if(!(e=N(t)).isEncrypt)return[2,t];r="",n="",s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.getPublicKey()];case 2:return i=s.sent(),r=i.public_key,n=i.public_key_thumbprint,[3,4];case 3:return s.sent(),[3,4];case 4:if(!r||!n)throw new Error("public_key or public_key_thumbprint is empty");return delete e.isEncrypt,[2,{params:C({publicKey:r,payload:e}),public_key_thumbprint:n}]}}))}))},t}(),k=function(){},q=function(){return q=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},q.apply(this,arguments)},H=function(t){var e=t.apiOrigin,r=t.clientId,n=t.storage,i=t.request,s=t.anonymousSignInFunc;this.oauth2client=new I({apiOrigin:e,clientId:r,storage:n,baseRequest:i,anonymousSignInFunc:s}),this.authApi=new B(q(q({credentialsClient:this.oauth2client},t),{request:i?this.oauth2client.request.bind(this.oauth2client):void 0}))}},118:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(261),e)}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,r),s.exports}return r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r(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={406:(t,e,r)=>{r.r(e),r.d(e,{Auth:()=>Ht,AuthClient:()=>Mt,CloudbaseOAuth:()=>Ft,ErrorType:()=>i,OAuth2Client:()=>D,Syntax:()=>n,authModels:()=>h,defaultRequest:()=>E,defaultStorage:()=>_,generateRequestId:()=>S,toResponseError:()=>T});var n,i,s,o,a,u,h={};function c(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}r.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"}(n||(n={})),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_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_TRANS_BY_PROVIDER_URL="/auth/v1/user/trans/by/provider",t.VERIFICATION_URL="/auth/v1/verification",t.VERIFY_URL="/auth/v1/verification/verify",t.PROVIDER_LIST="/auth/v1/user/provider",t.PROVIDER_UNBIND_URL="/auth/v1/user/provider",t.CHECK_PWD_URL="/auth/v1/user/sudo",t.SUDO_URL="/auth/v1/user/sudo",t.BIND_CONTACT_URL="/auth/v1/user/contact",t.AUTH_SET_PASSWORD="/auth/v1/user/password",t.AUTH_RESET_PASSWORD="/auth/v1/reset",t.AUTH_GET_DEVICE_CODE="/auth/v1/device/code",t.CHECK_USERNAME="/auth/v1/checkUsername",t.CHECK_IF_USER_EXIST="/auth/v1/checkIfUserExist",t.GET_PROVIDER_TYPE="/auth/v1/mgr/provider/providerSubType"}(s||(s={})),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"}(o||(o={})),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={}));var l=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))},f=function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},d=function(){function t(){this.fnPromiseMap=new Map}return t.prototype.run=function(t,e){return l(this,void 0,void 0,(function(){var r,n=this;return f(this,(function(i){switch(i.label){case 0:return[4,r=this.fnPromiseMap.get(t)];case 1:return i.sent()||(r=new Promise((function(r,i){l(n,void 0,void 0,(function(){var n,s,o;return f(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return a.sent(),n=e(),s=r,[4,n];case 2:return s.apply(void 0,[a.sent()]),[3,5];case 3:return o=a.sent(),i(o),[3,5];case 4:return this.fnPromiseMap.delete(t),[7];case 5:return[2]}}))}))})),this.fnPromiseMap.set(t,r)),[2,r]}}))}))},t.prototype.runIdlePromise=function(){return Promise.resolve()},t}(),p=function(){return p=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},p.apply(this,arguments)},g=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))},v=function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},y="x-request-id",m="x-device-id",b="device_id",E=function(t,e){return g(this,void 0,void 0,(function(){var r,n,s,o,a;return v(this,(function(u){switch(u.label){case 0:r=null,n=null,u.label=1;case 1:return u.trys.push([1,4,,5]),(s=Object.assign({},e)).method||(s.method="GET"),s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body)),[4,fetch(t,s)];case 2:return[4,u.sent().json()];case 3:return(null==(o=u.sent())?void 0:o.error)?(n=o).error_uri=new URL(t).pathname:r=o,[3,5];case 4:return a=u.sent(),n={error:i.UNREACHABLE,error_description:a.message,error_uri:new URL(t).pathname},[3,5];case 5:if(n)throw n;return[2,r]}}))}))},T=function(t,e){var r,n=e||{};if(t instanceof Error)r={error:n.error||i.LOCAL,error_description:n.error_description||t.message,error_uri:n.error_uri,details:n.details||t.stack};else{var s=t||{};r={error:n.error||s.error||i.LOCAL,error_description:n.error_description||s.error_description,error_uri:n.error_uri||s.error_uri,details:n.details||s.details}}return r};function S(){return c()}var _=new(function(){function t(){}return t.prototype.getItem=function(t){return g(this,void 0,void 0,(function(){return v(this,(function(e){return[2,window.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return g(this,void 0,void 0,(function(){return v(this,(function(e){return window.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return g(this,void 0,void 0,(function(){return v(this,(function(r){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 w(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 R,I=function(){function t(t){this.credentials=null,this.singlePromise=new d,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 g(this,void 0,void 0,(function(){var e;return v(this,(function(r){switch(r.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:r.sent(),r.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:r.sent(),r.label=5;case 5:this.credentials=null,r.label=6;case 6:return[2]}}))}))},t.prototype.getCredentials=function(){return g(this,void 0,void 0,(function(){var t=this;return v(this,(function(e){return[2,this.singlePromise.run("getCredentials",(function(){return g(t,void 0,void 0,(function(){var t;return v(this,(function(e){switch(e.label){case 0:return w(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 g(this,void 0,void 0,(function(){var t=this;return v(this,(function(e){return[2,this.singlePromise.run("_getStorageCredentials",(function(){return g(t,void 0,void 0,(function(){var t,e;return v(this,(function(r){switch(r.label){case 0:return t=null,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=r.sent()))return[3,5];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),[3,5];case 3:return r.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),t=null,[3,5];case 5:return[2,t]}}))}))}))]}))}))},t}(),D=function(){function t(e){this.singlePromise=new d,this.apiOrigin=e.apiOrigin,this.clientId=e.clientId,this.retry=this.formatRetry(e.retry,t.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=E,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||_,this.localCredentials=new I({tokenSectionName:"credentials_".concat(e.clientId),storage:this.storage}),this.clientSecret=e.clientSecret,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 g(this,void 0,void 0,(function(){var t,e;return v(this,(function(r){switch(r.label){case 0:return[4,this.getCredentials()];case 1:return(null==(t=r.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,r){return g(this,void 0,void 0,(function(){var n,s,o,a,u,h,c;return v(this,(function(l){switch(l.label){case 0:return r||(r={}),n=this.formatRetry(r.retry,this.retry),r.headers=r.headers||{},this.headers&&(r.headers=p(p({},this.headers),r.headers)),r.headers[y]||(r.headers[y]=S()),r.headers[m]?[3,2]:[4,this.getDeviceId()];case 1:s=l.sent(),r.headers[m]=s,l.label=2;case 2:return(null==r?void 0:r.withCredentials)?[4,this.getCredentials()]:[3,4];case 3:return(o=l.sent())&&(this.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token=".concat(o.access_token)):r.headers.Authorization="".concat(o.token_type," ").concat(o.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=n+1,h=0,l.label=6;case 6:if(!(h<u))return[3,15];l.label=7;case 7:return l.trys.push([7,9,,12]),[4,this.baseRequest(e,r)];case 8:return a=l.sent(),[3,15];case 9:return c=l.sent(),r.withCredentials&&c&&c.error===i.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,11];case 10:return l.sent(),[2,Promise.reject(c)];case 11:return h!==n&&c&&"unreachable"===c.error?[3,12]:[2,Promise.reject(c)];case 12:return[4,this.sleep(t.retryInterval)];case 13:l.sent(),l.label=14;case 14:return h++,[3,6];case 15:return[2,a]}}))}))},t.prototype.getCredentials=function(){return g(this,void 0,void 0,(function(){var t,e,r;return v(this,(function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return w(t=n.sent())?t&&"anonymous"===t.scope?this.anonymousSignInFunc?[4,this.anonymousSignInFunc(t)]:[3,5]:[3,8]:[3,10];case 2:return e=n.sent(),(r=e)?[3,4]:[4,this.localCredentials.getCredentials()];case 3:r=n.sent(),n.label=4;case 4:return t=r,[3,7];case 5:return[4,this.anonymousSignIn(t)];case 6:t=n.sent(),n.label=7;case 7:return[3,10];case 8:return[4,this.refreshToken(t)];case 9:t=n.sent(),n.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 g(this,void 0,void 0,(function(){var t;return v(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 g(this,void 0,void 0,(function(){var t;return v(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 g(this,void 0,void 0,(function(){var e=this;return v(this,(function(r){return[2,this.singlePromise.run("_refreshToken",(function(){return g(e,void 0,void 0,(function(){var e,r;return v(this,(function(n){switch(n.label){case 0:if(!t||!t.refresh_token)return[2,this.unAuthenticatedError("no refresh token found in credentials")];n.label=1;case 1:return n.trys.push([1,4,,7]),[4,this.refreshTokenFunc(t.refresh_token,t)];case 2:return e=n.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return n.sent(),[2,e];case 4:return(r=n.sent()).error!==i.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return n.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}}))}))}))]}))}))},t.prototype.checkRetry=function(e){var r=null;if(("number"!=typeof e||e<t.minRetry||e>t.maxRetry)&&(r={error:i.UNREACHABLE,error_description:"wrong options param: retry"}),r)throw r;return e},t.prototype.formatRetry=function(t,e){return void 0===t?e:this.checkRetry(t)},t.prototype.sleep=function(t){return g(this,void 0,void 0,(function(){return v(this,(function(e){return[2,new Promise((function(e){setTimeout((function(){e()}),t)}))]}))}))},t.prototype.anonymousSignIn=function(t){return g(this,void 0,void 0,(function(){var e=this;return v(this,(function(r){return[2,this.singlePromise.run("_anonymous",(function(){return g(e,void 0,void 0,(function(){var e,r;return v(this,(function(n){switch(n.label){case 0:if(!t||"anonymous"!==t.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];n.label=1;case 1:return n.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=n.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return n.sent(),[2,e];case 4:return(r=n.sent()).error!==i.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return n.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}}))}))}))]}))}))},t.prototype.defaultRefreshTokenFunc=function(t,e){return g(this,void 0,void 0,(function(){var r,n;return v(this,(function(i){switch(i.label){case 0:return void 0===t||""===t?[2,this.unAuthenticatedError("refresh token not found")]:(r=s.AUTH_TOKEN_URL,"v2"===(null==e?void 0:e.version)&&(r=o.AUTH_TOKEN_URL),[4,this.request(r,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}})]);case 1:return n=i.sent(),[2,p(p({},n),{version:(null==e?void 0:e.version)||"v1"})]}}))}))},t.prototype.getDeviceId=function(){return g(this,void 0,void 0,(function(){var t;return v(this,(function(e){switch(e.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(b)];case 1:return"string"==typeof(t=e.sent())&&t.length>=16&&t.length<=48?[3,3]:(t=c(),[4,this.storage.setItem(b,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}(),O=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))},A=function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},N=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=_),this.config=t,this.tokenSectionName="captcha_".concat(t.clientId)}return t.prototype.request=function(t,e){return O(this,void 0,void 0,(function(){var r,n,i,s;return A(this,(function(o){switch(o.label){case 0:return e||(e={}),e.method||(e.method="GET"),r="".concat(e.method,":").concat(t),n=t,e.withCaptcha?[4,this.appendCaptchaTokenToURL(t,r,!1)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return o.trys.push([2,4,,7]),[4,this.config.request(n,e)];case 3:return i=o.sent(),[3,7];case 4:return"captcha_required"!==(s=o.sent()).error&&"captcha_invalid"!==s.error?[3,6]:[4,this.appendCaptchaTokenToURL(t,r,"captcha_invalid"===s.error)];case 5:return t=o.sent(),[2,this.config.request(t,e)];case 6:return[2,Promise.reject(s)];case 7:return[2,i]}}))}))},t.prototype.getDefaultOpenURIWithCallback=function(){if(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap")){var t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((function(){document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback},t.prototype.defaultOpenURIWithCallback=function(t){return O(this,void 0,void 0,(function(){var e,r;return A(this,(function(n){return e=document.getElementById("captcha_panel_wrap"),r=document.createElement("iframe"),e.innerHTML="",r.setAttribute("src",t),r.setAttribute("id","review-panel-iframe"),r.style.cssText="min-width:355px;display:block;height:355px;margin:0 auto;background-color: rgb(255, 255, 255);border: none;",e.appendChild(r),e.style.display="block",[2,new Promise((function(t,n){r.onload=function(){try{var i=window.location,s=r.contentWindow.location;if(s.host+s.pathname===i.host+i.pathname){e.style.display="none";var o=new URLSearchParams(s.search),a=o.get("captcha_token");return a?t({captcha_token:a,expires_in:Number(o.get("expires_in"))}):n({error:o.get("error"),error_description:o.get("error_description")})}e.style.display="block"}catch(t){e.style.display="block"}}}))]}))}))},t.prototype.getCaptchaToken=function(t,e){return O(this,void 0,void 0,(function(){var r,n,i,s,o;return A(this,(function(a){switch(a.label){case 0:return t?[3,2]:[4,this.findCaptchaToken()];case 1:if(r=a.sent())return[2,r];a.label=2;case 2:return n="".concat(window.location.origin+window.location.pathname,"?__captcha=on"),[4,this.config.request("/auth/v1/captcha/init",{method:"POST",body:{client_id:this.config.clientId,redirect_uri:n,state:e},withCredentials:!1})];case 3:return(i=a.sent()).captcha_token?(s={captcha_token:i.captcha_token,expires_in:i.expires_in},this.saveCaptchaToken(s),[2,i.captcha_token]):[4,this.config.openURIWithCallback(i.url)];case 4:return o=a.sent(),this.saveCaptchaToken(o),[2,o.captcha_token]}}))}))},t.prototype.appendCaptchaTokenToURL=function(t,e,r){return O(this,void 0,void 0,(function(){var n;return A(this,(function(i){switch(i.label){case 0:return[4,this.getCaptchaToken(r,e)];case 1:return n=i.sent(),t.indexOf("?")>0?t+="&captcha_token=".concat(n):t+="?captcha_token=".concat(n),[2,t]}}))}))},t.prototype.saveCaptchaToken=function(t){return O(this,void 0,void 0,(function(){var e;return A(this,(function(r){switch(r.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 r.sent(),[2]}}))}))},t.prototype.findCaptchaToken=function(){return O(this,void 0,void 0,(function(){var t,e;return A(this,(function(r){switch(r.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(t=r.sent()))return[3,5];r.label=2;case 2:return r.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 r.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),[2,null];case 5:return[2,null]}}))}))},t}(),x=function(t){var e=function(e){for(var r in t)t.hasOwnProperty(r)&&(e[r]=x(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}},P=(R=function(t,e){return R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},R(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}R(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),C="0123456789abcdefghijklmnopqrstuvwxyz";function U(t){return C.charAt(t)}function L(t,e){return t&e}function V(t,e){return t|e}function B(t,e){return t^e}function k(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 H(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",j="=";function F(t){var e,r,n="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),n+=M.charAt(r>>6)+M.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=M.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=M.charAt(r>>2)+M.charAt((3&r)<<4));(3&n.length)>0;)n+=j;return n}function K(t){var e,r="",n=0,i=0;for(e=0;e<t.length&&t.charAt(e)!=j;++e){var s=M.indexOf(t.charAt(e));s<0||(0==n?(r+=U(s>>2),i=3&s,n=1):1==n?(r+=U(i<<2|s>>4),i=15&s,n=2):2==n?(r+=U(i),r+=U(s>>2),i=3&s,n=3):(r+=U(i<<2|s>>4),r+=U(15&s),n=0))}return 1==n&&(r+=U(i<<2)),r}var G,W,Y={decode:function(t){var e;if(void 0===W){var r="= \f\n\r\t \u2028\u2029";for(W=Object.create(null),e=0;e<64;++e)W["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<r.length;++e)W[r.charAt(e)]=-1}var n=[],i=0,s=0;for(e=0;e<t.length;++e){var o=t.charAt(e);if("="==o)break;if(-1!=(o=W[o])){if(void 0===o)throw new Error("Illegal character at offset "+e);i|=o,++s>=4?(n[n.length]=i>>16,n[n.length]=i>>8&255,n[n.length]=255&i,i=0,s=0):i<<=6}}switch(s){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=i>>10;break;case 3:n[n.length]=i>>16,n[n.length]=i>>8&255}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=Y.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 Y.decode(t)}},z=1e13,Z=function(){function t(t){this.buf=[+t||0]}return t.prototype.mulAdd=function(t,e){var r,n,i=this.buf,s=i.length;for(r=0;r<s;++r)(n=i[r]*t+e)<z?e=0:n-=(e=0|n/z)*z,i[r]=n;e>0&&(i[r]=e)},t.prototype.sub=function(t){var e,r,n=this.buf,i=n.length;for(e=0;e<i;++e)(r=n[e]-t)<0?(r+=z,t=1):t=0,n[e]=r;for(;0===n[n.length-1];)n.pop()},t.prototype.toString=function(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),n=e.length-2;n>=0;--n)r+=(z+e[n]).toString().substring(1);return r},t.prototype.valueOf=function(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*z+t[r];return e},t.prototype.simplify=function(){var t=this.buf;return 1==t.length?t[0]:this},t}(),Q="…",$=/^(\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)?)?$/,X=/^(\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 J(t,e){return t.length>e&&(t=t.substring(0,e)+Q),t}var tt,et=function(){function t(e,r){this.hexDigits="0123456789ABCDEF",e instanceof t?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=r)}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,r){for(var n="",i=t;i<e;++i)if(n+=this.hexByte(this.get(i)),!0!==r)switch(15&i){case 7:n+=" ";break;case 15:n+="\n";break;default:n+=" "}return n},t.prototype.isASCII=function(t,e){for(var r=t;r<e;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0},t.prototype.parseStringISO=function(t,e){for(var r="",n=t;n<e;++n)r+=String.fromCharCode(this.get(n));return r},t.prototype.parseStringUTF=function(t,e){for(var r="",n=t;n<e;){var i=this.get(n++);r+=i<128?String.fromCharCode(i):i>191&&i<224?String.fromCharCode((31&i)<<6|63&this.get(n++)):String.fromCharCode((15&i)<<12|(63&this.get(n++))<<6|63&this.get(n++))}return r},t.prototype.parseStringBMP=function(t,e){for(var r,n,i="",s=t;s<e;)r=this.get(s++),n=this.get(s++),i+=String.fromCharCode(r<<8|n);return i},t.prototype.parseTime=function(t,e,r){var n=this.parseStringISO(t,e),i=(r?$:X).exec(n);return i?(r&&(i[1]=+i[1],i[1]+=+i[1]<70?2e3:1900),n=i[1]+"-"+i[2]+"-"+i[3]+" "+i[4],i[5]&&(n+=":"+i[5],i[6]&&(n+=":"+i[6],i[7]&&(n+="."+i[7]))),i[8]&&(n+=" UTC","Z"!=i[8]&&(n+=i[8],i[9]&&(n+=":"+i[9]))),n):"Unrecognized time: "+n},t.prototype.parseInteger=function(t,e){for(var r,n=this.get(t),i=n>127,s=i?255:0,o="";n==s&&++t<e;)n=this.get(t);if(0==(r=e-t))return i?-1:0;if(r>4){for(o=n,r<<=3;0==(128&(+o^s));)o=+o<<1,--r;o="("+r+" bit)\n"}i&&(n-=256);for(var a=new Z(n),u=t+1;u<e;++u)a.mulAdd(256,this.get(u));return o+a.toString()},t.prototype.parseBitString=function(t,e,r){for(var n=this.get(t),i="("+((e-t-1<<3)-n)+" bit)\n",s="",o=t+1;o<e;++o){for(var a=this.get(o),u=o==e-1?n:0,h=7;h>=u;--h)s+=a>>h&1?"1":"0";if(s.length>r)return i+J(s,r)}return i+s},t.prototype.parseOctetString=function(t,e,r){if(this.isASCII(t,e))return J(this.parseStringISO(t,e),r);var n=e-t,i="("+n+" byte)\n";n>(r/=2)&&(e=t+r);for(var s=t;s<e;++s)i+=this.hexByte(this.get(s));return n>r&&(i+=Q),i},t.prototype.parseOID=function(t,e,r){for(var n="",i=new Z,s=0,o=t;o<e;++o){var a=this.get(o);if(i.mulAdd(128,127&a),s+=7,!(128&a)){if(""===n)if((i=i.simplify())instanceof Z)i.sub(80),n="2."+i.toString();else{var u=i<80?i<40?0:1:2;n=u+"."+(i-40*u)}else n+="."+i.toString();if(n.length>r)return J(n,r);i=new Z,s=0}}return s>0&&(n+=".incomplete"),n},t}(),rt=function(){function t(t,e,r,n,i){if(!(n instanceof nt))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=n,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(),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 J(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return J(this.stream.parseStringISO(e,e+r),t);case 30:return J(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+r,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 r=0,n=this.sub.length;r<n;++r)e+=this.sub[r].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(),r=127&e;if(r==e)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var n=0;n<r;++n)e=256*e+t.get();return e},t.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)},t.decode=function(e){var r;r=e instanceof et?e:new et(e,0);var n=new et(r),i=new nt(r),s=t.decodeLength(r),o=r.pos,a=o-n.pos,u=null,h=function(){var e=[];if(null!==s){for(var n=o+s;r.pos<n;)e[e.length]=t.decode(r);if(r.pos!=n)throw new Error("Content size is not correct for container starting at offset "+o)}else try{for(;;){var i=t.decode(r);if(i.tag.isEOC())break;e[e.length]=i}s=o-r.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return e};if(i.tagConstructed)u=h();else if(i.isUniversal()&&(3==i.tagNumber||4==i.tagNumber))try{if(3==i.tagNumber&&0!=r.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");u=h();for(var c=0;c<u.length;++c)if(u[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){u=null}if(null===u){if(null===s)throw new Error("We can't skip over an invalid tag with undefined length at offset "+o);r.pos=o+Math.abs(s)}return new t(n,a,s,i,u)},t}(),nt=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 r=new Z;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}return t.prototype.isUniversal=function(){return 0===this.tagClass},t.prototype.isEOC=function(){return 0===this.tagClass&&0===this.tagNumber},t}(),it=[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],st=(1<<26)/it[it.length-1],ot=function(){function t(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))}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 r,n=(1<<e)-1,i=!1,s="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(i=!0,s=U(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)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=U(r));return i?s:"0"},t.prototype.negate=function(){var e=lt();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 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},t.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+mt(this[this.t-1]^this.s&this.DM)},t.prototype.mod=function(e){var r=lt();return this.abs().divRemTo(e,null,r),this.s<0&&r.compareTo(t.ZERO)>0&&e.subTo(r,r),r},t.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new ut(e):new ht(e),this.exp(t,r)},t.prototype.clone=function(){var t=lt();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 r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},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=lt();return this.bitwiseTo(t,L,e),e},t.prototype.or=function(t){var e=lt();return this.bitwiseTo(t,V,e),e},t.prototype.xor=function(t){var e=lt();return this.bitwiseTo(t,B,e),e},t.prototype.andNot=function(t){var e=lt();return this.bitwiseTo(t,k,e),e},t.prototype.not=function(){for(var t=lt(),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=lt();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},t.prototype.shiftRight=function(t){var e=lt();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,r=0;r<this.t;++r)t+=H(this[r]^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,V)},t.prototype.clearBit=function(t){return this.changeBit(t,k)},t.prototype.flipBit=function(t){return this.changeBit(t,B)},t.prototype.add=function(t){var e=lt();return this.addTo(t,e),e},t.prototype.subtract=function(t){var e=lt();return this.subTo(t,e),e},t.prototype.multiply=function(t){var e=lt();return this.multiplyTo(t,e),e},t.prototype.divide=function(t){var e=lt();return this.divRemTo(t,e,null),e},t.prototype.remainder=function(t){var e=lt();return this.divRemTo(t,null,e),e},t.prototype.divideAndRemainder=function(t){var e=lt(),r=lt();return this.divRemTo(t,e,r),[e,r]},t.prototype.modPow=function(t,e){var r,n,i=t.bitLength(),s=yt(1);if(i<=0)return s;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new ut(e):e.isEven()?new ct(e):new ht(e);var o=[],a=3,u=r-1,h=(1<<r)-1;if(o[1]=n.convert(this),r>1){var c=lt();for(n.sqrTo(o[1],c);a<=h;)o[a]=lt(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,p=!0,g=lt();for(i=mt(t[d])-1;d>=0;){for(i>=u?l=t[d]>>i-u&h:(l=(t[d]&(1<<i+1)-1)<<u-i,d>0&&(l|=t[d-1]>>this.DB+i-u)),a=r;0==(1&l);)l>>=1,--a;if((i-=a)<0&&(i+=this.DB,--d),p)o[l].copyTo(s),p=!1;else{for(;a>1;)n.sqrTo(s,g),n.sqrTo(g,s),a-=2;a>0?n.sqrTo(s,g):(f=s,s=g,g=f),n.mulTo(g,o[l],s)}for(;d>=0&&0==(t[d]&1<<i);)n.sqrTo(s,g),f=s,s=g,g=f,--i<0&&(i=this.DB-1,--d)}return n.revert(s)},t.prototype.modInverse=function(e){var r=e.isEven();if(this.isEven()&&r||0==e.signum())return t.ZERO;for(var n=e.clone(),i=this.clone(),s=yt(1),o=yt(0),a=yt(0),u=yt(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),r?(s.isEven()&&o.isEven()||(s.addTo(this,s),o.subTo(e,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;i.isEven();)i.rShiftTo(1,i),r?(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);n.compareTo(i)>=0?(n.subTo(i,n),r&&s.subTo(a,s),o.subTo(u,o)):(i.subTo(n,i),r&&a.subTo(s,a),u.subTo(o,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 at)},t.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i<s&&(s=i),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},t.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=it[it.length-1]){for(e=0;e<it.length;++e)if(r[0]==it[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<it.length;){for(var n=it[e],i=e+1;i<it.length&&n<st;)n*=it[i++];for(n=r.modInt(n);e<i;)if(n%it[e++]==0)return!1}return r.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,r){var n;if(16==r)n=4;else if(8==r)n=3;else if(256==r)n=8;else if(2==r)n=1;else if(32==r)n=5;else{if(4!=r)return void this.fromRadix(e,r);n=2}this.t=0,this.s=0;for(var i=e.length,s=!1,o=0;--i>=0;){var a=8==n?255&+e[i]:vt(e,i);a<0?"-"==e.charAt(i)&&(s=!0):(s=!1,0==o?this[this.t++]=a:o+n>this.DB?(this[this.t-1]|=(a&(1<<this.DB-o)-1)<<o,this[this.t++]=a>>this.DB-o):this[this.t-1]|=a<<o,(o+=n)>=this.DB&&(o-=this.DB))}8==n&&0!=(128&+e[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),s&&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 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},t.prototype.drShiftTo=function(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},t.prototype.lShiftTo=function(t,e){for(var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,s=Math.floor(t/this.DB),o=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+s+1]=this[a]>>n|o,o=(this[a]&i)<<r;for(a=s-1;a>=0;--a)e[a]=0;e[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()},t.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<<n)-1;e[0]=this[r]>>n;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&s)<<i,e[o-r]=this[o]>>n;n>0&&(e[this.t-r-1]|=(this.s&s)<<i),e.t=this.t-r,e.clamp()}},t.prototype.subTo=function(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},t.prototype.multiplyTo=function(e,r){var n=this.abs(),i=e.abs(),s=n.t;for(r.t=s+i.t;--s>=0;)r[s]=0;for(s=0;s<i.t;++s)r[s+n.t]=n.am(0,i[s],r,s,0,n.t);r.s=0,r.clamp(),this.s!=e.s&&t.ZERO.subTo(r,r)},t.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},t.prototype.divRemTo=function(e,r,n){var i=e.abs();if(!(i.t<=0)){var s=this.abs();if(s.t<i.t)return null!=r&&r.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=lt());var o=lt(),a=this.s,u=e.s,h=this.DB-mt(i[i.t-1]);h>0?(i.lShiftTo(h,o),s.lShiftTo(h,n)):(i.copyTo(o),s.copyTo(n));var c=o.t,l=o[c-1];if(0!=l){var f=l*(1<<this.F1)+(c>1?o[c-2]>>this.F2:0),d=this.FV/f,p=(1<<this.F1)/f,g=1<<this.F2,v=n.t,y=v-c,m=null==r?lt():r;for(o.dlShiftTo(y,m),n.compareTo(m)>=0&&(n[n.t++]=1,n.subTo(m,n)),t.ONE.dlShiftTo(c,m),m.subTo(o,o);o.t<c;)o[o.t++]=0;for(;--y>=0;){var b=n[--v]==l?this.DM:Math.floor(n[v]*d+(n[v-1]+g)*p);if((n[v]+=o.am(0,b,n,y,0,c))<b)for(o.dlShiftTo(y,m),n.subTo(m,n);n[v]<--b;)n.subTo(m,n)}null!=r&&(n.drShiftTo(c,r),a!=u&&t.ZERO.subTo(r,r)),n.t=c,n.clamp(),h>0&&n.rShiftTo(h,n),a<0&&t.ZERO.subTo(n,n)}}},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,r){if(e>4294967295||e<1)return t.ONE;var n=lt(),i=lt(),s=r.convert(this),o=mt(e)-1;for(s.copyTo(n);--o>=0;)if(r.sqrTo(n,i),(e&1<<o)>0)r.mulTo(i,s,n);else{var a=n;n=i,i=a}return r.revert(n)},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),r=Math.pow(t,e),n=yt(r),i=lt(),s=lt(),o="";for(this.divRemTo(n,i,s);i.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,i.divRemTo(n,i,s);return s.intValue().toString(t)+o},t.prototype.fromRadix=function(e,r){this.fromInt(0),null==r&&(r=10);for(var n=this.chunkSize(r),i=Math.pow(r,n),s=!1,o=0,a=0,u=0;u<e.length;++u){var h=vt(e,u);h<0?"-"==e.charAt(u)&&0==this.signum()&&(s=!0):(a=r*a+h,++o>=n&&(this.dMultiply(i),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(r,o)),this.dAddOffset(a,0)),s&&t.ZERO.subTo(this,this)},t.prototype.fromNumber=function(e,r,n){if("number"==typeof r)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),V,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(r);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(t.ONE.shiftLeft(e-1),this);else{var i=[],s=7&e;i.length=1+(e>>3),r.nextBytes(i),s>0?i[0]&=(1<<s)-1:i[0]=0,this.fromString(i,256)}},t.prototype.bitwiseTo=function(t,e,r){var n,i,s=Math.min(t.t,this.t);for(n=0;n<s;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(i=t.s&this.DM,n=s;n<this.t;++n)r[n]=e(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=s;n<t.t;++n)r[n]=e(i,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},t.prototype.changeBit=function(e,r){var n=t.ONE.shiftLeft(e);return this.bitwiseTo(n,r,n),n},t.prototype.addTo=function(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},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,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(var i=r.t-this.t;n<i;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()},t.prototype.multiplyUpperTo=function(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)},t.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},t.prototype.millerRabin=function(e){var r=this.subtract(t.ONE),n=r.getLowestSetBit();if(n<=0)return!1;var i=r.shiftRight(n);(e=e+1>>1)>it.length&&(e=it.length);for(var s=lt(),o=0;o<e;++o){s.fromInt(it[Math.floor(Math.random()*it.length)]);var a=s.modPow(i,this);if(0!=a.compareTo(t.ONE)&&0!=a.compareTo(r)){for(var u=1;u++<n&&0!=a.compareTo(r);)if(0==(a=a.modPowInt(2,this)).compareTo(t.ONE))return!1;if(0!=a.compareTo(r))return!1}}return!0},t.prototype.square=function(){var t=lt();return this.squareTo(t),t},t.prototype.gcda=function(t,e){var r=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(r.compareTo(n)<0){var i=r;r=n,n=i}var s=r.getLowestSetBit(),o=n.getLowestSetBit();if(o<0)e(r);else{s<o&&(o=s),o>0&&(r.rShiftTo(o,r),n.rShiftTo(o,n));var a=function(){(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),(s=n.getLowestSetBit())>0&&n.rShiftTo(s,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n)),r.signum()>0?setTimeout(a,0):(o>0&&n.lShiftTo(o,n),setTimeout((function(){e(n)}),0))};setTimeout(a,10)}},t.prototype.fromNumberAsync=function(e,r,n,i){if("number"==typeof r)if(e<2)this.fromInt(1);else{this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),V,this),this.isEven()&&this.dAddOffset(1,0);var s=this,o=function(){s.dAddOffset(2,0),s.bitLength()>e&&s.subTo(t.ONE.shiftLeft(e-1),s),s.isProbablePrime(r)?setTimeout((function(){i()}),0):setTimeout(o,0)};setTimeout(o,0)}else{var a=[],u=7&e;a.length=1+(e>>3),r.nextBytes(a),u>0?a[0]&=(1<<u)-1:a[0]=0,this.fromString(a,256)}},t}(),at=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}(),ut=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}(),ht=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=lt();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(ot.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=lt();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),ct=function(){function t(t){this.m=t,this.r2=lt(),this.q3=lt(),ot.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=lt();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 lt(){return new ot(null)}function ft(t,e){return new ot(t,e)}"Microsoft Internet Explorer"==(null===navigator||void 0===navigator?void 0:navigator.appName)?(ot.prototype.am=function(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;--s>=0;){var u=32767&this[t],h=this[t++]>>15,c=a*u+h*o;i=((u=o*u+((32767&c)<<15)+r[n]+(1073741823&i))>>>30)+(c>>>15)+a*h+(i>>>30),r[n++]=1073741823&u}return i},tt=30):"Netscape"!=(null===navigator||void 0===navigator?void 0:navigator.appName)?(ot.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var o=e*this[t++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},tt=26):(ot.prototype.am=function(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var u=16383&this[t],h=this[t++]>>14,c=a*u+h*o;i=((u=o*u+((16383&c)<<14)+r[n]+i)>>28)+(c>>14)+a*h,r[n++]=268435455&u}return i},tt=28),ot.prototype.DB=tt,ot.prototype.DM=(1<<tt)-1,ot.prototype.DV=1<<tt,ot.prototype.FV=Math.pow(2,52),ot.prototype.F1=52-tt,ot.prototype.F2=2*tt-52;var dt,pt,gt=[];for(dt="0".charCodeAt(0),pt=0;pt<=9;++pt)gt[dt++]=pt;for(dt="a".charCodeAt(0),pt=10;pt<36;++pt)gt[dt++]=pt;for(dt="A".charCodeAt(0),pt=10;pt<36;++pt)gt[dt++]=pt;function vt(t,e){var r=gt[t.charCodeAt(e)];return null==r?-1:r}function yt(t){var e=lt();return e.fromInt(t),e}function mt(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}ot.ZERO=yt(0),ot.ONE=yt(1);var bt,Et,Tt=function(){function t(){this.i=0,this.j=0,this.S=[]}return t.prototype.init=function(t){var e,r,n;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,n=this.S[e],this.S[e]=this.S[r],this.S[r]=n;this.i=0,this.j=0},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}(),St=256,_t=null;if(null==_t){_t=[],Et=0;var wt=void 0;if((null===window||void 0===window?void 0:window.crypto)&&(null===window||void 0===window?void 0:window.crypto.getRandomValues)){var Rt=new Uint32Array(256);for(null===window||void 0===window||window.crypto.getRandomValues(Rt),wt=0;wt<Rt.length;++wt)_t[Et++]=255&Rt[wt]}var It=function(t){if(this.count=this.count||0,this.count>=256||Et>=St)(null===window||void 0===window?void 0:window.removeEventListener)?null===window||void 0===window||window.removeEventListener("mousemove",It,!1):(null===window||void 0===window?void 0:window.detachEvent)&&(null===window||void 0===window||window.detachEvent("onmousemove",It));else try{var e=t.x+t.y;_t[Et++]=255&e,this.count+=1}catch(t){}};(null===window||void 0===window?void 0:window.addEventListener)?null===window||void 0===window||window.addEventListener("mousemove",It,!1):(null===window||void 0===window?void 0:window.attachEvent)&&(null===window||void 0===window||window.attachEvent("onmousemove",It))}function Dt(){if(null==bt){for(bt=new Tt;Et<St;){var t=Math.floor(65536*Math.random());_t[Et++]=255&t}for(bt.init(_t),Et=0;Et<_t.length;++Et)_t[Et]=0;Et=0}return bt.next()}var Ot=function(){function t(){}return t.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=Dt()},t}(),At=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),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)},t.prototype.setPublic=function(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=ft(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 r=[],n=t.length-1;n>=0&&e>0;){var i=t.charCodeAt(n--);i<128?r[--e]=i:i>127&&i<2048?(r[--e]=63&i|128,r[--e]=i>>6|192):(r[--e]=63&i|128,r[--e]=i>>6&63|128,r[--e]=i>>12|224)}r[--e]=0;for(var s=new Ot,o=[];e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);r[--e]=o[0]}return r[--e]=2,r[--e]=0,new ot(r)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var n=r.toString(16);return 0==(1&n.length)?n:"0"+n},t.prototype.encryptLong=function(t){var e=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return t.length>r?(t.match(/.{1,117}/g).forEach((function(t){var r=e.encrypt(t);n+=r})),F(n)):F(this.encrypt(t))}catch(t){return!1}},t.prototype.decryptLong=function(t){var e=this,r=this.n.bitLength()+7>>3;t=K(t);try{if(t.length>r){var n="";return t.match(/.{1,256}/g).forEach((function(t){var r=e.decrypt(t);n+=r})),n}return this.decrypt(t)}catch(t){return!1}},t.prototype.setPrivate=function(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=ft(t,16),this.e=parseInt(e,16),this.d=ft(r,16)):console.error("Invalid RSA private key")},t.prototype.setPrivateEx=function(t,e,r,n,i,s,o,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=ft(t,16),this.e=parseInt(e,16),this.d=ft(r,16),this.p=ft(n,16),this.q=ft(i,16),this.dmp1=ft(s,16),this.dmq1=ft(o,16),this.coeff=ft(a,16)):console.error("Invalid RSA private key")},t.prototype.generate=function(t,e){var r=new Ot,n=t>>1;this.e=parseInt(e,16);for(var i=new ot(e,16);;){for(;this.p=new ot(t-n,1,r),0!=this.p.subtract(ot.ONE).gcd(i).compareTo(ot.ONE)||!this.p.isProbablePrime(10););for(;this.q=new ot(n,1,r),0!=this.q.subtract(ot.ONE).gcd(i).compareTo(ot.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(ot.ONE),a=this.q.subtract(ot.ONE),u=o.multiply(a);if(0==u.gcd(i).compareTo(ot.ONE)){this.n=this.p.multiply(this.q),this.d=i.modInverse(u),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}},t.prototype.decrypt=function(t){var e=ft(t,16),r=this.doPrivate(e);return null==r?null:function(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var i="";++n<r.length;){var s=255&r[n];s<128?i+=String.fromCharCode(s):s>191&&s<224?(i+=String.fromCharCode((31&s)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&s)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}(r,this.n.bitLength()+7>>3)},t.prototype.generateAsync=function(t,e,r){var n=new Ot,i=t>>1;this.e=parseInt(e,16);var s=new ot(e,16),o=this,a=function(){var e=function(){if(o.p.compareTo(o.q)<=0){var t=o.p;o.p=o.q,o.q=t}var e=o.p.subtract(ot.ONE),n=o.q.subtract(ot.ONE),i=e.multiply(n);0==i.gcd(s).compareTo(ot.ONE)?(o.n=o.p.multiply(o.q),o.d=s.modInverse(i),o.dmp1=o.d.mod(e),o.dmq1=o.d.mod(n),o.coeff=o.q.modInverse(o.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},u=function(){o.q=lt(),o.q.fromNumberAsync(i,1,n,(function(){o.q.subtract(ot.ONE).gcda(s,(function(t){0==t.compareTo(ot.ONE)&&o.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(u,0)}))}))},h=function(){o.p=lt(),o.p.fromNumberAsync(t-i,1,n,(function(){o.p.subtract(ot.ONE).gcda(s,(function(t){0==t.compareTo(ot.ONE)&&o.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(h,0)}))}))};setTimeout(h,0)};setTimeout(a,0)},t.prototype.sign=function(t,e,r){var n=function(t,e){if(e<t.length+22)return console.error("Message too long for RSA"),null;for(var r=e-t.length-6,n="",i=0;i<r;i+=2)n+="ff";return ft("0001"+n+"00"+t,16)}((Nt[r]||"")+e(t).toString(),this.n.bitLength()/4);if(null==n)return null;var i=this.doPrivate(n);if(null==i)return null;var s=i.toString(16);return 0==(1&s.length)?s:"0"+s},t.prototype.verify=function(t,e,r){var n=ft(e,16),i=this.doPublic(n);return null==i?null:function(t){for(var e in Nt)if(Nt.hasOwnProperty(e)){var r=Nt[e],n=r.length;if(t.substr(0,n)==r)return t.substr(n)}return t}(i.toString(16).replace(/^1f+00/,""))==r(t).toString()},t}(),Nt={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"},xt={};xt.lang={extend:function(t,e,r){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var n=function(){};if(n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),r){var i;for(i in r)t.prototype[i]=r[i];var s=function(){},o=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(s=function(t,e){for(i=0;i<o.length;i+=1){var r=o[i],n=e[r];"function"==typeof n&&n!=Object.prototype[r]&&(t[r]=n)}})}catch(t){}s(t.prototype,r)}}};var Pt={};void 0!==Pt.asn1&&Pt.asn1||(Pt.asn1={}),Pt.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 r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i<r;i++)n+="f";e=new ot(n,16).xor(t).add(ot.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=Pt.asn1,r=e.DERBoolean,n=e.DERInteger,i=e.DERBitString,s=e.DEROctetString,o=e.DERNull,a=e.DERObjectIdentifier,u=e.DEREnumerated,h=e.DERUTF8String,c=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 r(t[T]);if("int"==T)return new n(t[T]);if("bitstr"==T)return new i(t[T]);if("octstr"==T)return new s(t[T]);if("null"==T)return new o(t[T]);if("oid"==T)return new a(t[T]);if("enum"==T)return new u(t[T]);if("utf8str"==T)return new h(t[T]);if("numstr"==T)return new c(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 O={};if(void 0!==I.explicit&&(O.explicit=I.explicit),void 0!==I.tag&&(O.tag=I.tag),void 0===I.obj)throw"obj shall be specified for 'tag'.";return O.obj=b(I.obj),new m(O)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},Pt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),n=(e=Math.floor(r/40)+"."+r%40,""),i=2;i<t.length;i+=2){var s=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);n+=s.substr(1,7),"0"==s.substr(0,1)&&(e=e+"."+new ot(n,2).toString(10),n="")}return e},Pt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new ot(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";for(n=s+n,o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",i=t.split("."),s=40*parseInt(i[0])+parseInt(i[1]);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n},Pt.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 r=e.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+r).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""}},Pt.asn1.DERAbstractString=function(t){Pt.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))},xt.lang.extend(Pt.asn1.DERAbstractString,Pt.asn1.ASN1Object),Pt.asn1.DERAbstractTime=function(t){Pt.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,r){var n=this.zeroPadding,i=this.localDateToUTC(t),s=String(i.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var a=i.getMilliseconds();if(0!=a){var u=n(String(a),3);o=o+"."+(u=u.replace(/[0]+$/,""))}}return o+"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,r,n,i,s){var o=new Date(Date.UTC(t,e-1,r,n,i,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},xt.lang.extend(Pt.asn1.DERAbstractTime,Pt.asn1.ASN1Object),Pt.asn1.DERAbstractStructured=function(t){Pt.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)},xt.lang.extend(Pt.asn1.DERAbstractStructured,Pt.asn1.ASN1Object),Pt.asn1.DERBoolean=function(){Pt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},xt.lang.extend(Pt.asn1.DERBoolean,Pt.asn1.ASN1Object),Pt.asn1.DERInteger=function(t){Pt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=Pt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new ot(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))},xt.lang.extend(Pt.asn1.DERInteger,Pt.asn1.ASN1Object),Pt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=Pt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}Pt.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 r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var r=0;r<=e;r++)t+="0";var n="";for(r=0;r<t.length-1;r+=8){var i=t.substr(r,8),s=parseInt(i,2).toString(16);1==s.length&&(s="0"+s),n+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+n},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!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))},xt.lang.extend(Pt.asn1.DERBitString,Pt.asn1.ASN1Object),Pt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=Pt.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}Pt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},xt.lang.extend(Pt.asn1.DEROctetString,Pt.asn1.DERAbstractString),Pt.asn1.DERNull=function(){Pt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},xt.lang.extend(Pt.asn1.DERNull,Pt.asn1.ASN1Object),Pt.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new ot(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";for(n=s+n,o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};Pt.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 n="",i=t.split("."),s=40*parseInt(i[0])+parseInt(i[1]);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.setValueName=function(t){var e=Pt.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))},xt.lang.extend(Pt.asn1.DERObjectIdentifier,Pt.asn1.ASN1Object),Pt.asn1.DEREnumerated=function(t){Pt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=Pt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new ot(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))},xt.lang.extend(Pt.asn1.DEREnumerated,Pt.asn1.ASN1Object),Pt.asn1.DERUTF8String=function(t){Pt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},xt.lang.extend(Pt.asn1.DERUTF8String,Pt.asn1.DERAbstractString),Pt.asn1.DERNumericString=function(t){Pt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},xt.lang.extend(Pt.asn1.DERNumericString,Pt.asn1.DERAbstractString),Pt.asn1.DERPrintableString=function(t){Pt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},xt.lang.extend(Pt.asn1.DERPrintableString,Pt.asn1.DERAbstractString),Pt.asn1.DERTeletexString=function(t){Pt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},xt.lang.extend(Pt.asn1.DERTeletexString,Pt.asn1.DERAbstractString),Pt.asn1.DERIA5String=function(t){Pt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},xt.lang.extend(Pt.asn1.DERIA5String,Pt.asn1.DERAbstractString),Pt.asn1.DERUTCTime=function(t){Pt.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))},xt.lang.extend(Pt.asn1.DERUTCTime,Pt.asn1.DERAbstractTime),Pt.asn1.DERGeneralizedTime=function(t){Pt.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))},xt.lang.extend(Pt.asn1.DERGeneralizedTime,Pt.asn1.DERAbstractTime),Pt.asn1.DERSequence=function(t){Pt.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}},xt.lang.extend(Pt.asn1.DERSequence,Pt.asn1.DERAbstractStructured),Pt.asn1.DERSet=function(t){Pt.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 r=this.asn1Array[e];t.push(r.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)},xt.lang.extend(Pt.asn1.DERSet,Pt.asn1.DERAbstractStructured),Pt.asn1.DERTaggedObject=function(t){Pt.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,r){this.hT=e,this.isExplicit=t,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.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)))},xt.lang.extend(Pt.asn1.DERTaggedObject,Pt.asn1.ASN1Object);var Ct=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 P(e,t),e.prototype.parseKey=function(t){try{var e=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?function(t){var e;if(void 0===G){var r="0123456789ABCDEF",n=" \f\n\r\t \u2028\u2029";for(G={},e=0;e<16;++e)G[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)G[r.charAt(e)]=e;for(e=0;e<n.length;++e)G[n.charAt(e)]=-1}var i=[],s=0,o=0;for(e=0;e<t.length;++e){var a=t.charAt(e);if("="==a)break;if(-1!=(a=G[a])){if(void 0===a)throw new Error("Illegal character at offset "+e);s|=a,++o>=2?(i[i.length]=s,s=0,o=0):s<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return i}(t):Y.unarmor(t),i=rt.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=ft(e,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var s=i.sub[3].getHexStringValue();this.d=ft(s,16);var o=i.sub[4].getHexStringValue();this.p=ft(o,16);var a=i.sub[5].getHexStringValue();this.q=ft(a,16);var u=i.sub[6].getHexStringValue();this.dmp1=ft(u,16);var h=i.sub[7].getHexStringValue();this.dmq1=ft(h,16);var c=i.sub[8].getHexStringValue();this.coeff=ft(c,16)}else{if(2!==i.sub.length)return!1;var l=i.sub[1].sub[0];e=l.sub[0].getHexStringValue(),this.n=ft(e,16),r=l.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new Pt.asn1.DERInteger({int:0}),new Pt.asn1.DERInteger({bigint:this.n}),new Pt.asn1.DERInteger({int:this.e}),new Pt.asn1.DERInteger({bigint:this.d}),new Pt.asn1.DERInteger({bigint:this.p}),new Pt.asn1.DERInteger({bigint:this.q}),new Pt.asn1.DERInteger({bigint:this.dmp1}),new Pt.asn1.DERInteger({bigint:this.dmq1}),new Pt.asn1.DERInteger({bigint:this.coeff})]};return new Pt.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return F(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new Pt.asn1.DERSequence({array:[new Pt.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new Pt.asn1.DERNull]}),e=new Pt.asn1.DERSequence({array:[new Pt.asn1.DERInteger({bigint:this.n}),new Pt.asn1.DERInteger({int:this.e})]}),r=new Pt.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new Pt.asn1.DERSequence({array:[t,r]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return F(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(void 0===e&&(e=void 0),!t)return t;var r="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(r,"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}(At);function Ut(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}Ut.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new Ct(t)},Ut.prototype.setPrivateKey=function(t){this.setKey(t)},Ut.prototype.setPublicKey=function(t){this.setKey(t)},Ut.prototype.decrypt=function(t){try{return this.getKey().decrypt(K(t))}catch(t){return!1}},Ut.prototype.encrypt=function(t){try{return F(this.getKey().encrypt(t))}catch(t){return!1}},Ut.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",n=0,i=/null$/g;i.test(r)&&(n++,e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",!(n>10)););return e}catch(t){return!1}},Ut.prototype.decryptLong=function(t){try{return this.getKey().decryptLong(t)}catch(t){return!1}},Ut.prototype.sign=function(t,e,r){try{return F(this.getKey().sign(t,e,r))}catch(t){return!1}},Ut.prototype.verify=function(t,e,r){try{return this.getKey().verify(t,K(e),r)}catch(t){return!1}},Ut.prototype.getKey=function(t){if(!this.key){if(this.key=new Ct,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},Ut.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},Ut.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},Ut.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},Ut.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},Ut.version="3.1.4";const Lt=Ut;var Vt=function(t){var e=void 0===t?{}:t,r=e.publicKey,n=void 0===r?"":r,i=e.payload,s=void 0===i?{}:i;if(!n)return"";try{var o=x(s),a=new Lt;return a.setPublicKey(n),a.encryptLong(JSON.stringify(o))}catch(t){}return""},Bt=function(){return Bt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Bt.apply(this,arguments)},kt=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))},qt=function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Ht=function(){function t(t){var e=t.request,r=t.credentialsClient;if(!r){var n={apiOrigin:t.apiOrigin,clientId:t.clientId,storage:t.storage};r=new D(n)}if(!e){var i=r.request.bind(r),s=new N({clientId:t.clientId,request:i,storage:t.storage});e=s.request.bind(s)}this.config={apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:r,storage:t.storage||_}}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 r,n=x(t),i=(null===(r={v2:o}[null==n?void 0:n.version])||void 0===r?void 0:r[e])||s[e];return n&&delete n.version,{params:n,url:i}},t.prototype.signIn=function(t){return kt(this,void 0,void 0,(function(){var e,r,n,i;return qt(this,(function(s){switch(s.label){case 0:return e=t.version||"v1",(r=this.getParamsByVersion(t,"AUTH_SIGN_IN_URL")).params.query&&delete r.params.query,[4,this.getEncryptParams(r.params)];case 1:return n=s.sent(),[4,this.config.request(r.url,{method:"POST",body:n})];case 2:return i=s.sent(),[4,this.config.credentialsClient.setCredentials(Bt(Bt({},i),{version:e}))];case 3:return s.sent(),[2,Promise.resolve(i)]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),kt(this,void 0,void 0,(function(){var e;return qt(this,(function(r){switch(r.label){case 0:return[4,this.config.request(s.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t})];case 1:return e=r.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return r.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signUp=function(t){return kt(this,void 0,void 0,(function(){var e;return qt(this,(function(r){switch(r.label){case 0:return[4,this.config.request(s.AUTH_SIGN_UP_URL,{method:"POST",body:t})];case 1:return e=r.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return r.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signOut=function(){return kt(this,void 0,void 0,(function(){var t,e;return qt(this,(function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getAccessToken()];case 1:return t=r.sent(),[4,this.config.request(s.AUTH_REVOKE_URL,{method:"POST",body:{token:t}})];case 2:return e=r.sent(),[4,this.config.credentialsClient.setCredentials()];case 3:return r.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.getVerification=function(t){return kt(this,void 0,void 0,(function(){var e;return qt(this,(function(r){switch(r.label){case 0:return e=!1,"CUR_USER"!==t.target?[3,1]:(e=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:r.sent()&&(e=!0),r.label=3;case 3:return[2,this.config.request(s.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:!0,withCredentials:e})]}}))}))},t.prototype.verify=function(t){return kt(this,void 0,void 0,(function(){var e,r;return qt(this,(function(n){switch(n.label){case 0:return e=this.getParamsByVersion(t,"VERIFY_URL"),[4,this.config.request(e.url,{method:"POST",body:e.params})];case 1:return r=n.sent(),"v2"!==(null==t?void 0:t.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(Bt(Bt({},r),{version:"v2"}))];case 2:n.sent(),n.label=3;case 3:return[2,r]}}))}))},t.prototype.genProviderRedirectUri=function(t){return kt(this,void 0,void 0,(function(){var e,r;return qt(this,(function(n){return e="".concat(s.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),(r=t.other_params)&&"string"==typeof r.sign_out_uri&&r.sign_out_uri.length>0&&(e+="&other_params[sign_out_uri]=".concat(r.sign_out_uri)),[2,this.config.request(e,{method:"GET"})]}))}))},t.prototype.grantProviderToken=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request(s.PROVIDER_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.patchProviderToken=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request(s.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]}))}))},t.prototype.signInWithProvider=function(t){return kt(this,void 0,void 0,(function(){var e,r;return qt(this,(function(n){switch(n.label){case 0:return e=this.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(e.url,{method:"POST",body:e.params})];case 1:return r=n.sent(),[4,this.config.credentialsClient.setCredentials(Bt(Bt({},r),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return n.sent(),[2,Promise.resolve(r)]}}))}))},t.prototype.bindWithProvider=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request(s.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.getUserProfile=function(t){return kt(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={}),kt(this,void 0,void 0,(function(){var r,n,i;return qt(this,(function(s){switch(s.label){case 0:return r=this.getParamsByVersion(t,"USER_ME_URL"),(null===(e=r.params)||void 0===e?void 0:e.query)&&(n=new URLSearchParams(r.params.query),r.url+="?".concat(n.toString())),[4,this.config.request(r.url,{method:"GET",withCredentials:!0})];case 1:return(i=s.sent()).sub&&(i.uid=i.sub),[2,i]}}))}))},t.prototype.getWedaUserInfo=function(){return kt(this,void 0,void 0,(function(){return qt(this,(function(t){switch(t.label){case 0:return[4,this.config.request(s.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,t.sent()]}}))}))},t.prototype.deleteMe=function(e){return kt(this,void 0,void 0,(function(){var r,n;return qt(this,(function(i){return r=this.getParamsByVersion(e,"USER_ME_URL"),n="".concat(r.url,"?").concat(t.parseParamsToSearch(r.params)),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.hasLoginState=function(){return kt(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 kt(this,void 0,void 0,(function(){return qt(this,(function(t){return[2,this.config.credentialsClient.getCredentialsAsync()]}))}))},t.prototype.transByProvider=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request(s.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.grantToken=function(t){return kt(this,void 0,void 0,(function(){var e;return qt(this,(function(r){return e=this.getParamsByVersion(t,"AUTH_TOKEN_URL"),[2,this.config.request(e.url,{method:"POST",body:e.params})]}))}))},t.prototype.getProviders=function(){return kt(this,void 0,void 0,(function(){return qt(this,(function(t){return[2,this.config.request(s.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},t.prototype.unbindProvider=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request("".concat(s.PROVIDER_UNBIND_URL,"/").concat(t.provider_id),{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.checkPassword=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request("".concat(s.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.bindPhone=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request("".concat(s.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.bindEmail=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request("".concat(s.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.setPassword=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request("".concat(s.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.updatePasswordByOld=function(t){return kt(this,void 0,void 0,(function(){var e;return qt(this,(function(r){switch(r.label){case 0:return[4,this.sudo({password:t.old_password})];case 1:return e=r.sent(),[2,this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})]}}))}))},t.prototype.sudo=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request("".concat(s.SUDO_URL),{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.getCurUserVerification=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return t.target="CUR_USER",[2,this.config.request(s.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]}))}))},t.prototype.changeBindedProvider=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request("".concat(s.PROVIDER_LIST,"/").concat(t.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})]}))}))},t.prototype.setUserProfile=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request(s.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.queryUserProfile=function(t){return kt(this,void 0,void 0,(function(){var e;return qt(this,(function(r){return e=new URLSearchParams(t),[2,this.config.request("".concat(s.USER_QUERY_URL,"?").concat(e.toString()),{method:"GET",withCredentials:!0})]}))}))},t.prototype.setCustomSignFunc=function(t){this.getCustomSignTicketFn=t},t.prototype.signInWithCustomTicket=function(t){return kt(this,void 0,void 0,(function(){var e;return qt(this,(function(r){switch(r.label){case 0:return[4,this.getCustomSignTicketFn()];case 1:return e=r.sent(),[2,this.signInWithProvider(Bt(Bt({},t),{provider_id:"custom",provider_token:e}))]}}))}))},t.prototype.resetPassword=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request(s.AUTH_RESET_PASSWORD,{method:"POST",body:t})]}))}))},t.prototype.deviceAuthorize=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request(s.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.checkUsername=function(t){return kt(this,void 0,void 0,(function(){return qt(this,(function(e){return[2,this.config.request(s.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]}))}))},t.prototype.checkIfUserExist=function(t){return kt(this,void 0,void 0,(function(){var e;return qt(this,(function(r){return e=new URLSearchParams(t),[2,this.config.request("".concat(s.CHECK_IF_USER_EXIST,"?").concat(e.toString()),{method:"GET"})]}))}))},t.prototype.loginScope=function(){return kt(this,void 0,void 0,(function(){return qt(this,(function(t){return[2,this.config.credentialsClient.getScope()]}))}))},t.prototype.loginGroups=function(){return kt(this,void 0,void 0,(function(){return qt(this,(function(t){return[2,this.config.credentialsClient.getGroups()]}))}))},t.prototype.refreshTokenForce=function(t){return kt(this,void 0,void 0,(function(){var e;return qt(this,(function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return e=r.sent(),[4,this.config.credentialsClient.refreshToken(Bt(Bt({},e),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return[2,r.sent()]}}))}))},t.prototype.getCredentials=function(){return kt(this,void 0,void 0,(function(){return qt(this,(function(t){return[2,this.config.credentialsClient.getCredentials()]}))}))},t.prototype.getPublicKey=function(){return kt(this,void 0,void 0,(function(){return qt(this,(function(t){return[2,this.config.request(o.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]}))}))},t.prototype.getEncryptParams=function(t){return kt(this,void 0,void 0,(function(){var e,r,n,i;return qt(this,(function(s){switch(s.label){case 0:if(!(e=x(t)).isEncrypt)return[2,t];r="",n="",s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.getPublicKey()];case 2:return i=s.sent(),r=i.public_key,n=i.public_key_thumbprint,[3,4];case 3:return s.sent(),[3,4];case 4:if(!r||!n)throw new Error("public_key or public_key_thumbprint is empty");return delete e.isEncrypt,[2,{params:Vt({publicKey:r,payload:e}),public_key_thumbprint:n}]}}))}))},t.prototype.getProviderSubType=function(){return kt(this,void 0,void 0,(function(){return qt(this,(function(t){return[2,this.config.request(s.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})]}))}))},t}(),Mt=function(){},jt=function(){return jt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},jt.apply(this,arguments)},Ft=function(t){var e=t.apiOrigin,r=t.clientId,n=t.storage,i=t.request,s=t.baseRequest,o=t.anonymousSignInFunc;this.oauth2client=new D({apiOrigin:e,clientId:r,storage:n,baseRequest:s||i,anonymousSignInFunc:o}),this.authApi=new Ht(jt(jt({credentialsClient:this.oauth2client},t),{request:i?this.oauth2client.request.bind(this.oauth2client):void 0}))}},118:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(406),e)}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,r),s.exports}return r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r(118)})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/js-sdk",
3
- "version": "2.5.39-beta.0",
3
+ "version": "2.5.41-beta.0",
4
4
  "description": "cloudbase javascript sdk",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -46,15 +46,15 @@
46
46
  "license": "Apache-2.0",
47
47
  "dependencies": {
48
48
  "@cloudbase/adapter-interface": "^0.4.1",
49
- "@cloudbase/analytics": "^2.5.39-beta.0",
50
- "@cloudbase/app": "^2.5.39-beta.0",
51
- "@cloudbase/auth": "^2.5.39-beta.0",
49
+ "@cloudbase/analytics": "^2.5.41-beta.0",
50
+ "@cloudbase/app": "^2.5.41-beta.0",
51
+ "@cloudbase/auth": "^2.5.41-beta.0",
52
52
  "@cloudbase/database": "0.9.20",
53
- "@cloudbase/functions": "^2.5.39-beta.0",
54
- "@cloudbase/realtime": "^2.5.39-beta.0",
55
- "@cloudbase/storage": "^2.5.39-beta.0",
56
- "@cloudbase/types": "^2.5.39-beta.0",
57
- "@cloudbase/utilities": "^2.5.39-beta.0"
53
+ "@cloudbase/functions": "^2.5.41-beta.0",
54
+ "@cloudbase/realtime": "^2.5.41-beta.0",
55
+ "@cloudbase/storage": "^2.5.41-beta.0",
56
+ "@cloudbase/types": "^2.5.41-beta.0",
57
+ "@cloudbase/utilities": "^2.5.41-beta.0"
58
58
  },
59
59
  "browserslist": [
60
60
  "last 2 version",
@@ -62,5 +62,5 @@
62
62
  "not dead",
63
63
  "chrome 53"
64
64
  ],
65
- "gitHead": "3b38f0f9222b02585f8918b150a82f5c230e9b49"
65
+ "gitHead": "e8513caf4d4c69629977296f3a977e831bddd314"
66
66
  }