@cloudbase/js-sdk 3.6.2 → 3.6.3-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,2 @@
1
1
  /*! For license information please see auth.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_auth",[],t):"object"==typeof exports?exports.cloudbase_auth=t():e.cloudbase_auth=t()}("undefined"!=typeof window?window:this,()=>(()=>{"use strict";var e,t,r={829:(e,t,r)=>{var n;r.r(t),r.d(t,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>n,formatUrl:()=>s}),function(e){e.local="local",e.none="none",e.session="session"}(n||(n={}));var o=function(){},i=function(){};function s(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";for(var i in r)""===o?!n&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}},882:(e,t,r)=>{r.r(t),r.d(t,{WxMpWebSocket:()=>Mn,WxRequest:()=>kn,default:()=>qn,parseQueryString:()=>jn,wxMpStorage:()=>xn});var n=r(829);function o(){}function i(e){return"object"==typeof e&&null!==e||"function"==typeof e}const s=o;function a(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch(e){}}const u=Promise,c=Promise.resolve.bind(u),l=Promise.prototype.then,h=Promise.reject.bind(u),d=c;function f(e){return new u(e)}function p(e){return f(t=>t(e))}function v(e){return h(e)}function _(e,t,r){return l.call(e,t,r)}function m(e,t,r){_(_(e,t,r),void 0,s)}function y(e,t){m(e,t)}function g(e,t){m(e,void 0,t)}function b(e,t,r){return _(e,t,r)}function w(e){_(e,void 0,s)}let E=e=>{if("function"==typeof queueMicrotask)E=queueMicrotask;else{const e=p(void 0);E=t=>_(e,t)}return E(e)};function S(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function I(e,t,r){try{return p(S(e,t,r))}catch(e){return v(e)}}class A{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(e){const t=this._back;let r=t;16383===t._elements.length&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size}shift(){const e=this._front;let t=e;const r=this._cursor;let n=r+1;const o=e._elements,i=o[r];return 16384===n&&(t=e._next,n=0),--this._size,this._cursor=n,e!==t&&(this._front=t),o[r]=void 0,i}forEach(e){let t=this._cursor,r=this._front,n=r._elements;for(;!(t===n.length&&void 0===r._next||t===n.length&&(r=r._next,n=r._elements,t=0,0===n.length));)e(n[t]),++t}peek(){const e=this._front,t=this._cursor;return e._elements[t]}}const T=Symbol("[[AbortSteps]]"),P=Symbol("[[ErrorSteps]]"),O=Symbol("[[CancelSteps]]"),R=Symbol("[[PullSteps]]"),C=Symbol("[[CanPullSyncSteps]]"),N=Symbol("[[ReleaseSteps]]");function U(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?x(e):"closed"===t._state?function(e){x(e),q(e)}(e):M(e,t._storedError)}function D(e,t){return Xr(e._ownerReadableStream,t)}function L(e){const t=e._ownerReadableStream;"readable"===t._state?j(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e){M(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"))}(e),t._readableStreamController[N](),t._reader=void 0,e._ownerReadableStream=void 0}function k(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function x(e){e._closedPromise=f((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r})}function M(e,t){x(e),j(e,t)}function j(e,t){void 0!==e._closedPromise_reject&&(w(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function q(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const B=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},W=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function H(e,t){if(void 0!==e&&"object"!=typeof(r=e)&&"function"!=typeof r)throw new TypeError(`${t} is not an object.`);var r}function V(e,t){if("function"!=typeof e)throw new TypeError(`${t} is not a function.`)}function F(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(`${t} is not an object.`)}function G(e,t,r){if(void 0===e)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function Y(e,t,r){if(void 0===e)throw new TypeError(`${t} is required in '${r}'.`)}function z(e){return Number(e)}function K(e){return 0===e?0:e}function $(e,t){const r=Number.MAX_SAFE_INTEGER;let n=Number(e);if(n=K(n),!B(n))throw new TypeError(`${t} is not a finite number`);if(n=function(e){return K(W(e))}(n),n<0||n>r)throw new TypeError(`${t} is outside the accepted range of 0 to ${r}, inclusive`);return B(n)&&0!==n?n:0}function Q(e,t){if(!Qr(e))throw new TypeError(`${t} is not a ReadableStream.`)}function J(e){return new re(e)}function X(e,t){e._reader._readRequests.push(t)}function Z(e,t,r){const n=e._reader._readRequests.shift();r?n._closeSteps():n._chunkSteps(t)}function ee(e){return e._reader._readRequests.length}function te(e){const t=e._reader;return void 0!==t&&!!ie(t)}class re{constructor(e){if(G(e,1,"ReadableStreamDefaultReader"),Q(e,"First parameter"),Jr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");U(this,e),this._readRequests=new A}get closed(){return ie(this)?this._closedPromise:v(ce("closed"))}cancel(e=void 0){return ie(this)?void 0===this._ownerReadableStream?v(k("cancel")):D(this,e):v(ce("cancel"))}read(){if(!ie(this))return v(ce("read"));if(void 0===this._ownerReadableStream)return v(k("read from"));const e=ae(this)?new oe:new ne;return se(this,e),e._promise}releaseLock(){if(!ie(this))throw ce("releaseLock");void 0!==this._ownerReadableStream&&function(e){L(e),ue(e,new TypeError("Reader was released"))}(this)}}Object.defineProperties(re.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),a(re.prototype.cancel,"cancel"),a(re.prototype.read,"read"),a(re.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(re.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});class ne{constructor(){this._promise=f((e,t)=>{this._resolvePromise=e,this._rejectPromise=t})}_chunkSteps(e){this._resolvePromise({value:e,done:!1})}_closeSteps(){this._resolvePromise({value:void 0,done:!0})}_errorSteps(e){this._rejectPromise(e)}}class oe{constructor(){this._promise=void 0}_chunkSteps(e){this._promise=d({value:e,done:!1})}_closeSteps(){this._promise=d({value:void 0,done:!0})}_errorSteps(e){this._promise=v(e)}}function ie(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof re}function se(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[R](t)}function ae(e){const t=e._ownerReadableStream;return"closed"===t._state||"errored"===t._state||t._readableStreamController[C]()}function ue(e,t){const r=e._readRequests;e._readRequests=new A,r.forEach(e=>{e._errorSteps(t)})}function ce(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}var le,he,de;function fe(e){return e.slice()}function pe(e,t,r,n,o){new Uint8Array(e).set(new Uint8Array(r,n,o),t)}let ve=e=>(ve="function"==typeof e.transfer?e=>e.transfer():"function"==typeof structuredClone?e=>structuredClone(e,{transfer:[e]}):e=>e,ve(e)),_e=e=>(_e="boolean"==typeof e.detached?e=>e.detached:e=>0===e.byteLength,_e(e));function me(e,t,r){if(e.slice)return e.slice(t,r);const n=r-t,o=new ArrayBuffer(n);return pe(o,0,e,t,n),o}function ye(e,t){const r=e[t];if(null!=r){if("function"!=typeof r)throw new TypeError(`${String(t)} is not a function`);return r}}function ge(e){try{const t=e.done,r=e.value;return _(d(r),e=>({done:t,value:e}))}catch(e){return v(e)}}const be=null!==(de=null!==(le=Symbol.asyncIterator)&&void 0!==le?le:null===(he=Symbol.for)||void 0===he?void 0:he.call(Symbol,"Symbol.asyncIterator"))&&void 0!==de?de:"@@asyncIterator";function we(e,t="sync",r){if(void 0===r)if("async"===t){if(void 0===(r=ye(e,be)))return function(e){const t={next(){let t;try{t=Ee(e)}catch(e){return v(e)}return ge(t)},return(t){let r;try{const n=ye(e.iterator,"return");if(void 0===n)return p({done:!0,value:t});r=S(n,e.iterator,[t])}catch(e){return v(e)}return i(r)?ge(r):v(new TypeError("The iterator.return() method must return an object"))}};return{iterator:t,nextMethod:t.next,done:!1}}(we(e,"sync",ye(e,Symbol.iterator)))}else r=ye(e,Symbol.iterator);if(void 0===r)throw new TypeError("The object is not iterable");const n=S(r,e,[]);if(!i(n))throw new TypeError("The iterator method must return an object");return{iterator:n,nextMethod:n.next,done:!1}}function Ee(e){const t=S(e.nextMethod,e.iterator,[]);if(!i(t))throw new TypeError("The iterator.next() method must return an object");return t}class Se{constructor(e,t){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=e,this._preventCancel=t}next(){const e=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?b(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise=this._ongoingPromise?b(this._ongoingPromise,t,t):t(),this._ongoingPromise}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const e=this._reader,t=new Ie(this);return se(e,t),t._promise}_returnSteps(e){if(this._isFinished)return Promise.resolve({value:e,done:!0});this._isFinished=!0;const t=this._reader;if(!this._preventCancel){const r=D(t,e);return L(t),b(r,()=>({value:e,done:!0}))}return L(t),p({value:e,done:!0})}}class Ie{constructor(e){this._iterator=e,this._promise=f((e,t)=>{this._resolvePromise=e,this._rejectPromise=t})}_chunkSteps(e){this._iterator._ongoingPromise=void 0,E(()=>this._resolvePromise({value:e,done:!1}))}_closeSteps(){const e=this._iterator;e._ongoingPromise=void 0,e._isFinished=!0,L(e._reader),this._resolvePromise({value:void 0,done:!0})}_errorSteps(e){const t=this._iterator;t._ongoingPromise=void 0,t._isFinished=!0,L(t._reader),this._rejectPromise(e)}}const Ae={next(){return Te(this)?this._asyncIteratorImpl.next():v(Pe("next"))},return(e){return Te(this)?this._asyncIteratorImpl.return(e):v(Pe("return"))},[be](){return this}};function Te(e){if(!i(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof Se}catch(e){return!1}}function Pe(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}Object.defineProperty(Ae,be,{enumerable:!1});const Oe=Number.isNaN||function(e){return e!=e};function Re(e){const t=me(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function Ce(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function Ne(e,t,r){if("number"!=typeof(n=r)||Oe(n)||n<0||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");var n;e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function Ue(e){e._queue=new A,e._queueTotalSize=0}function De(e){return e===DataView}function Le(e){return De(e)?1:e.BYTES_PER_ELEMENT}class ke{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!je(this))throw lt("view");return this._view}respond(e){if(!je(this))throw lt("respond");if(G(e,1,"respond"),e=$(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(_e(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");at(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!je(this))throw lt("respondWithNewView");if(G(e,1,"respondWithNewView"),!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(_e(e.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");ut(this._associatedReadableByteStreamController,e)}}Object.defineProperties(ke.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),a(ke.prototype.respond,"respond"),a(ke.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ke.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class xe{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!Me(this))throw ht("byobRequest");return it(this)}get desiredSize(){if(!Me(this))throw ht("desiredSize");return st(this)}close(){if(!Me(this))throw ht("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);tt(this)}enqueue(e){if(!Me(this))throw ht("enqueue");if(G(e,1,"enqueue"),!ArrayBuffer.isView(e))throw new TypeError("chunk must be an array buffer view");if(0===e.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===e.buffer.byteLength)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");const t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be enqueued to`);rt(this,e)}error(e=void 0){if(!Me(this))throw ht("error");nt(this,e)}[O](e){Be(this),Ue(this);const t=this._cancelAlgorithm(e);return et(this),t}[R](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void ot(this,e);const r=this._autoAllocateChunkSize;if(void 0!==r){let n;try{n=new ArrayBuffer(r)}catch(t){return void e._errorSteps(t)}const o={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(o)}X(t,e),qe(this)}[C](){return this._queueTotalSize>0}[N](){if(this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek();e.readerType="none",this._pendingPullIntos=new A,this._pendingPullIntos.push(e)}}}function Me(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof xe}function je(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof ke}function qe(e){const t=function(e){const t=e._controlledReadableByteStream;return"readable"===t._state&&(!e._closeRequested&&(!!e._started&&(!!(te(t)&&ee(t)>0)||(!!(_t(t)&&vt(t)>0)||st(e)>0))))}(e);t&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,m(e._pullAlgorithm(),()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,qe(e)),null),t=>(nt(e,t),null))))}function Be(e){Qe(e),e._pendingPullIntos=new A}function We(e,t){let r=!1;"closed"===e._state&&(r=!0);const n=Ve(t);"default"===t.readerType?Z(e,n,r):function(e,t,r){const n=e._reader._readIntoRequests.shift();r?n._closeSteps(t):n._chunkSteps(t)}(e,n,r)}function He(e,t){for(let r=0;r<t.length;++r)We(e,t[r])}function Ve(e){const t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function Fe(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function Ge(e,t,r,n){let o;try{o=me(t,r,r+n)}catch(t){throw nt(e,t),t}Fe(e,o,0,n)}function Ye(e,t){t.bytesFilled>0&&Ge(e,t.buffer,t.byteOffset,t.bytesFilled),Ze(e)}function ze(e,t){const r=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),n=t.bytesFilled+r;let o=r,i=!1;const s=n-n%t.elementSize;s>=t.minimumFill&&(o=s-t.bytesFilled,i=!0);const a=e._queue;for(;o>0;){const r=a.peek(),n=Math.min(o,r.byteLength),i=t.byteOffset+t.bytesFilled;pe(t.buffer,i,r.buffer,r.byteOffset,n),r.byteLength===n?a.shift():(r.byteOffset+=n,r.byteLength-=n),e._queueTotalSize-=n,Ke(0,n,t),o-=n}return i}function Ke(e,t,r){r.bytesFilled+=t}function $e(e){0===e._queueTotalSize&&e._closeRequested?(et(e),Zr(e._controlledReadableByteStream)):qe(e)}function Qe(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function Je(e){const t=[];for(;e._pendingPullIntos.length>0&&0!==e._queueTotalSize;){const r=e._pendingPullIntos.peek();ze(e,r)&&(Ze(e),t.push(r))}return t}function Xe(e,t){const r=e._pendingPullIntos.peek();Qe(e),"closed"===e._controlledReadableByteStream._state?function(e,t){"none"===t.readerType&&Ze(e);const r=e._controlledReadableByteStream;if(_t(r)){const t=[];for(;t.length<vt(r);)t.push(Ze(e));He(r,t)}}(e,r):function(e,t,r){if(Ke(0,t,r),"none"===r.readerType){Ye(e,r);const t=Je(e);return void He(e._controlledReadableByteStream,t)}if(r.bytesFilled<r.minimumFill)return;Ze(e);const n=r.bytesFilled%r.elementSize;if(n>0){const t=r.byteOffset+r.bytesFilled;Ge(e,r.buffer,t-n,n)}r.bytesFilled-=n;const o=Je(e);We(e._controlledReadableByteStream,r),He(e._controlledReadableByteStream,o)}(e,t,r),qe(e)}function Ze(e){return e._pendingPullIntos.shift()}function et(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function tt(e){const t=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===t._state)if(e._queueTotalSize>0)e._closeRequested=!0;else{if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(t.bytesFilled%t.elementSize!==0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw nt(e,t),t}}et(e),Zr(t)}}function rt(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const{buffer:n,byteOffset:o,byteLength:i}=t;if(_e(n))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const s=ve(n);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(_e(t.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");Qe(e),t.buffer=ve(t.buffer),"none"===t.readerType&&Ye(e,t)}te(r)?(function(e){const t=e._controlledReadableByteStream._reader;for(;t._readRequests.length>0;){if(0===e._queueTotalSize)return;ot(e,t._readRequests.shift())}}(e),0===ee(r)?Fe(e,s,o,i):(e._pendingPullIntos.length>0&&Ze(e),Z(r,new Uint8Array(s,o,i),!1))):_t(r)?(Fe(e,s,o,i),He(r,Je(e))):Fe(e,s,o,i),qe(e)}function nt(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(Be(e),Ue(e),et(e),en(r,t))}function ot(e,t){const r=e._queue.shift();e._queueTotalSize-=r.byteLength,$e(e);const n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(n)}function it(e){if(null===e._byobRequest&&e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek(),r=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),n=Object.create(ke.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(n,e,r),e._byobRequest=n}return e._byobRequest}function st(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function at(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(0===t)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=ve(r.buffer),Xe(e,t)}function ut(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t.byteLength)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(0===t.byteLength)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+t.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");const n=t.byteLength;r.buffer=ve(t.buffer),Xe(e,n)}function ct(e,t,r,n,o,i,s){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,Ue(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,t._autoAllocateChunkSize=s,t._pendingPullIntos=new A,e._readableStreamController=t,m(p(r()),()=>(t._started=!0,qe(t),null),e=>(nt(t,e),null))}function lt(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function ht(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function dt(e,t){if("byob"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function ft(e){return new mt(e)}function pt(e,t){e._reader._readIntoRequests.push(t)}function vt(e){return e._reader._readIntoRequests.length}function _t(e){const t=e._reader;return void 0!==t&&!!bt(t)}Object.defineProperties(xe.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),a(xe.prototype.close,"close"),a(xe.prototype.enqueue,"enqueue"),a(xe.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(xe.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class mt{constructor(e){if(G(e,1,"ReadableStreamBYOBReader"),Q(e,"First parameter"),Jr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!Me(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");U(this,e),this._readIntoRequests=new A}get closed(){return bt(this)?this._closedPromise:v(St("closed"))}cancel(e=void 0){return bt(this)?void 0===this._ownerReadableStream?v(k("cancel")):D(this,e):v(St("cancel"))}read(e,t={}){if(!bt(this))return v(St("read"));if(!ArrayBuffer.isView(e))return v(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return v(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return v(new TypeError("view's buffer must have non-zero byteLength"));if(_e(e.buffer))return v(new TypeError("view's buffer has been detached"));let r;try{r=function(e,t){var r;return H(e,t),{min:$(null!==(r=null==e?void 0:e.min)&&void 0!==r?r:1,`${t} has member 'min' that`)}}(t,"options")}catch(e){return v(e)}const n=r.min;if(0===n)return v(new TypeError("options.min must be greater than 0"));if(function(e){return De(e.constructor)}(e)){if(n>e.byteLength)return v(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(n>e.length)return v(new RangeError("options.min must be less than or equal to view's length"));if(void 0===this._ownerReadableStream)return v(k("read from"));const o=function(e,t,r){const n=e._ownerReadableStream;return"errored"===n._state||function(e,t,r){const n=e._controlledReadableByteStream,o=Le(t.constructor),{byteLength:i}=t,s=r*o;return!(e._pendingPullIntos.length>0)&&("closed"===n._state||e._queueTotalSize>=s)}(n._readableStreamController,t,r)}(this,e,n)?new gt:new yt;return wt(this,e,n,o),o._promise}releaseLock(){if(!bt(this))throw St("releaseLock");void 0!==this._ownerReadableStream&&function(e){L(e),Et(e,new TypeError("Reader was released"))}(this)}}Object.defineProperties(mt.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),a(mt.prototype.cancel,"cancel"),a(mt.prototype.read,"read"),a(mt.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(mt.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});class yt{constructor(){this._promise=f((e,t)=>{this._resolvePromise=e,this._rejectPromise=t})}_chunkSteps(e){this._resolvePromise({value:e,done:!1})}_closeSteps(e){this._resolvePromise({value:e,done:!0})}_errorSteps(e){this._rejectPromise(e)}}class gt{constructor(){this._promise=void 0}_chunkSteps(e){this._promise=d({value:e,done:!1})}_closeSteps(e){this._promise=d({value:e,done:!0})}_errorSteps(e){this._promise=v(e)}}function bt(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof mt}function wt(e,t,r,n){const o=e._ownerReadableStream;o._disturbed=!0,"errored"===o._state?n._errorSteps(o._storedError):function(e,t,r,n){const o=e._controlledReadableByteStream,i=t.constructor,s=Le(i),{byteOffset:a,byteLength:u}=t,c=r*s;let l;try{l=ve(t.buffer)}catch(e){return void n._errorSteps(e)}const h={buffer:l,bufferByteLength:l.byteLength,byteOffset:a,byteLength:u,bytesFilled:0,minimumFill:c,elementSize:s,viewConstructor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(h),void pt(o,n);if("closed"===o._state){const e=new i(h.buffer,h.byteOffset,0);return void n._closeSteps(e)}if(e._queueTotalSize>0){if(ze(e,h)){const t=Ve(h);return $e(e),void n._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return nt(e,t),void n._errorSteps(t)}}e._pendingPullIntos.push(h),pt(o,n),qe(e)}(o._readableStreamController,t,r,n)}function Et(e,t){const r=e._readIntoRequests;e._readIntoRequests=new A,r.forEach(e=>{e._errorSteps(t)})}function St(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function It(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(Oe(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function At(e){const{size:t}=e;return t||(()=>1)}function Tt(e,t){H(e,t);const r=null==e?void 0:e.highWaterMark,n=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:z(r),size:void 0===n?void 0:Pt(n,`${t} has member 'size' that`)}}function Pt(e,t){return V(e,t),t=>z(e(t))}function Ot(e,t,r){return V(e,r),r=>I(e,t,[r])}function Rt(e,t,r){return V(e,r),()=>I(e,t,[])}function Ct(e,t,r){return V(e,r),r=>S(e,t,[r])}function Nt(e,t,r){return V(e,r),(r,n)=>I(e,t,[r,n])}function Ut(e,t){if(!xt(e))throw new TypeError(`${t} is not a WritableStream.`)}class Dt{constructor(e={},t={}){void 0===e?e=null:F(e,"First parameter");const r=Tt(t,"Second parameter"),n=function(e,t){H(e,t);const r=null==e?void 0:e.abort,n=null==e?void 0:e.close,o=null==e?void 0:e.start,i=null==e?void 0:e.type,s=null==e?void 0:e.write;return{abort:void 0===r?void 0:Ot(r,e,`${t} has member 'abort' that`),close:void 0===n?void 0:Rt(n,e,`${t} has member 'close' that`),start:void 0===o?void 0:Ct(o,e,`${t} has member 'start' that`),write:void 0===s?void 0:Nt(s,e,`${t} has member 'write' that`),type:i}}(e,"First parameter");if(kt(this),void 0!==n.type)throw new RangeError("Invalid type is specified");const o=At(r);!function(e,t,r,n){const o=Object.create(Zt.prototype);let i,s,a,u;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.write?e=>t.write(e,o):()=>p(void 0),a=void 0!==t.close?()=>t.close():()=>p(void 0),u=void 0!==t.abort?e=>t.abort(e):()=>p(void 0),tr(e,o,i,s,a,u,r,n)}(this,n,It(r,1),o)}get locked(){if(!xt(this))throw ur("locked");return Mt(this)}abort(e=void 0){return xt(this)?Mt(this)?v(new TypeError("Cannot abort a stream that already has a writer")):jt(this,e):v(ur("abort"))}close(){return xt(this)?Mt(this)?v(new TypeError("Cannot close a stream that already has a writer")):Vt(this)?v(new TypeError("Cannot close an already-closing stream")):qt(this):v(ur("close"))}getWriter(){if(!xt(this))throw ur("getWriter");return Lt(this)}}function Lt(e){return new Yt(e)}function kt(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new A,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function xt(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof Dt}function Mt(e){return void 0!==e._writer}function jt(e,t){var r;if("closed"===e._state||"errored"===e._state)return p(void 0);e._writableStreamController._abortReason=t,null===(r=e._writableStreamController._abortController)||void 0===r||r.abort(t);const n=e._state;if("closed"===n||"errored"===n)return p(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===n&&(o=!0,t=void 0);const i=f((r,n)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=i,o||Wt(e,t),i}function qt(e){const t=e._state;if("closed"===t||"errored"===t)return v(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=f((t,r)=>{const n={_resolve:t,_reject:r};e._closeRequest=n}),n=e._writer;var o;return void 0!==n&&e._backpressure&&"writable"===t&&br(n),Ne(o=e._writableStreamController,Xt,0),or(o),r}function Bt(e,t){"writable"!==e._state?Ht(e):Wt(e,t)}function Wt(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const n=e._writer;void 0!==n&&$t(n,t),!function(e){return void 0!==e._inFlightWriteRequest||void 0!==e._inFlightCloseRequest}(e)&&r._started&&Ht(e)}function Ht(e){e._state="errored",e._writableStreamController[P]();const t=e._storedError;if(e._writeRequests.forEach(e=>{e._reject(t)}),e._writeRequests=new A,void 0===e._pendingAbortRequest)return void Ft(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void Ft(e);m(e._writableStreamController[T](r._reason),()=>(r._resolve(),Ft(e),null),t=>(r._reject(t),Ft(e),null))}function Vt(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function Ft(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&pr(t,e._storedError)}function Gt(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){_r(e)}(r):br(r)),e._backpressure=t}Object.defineProperties(Dt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),a(Dt.prototype.abort,"abort"),a(Dt.prototype.close,"close"),a(Dt.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Dt.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class Yt{constructor(e){if(G(e,1,"WritableStreamDefaultWriter"),Ut(e,"First parameter"),Mt(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;const t=e._state;if("writable"===t)!Vt(e)&&e._backpressure?_r(this):yr(this),dr(this);else if("erroring"===t)mr(this,e._storedError),dr(this);else if("closed"===t)yr(this),dr(this),vr(this);else{const t=e._storedError;mr(this,t),fr(this,t)}}get closed(){return zt(this)?this._closedPromise:v(lr("closed"))}get desiredSize(){if(!zt(this))throw lr("desiredSize");if(void 0===this._ownerWritableStream)throw hr("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:nr(t._writableStreamController)}(this)}get ready(){return zt(this)?this._readyPromise:v(lr("ready"))}abort(e=void 0){return zt(this)?void 0===this._ownerWritableStream?v(hr("abort")):function(e,t){return jt(e._ownerWritableStream,t)}(this,e):v(lr("abort"))}close(){if(!zt(this))return v(lr("close"));const e=this._ownerWritableStream;return void 0===e?v(hr("close")):Vt(e)?v(new TypeError("Cannot close an already-closing stream")):Kt(this)}releaseLock(){if(!zt(this))throw lr("releaseLock");void 0!==this._ownerWritableStream&&Qt(this)}write(e=void 0){return zt(this)?void 0===this._ownerWritableStream?v(hr("write to")):Jt(this,e):v(lr("write"))}}function zt(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof Yt}function Kt(e){return qt(e._ownerWritableStream)}function $t(e,t){"pending"===e._readyPromiseState?gr(e,t):function(e,t){mr(e,t)}(e,t)}function Qt(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");$t(e,r),function(e,t){"pending"===e._closedPromiseState?pr(e,t):function(e,t){fr(e,t)}(e,t)}(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function Jt(e,t){const r=e._ownerWritableStream,n=r._writableStreamController,o=function(e,t){if(void 0===e._strategySizeAlgorithm)return 1;try{return e._strategySizeAlgorithm(t)}catch(t){return ir(e,t),1}}(n,t);if(r!==e._ownerWritableStream)return v(hr("write to"));const i=r._state;if("errored"===i)return v(r._storedError);if(Vt(r)||"closed"===i)return v(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return v(r._storedError);const s=function(e){return f((t,r)=>{const n={_resolve:t,_reject:r};e._writeRequests.push(n)})}(r);return function(e,t,r){try{Ne(e,t,r)}catch(t){return void ir(e,t)}const n=e._controlledWritableStream;Vt(n)||"writable"!==n._state||Gt(n,sr(e)),or(e)}(n,t,o),s}Object.defineProperties(Yt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),a(Yt.prototype.abort,"abort"),a(Yt.prototype.close,"close"),a(Yt.prototype.releaseLock,"releaseLock"),a(Yt.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Yt.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Xt={};class Zt{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!er(this))throw cr("abortReason");return this._abortReason}get signal(){if(!er(this))throw cr("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(e=void 0){if(!er(this))throw cr("error");"writable"===this._controlledWritableStream._state&&ar(this,e)}[T](e){const t=this._abortAlgorithm(e);return rr(this),t}[P](){Ue(this)}}function er(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof Zt}function tr(e,t,r,n,o,i,s,a){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,Ue(t),t._abortReason=void 0,t._abortController=function(){if("function"==typeof AbortController)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=a,t._strategyHWM=s,t._writeAlgorithm=n,t._closeAlgorithm=o,t._abortAlgorithm=i;const u=sr(t);Gt(e,u),m(p(r()),()=>(t._started=!0,or(t),null),r=>(t._started=!0,Bt(e,r),null))}function rr(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function nr(e){return e._strategyHWM-e._queueTotalSize}function or(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void Ht(t);if(0===e._queue.length)return;const r=e._queue.peek().value;r===Xt?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),Ce(e);const r=e._closeAlgorithm();rr(e),m(r,()=>(function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const t=e._writer;void 0!==t&&vr(t)}(t),null),e=>(function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),Bt(e,t)}(t,e),null))}(e):function(e,t){const r=e._controlledWritableStream;!function(e){e._inFlightWriteRequest=e._writeRequests.shift()}(r),m(e._writeAlgorithm(t),()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(Ce(e),!Vt(r)&&"writable"===t){const t=sr(e);Gt(r,t)}return or(e),null},t=>("writable"===r._state&&rr(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,Bt(e,t)}(r,t),null))}(e,r)}function ir(e,t){"writable"===e._controlledWritableStream._state&&ar(e,t)}function sr(e){return nr(e)<=0}function ar(e,t){const r=e._controlledWritableStream;rr(e),Wt(r,t)}function ur(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function cr(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function lr(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function hr(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function dr(e){e._closedPromise=f((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"})}function fr(e,t){dr(e),pr(e,t)}function pr(e,t){void 0!==e._closedPromise_reject&&(w(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function vr(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function _r(e){e._readyPromise=f((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r}),e._readyPromiseState="pending"}function mr(e,t){_r(e),gr(e,t)}function yr(e){_r(e),br(e)}function gr(e,t){void 0!==e._readyPromise_reject&&(w(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function br(e){void 0!==e._readyPromise_resolve&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}Object.defineProperties(Zt.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Zt.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const wr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0,Er=function(){const e=null==wr?void 0:wr.DOMException;return function(e){if("function"!=typeof e&&"object"!=typeof e)return!1;if("DOMException"!==e.name)return!1;try{return new e,!0}catch(e){return!1}}(e)?e:void 0}()||function(){const e=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return a(e,"DOMException"),e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}();function Sr(e,t,r,n,o,i){const s=J(e),a=Lt(t);e._disturbed=!0;const u=new Ir(a),c=new Tr(u);return f((l,h)=>{let d;if(void 0!==i){if(d=()=>{const r=void 0!==i.reason?i.reason:new Er("Aborted","AbortError"),s=[];n||s.push(()=>"writable"===t._state?jt(t,r):p(void 0)),o||s.push(()=>"readable"===e._state?Xr(e,r):p(void 0)),I(()=>Promise.all(s.map(e=>e())),!0,r)},i.aborted)return void d();i.addEventListener("abort",d)}function g(){for(;!u._shuttingDown&&!t._backpressure&&"writable"===t._state&&!Vt(t)&&"readable"===e._state&&ae(s);)se(s,c);if(u._shuttingDown)return p(!0);if(t._backpressure)return _(a._readyPromise,g);const r=new Ar(u);return se(s,r),r._promise}var b,E,S;if(Pr(e,s._closedPromise,e=>(n?A(!0,e):I(()=>jt(t,e),!0,e),null)),Pr(t,a._closedPromise,t=>(o?A(!0,t):I(()=>Xr(e,t),!0,t),null)),b=e,E=s._closedPromise,S=()=>(r?A():I(()=>function(e){const t=e._ownerWritableStream,r=t._state;return Vt(t)||"closed"===r?p(void 0):"errored"===r?v(t._storedError):Kt(e)}(a)),null),"closed"===b._state?S():y(E,S),Vt(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");o?A(!0,t):I(()=>Xr(e,t),!0,t)}function I(e,r,n){function o(){return m(e(),()=>T(r,n),e=>T(!0,e)),null}u._shuttingDown||(u._shuttingDown=!0,"writable"!==t._state||Vt(t)?o():y(u._waitForWritesToFinish(),o))}function A(e,r){u._shuttingDown||(u._shuttingDown=!0,"writable"!==t._state||Vt(t)?T(e,r):y(u._waitForWritesToFinish(),()=>T(e,r)))}function T(e,t){return Qt(a),L(s),void 0!==i&&i.removeEventListener("abort",d),e?h(t):l(void 0),null}w(f((e,t)=>{!function r(n){n?e():_(g(),r,t)}(!1)}))})}class Ir{constructor(e){this._writer=e,this._shuttingDown=!1,this._currentWrite=p(void 0)}_waitForWritesToFinish(){const e=this._currentWrite;return _(this._currentWrite,()=>e!==this._currentWrite?this._waitForWritesToFinish():void 0)}}class Ar{constructor(e){this._state=e,this._promise=f((e,t)=>{this._resolvePromise=e,this._rejectPromise=t})}_chunkSteps(e){this._state._currentWrite=_(Jt(this._state._writer,e),void 0,o),this._resolvePromise(!1)}_closeSteps(){this._resolvePromise(!0)}_errorSteps(e){this._rejectPromise(e)}}class Tr{constructor(e){this._state=e}_chunkSteps(e){this._state._currentWrite=_(Jt(this._state._writer,e),void 0,o)}_closeSteps(){}_errorSteps(e){}}function Pr(e,t,r){"errored"===e._state?r(e._storedError):g(t,r)}class Or{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!Rr(this))throw qr("desiredSize");return xr(this)}close(){if(!Rr(this))throw qr("close");if(!Mr(this))throw new TypeError("The stream is not in a state that permits close");Dr(this)}enqueue(e=void 0){if(!Rr(this))throw qr("enqueue");if(!Mr(this))throw new TypeError("The stream is not in a state that permits enqueue");return Lr(this,e)}error(e=void 0){if(!Rr(this))throw qr("error");kr(this,e)}[O](e){Ue(this);const t=this._cancelAlgorithm(e);return Ur(this),t}[R](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=Ce(this);this._closeRequested&&0===this._queue.length?(Ur(this),Zr(t)):Cr(this),e._chunkSteps(r)}else X(t,e),Cr(this)}[C](){return this._queue.length>0}[N](){}}function Rr(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")&&e instanceof Or}function Cr(e){Nr(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,m(e._pullAlgorithm(),()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,Cr(e)),null),t=>(kr(e,t),null))))}function Nr(e){const t=e._controlledReadableStream;return!!Mr(e)&&!!e._started&&(!!(Jr(t)&&ee(t)>0)||xr(e)>0)}function Ur(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Dr(e){if(!Mr(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Ur(e),Zr(t))}function Lr(e,t){if(!Mr(e))return;const r=e._controlledReadableStream;if(Jr(r)&&ee(r)>0)Z(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw kr(e,t),t}try{Ne(e,t,r)}catch(t){throw kr(e,t),t}}Cr(e)}function kr(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(Ue(e),Ur(e),en(r,t))}function xr(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Mr(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function jr(e,t,r,n,o,i,s){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,Ue(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=s,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,e._readableStreamController=t,m(p(r()),()=>(t._started=!0,Cr(t),null),e=>(kr(t,e),null))}function qr(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function Br(e){return i(t=e)&&void 0!==t.getReader?function(e){let t;return t=zr(o,function(){let r;try{r=e.read()}catch(r){return v(r)}return b(r,e=>{if(!i(e))throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");if(e.done)Dr(t._readableStreamController);else{const r=e.value;Lr(t._readableStreamController,r)}})},function(t){try{return p(e.cancel(t))}catch(t){return v(t)}},0),t}(e.getReader()):function(e){let t;const r=we(e,"async");return t=zr(o,function(){let e;try{e=Ee(r)}catch(e){return v(e)}return b(p(e),e=>{if(!i(e))throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");if(e.done)Dr(t._readableStreamController);else{const r=e.value;Lr(t._readableStreamController,r)}})},function(e){const t=r.iterator;let n;try{n=ye(t,"return")}catch(e){return v(e)}return void 0===n?p(void 0):b(I(n,t,[e]),e=>{if(!i(e))throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")})},0),t}(e);var t}function Wr(e,t,r){return V(e,r),r=>I(e,t,[r])}function Hr(e,t,r){return V(e,r),r=>I(e,t,[r])}function Vr(e,t,r){return V(e,r),r=>S(e,t,[r])}function Fr(e,t){if("bytes"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function Gr(e,t){H(e,t);const r=null==e?void 0:e.preventAbort,n=null==e?void 0:e.preventCancel,o=null==e?void 0:e.preventClose,i=null==e?void 0:e.signal;return void 0!==i&&function(e,t){if(!function(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}(e))throw new TypeError(`${t} is not an AbortSignal.`)}(i,`${t} has member 'signal' that`),{preventAbort:Boolean(r),preventCancel:Boolean(n),preventClose:Boolean(o),signal:i}}Object.defineProperties(Or.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),a(Or.prototype.close,"close"),a(Or.prototype.enqueue,"enqueue"),a(Or.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Or.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class Yr{constructor(e={},t={}){void 0===e?e=null:F(e,"First parameter");const r=Tt(t,"Second parameter"),n=function(e,t){H(e,t);const r=e,n=null==r?void 0:r.autoAllocateChunkSize,o=null==r?void 0:r.cancel,i=null==r?void 0:r.pull,s=null==r?void 0:r.start,a=null==r?void 0:r.type;return{autoAllocateChunkSize:void 0===n?void 0:$(n,`${t} has member 'autoAllocateChunkSize' that`),cancel:void 0===o?void 0:Wr(o,r,`${t} has member 'cancel' that`),pull:void 0===i?void 0:Hr(i,r,`${t} has member 'pull' that`),start:void 0===s?void 0:Vr(s,r,`${t} has member 'start' that`),type:void 0===a?void 0:Fr(a,`${t} has member 'type' that`)}}(e,"First parameter");if($r(this),"bytes"===n.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");!function(e,t,r){const n=Object.create(xe.prototype);let o,i,s;o=void 0!==t.start?()=>t.start(n):()=>{},i=void 0!==t.pull?()=>t.pull(n):()=>p(void 0),s=void 0!==t.cancel?e=>t.cancel(e):()=>p(void 0);const a=t.autoAllocateChunkSize;if(0===a)throw new TypeError("autoAllocateChunkSize must be greater than 0");ct(e,n,o,i,s,r,a)}(this,n,It(r,0))}else{const e=At(r);!function(e,t,r,n){const o=Object.create(Or.prototype);let i,s,a;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.pull?()=>t.pull(o):()=>p(void 0),a=void 0!==t.cancel?e=>t.cancel(e):()=>p(void 0),jr(e,o,i,s,a,r,n)}(this,n,It(r,1),e)}}get locked(){if(!Qr(this))throw tn("locked");return Jr(this)}cancel(e=void 0){return Qr(this)?Jr(this)?v(new TypeError("Cannot cancel a stream that already has a reader")):Xr(this,e):v(tn("cancel"))}getReader(e=void 0){if(!Qr(this))throw tn("getReader");return void 0===function(e,t){H(e,t);const r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:dt(r,`${t} has member 'mode' that`)}}(e,"First parameter").mode?J(this):ft(this)}pipeThrough(e,t={}){if(!Qr(this))throw tn("pipeThrough");G(e,1,"pipeThrough");const r=function(e,t){H(e,t);const r=null==e?void 0:e.readable;Y(r,"readable","ReadableWritablePair"),Q(r,`${t} has member 'readable' that`);const n=null==e?void 0:e.writable;return Y(n,"writable","ReadableWritablePair"),Ut(n,`${t} has member 'writable' that`),{readable:r,writable:n}}(e,"First parameter"),n=Gr(t,"Second parameter");if(Jr(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Mt(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return w(Sr(this,r.writable,n.preventClose,n.preventAbort,n.preventCancel,n.signal)),r.readable}pipeTo(e,t={}){if(!Qr(this))return v(tn("pipeTo"));if(void 0===e)return v("Parameter 1 is required in 'pipeTo'.");if(!xt(e))return v(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let r;try{r=Gr(t,"Second parameter")}catch(e){return v(e)}return Jr(this)?v(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Mt(e)?v(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Sr(this,e,r.preventClose,r.preventAbort,r.preventCancel,r.signal)}tee(){if(!Qr(this))throw tn("tee");return fe(function(e){return Me(e._readableStreamController)?function(e){let t,r,n,o,i,s=J(e),a=!1,u=!1,c=!1,l=!1,h=!1;const d=f(e=>{i=e});function v(e){g(e._closedPromise,t=>(e!==s||(nt(n._readableStreamController,t),nt(o._readableStreamController,t),l&&h||i(void 0)),null))}function _(){bt(s)&&(L(s),s=J(e),v(s)),se(s,{_chunkSteps:t=>{E(()=>{u=!1,c=!1;const r=t;let s=t;if(!l&&!h)try{s=Re(t)}catch(t){return nt(n._readableStreamController,t),nt(o._readableStreamController,t),void i(Xr(e,t))}l||rt(n._readableStreamController,r),h||rt(o._readableStreamController,s),a=!1,u?y():c&&b()})},_closeSteps:()=>{a=!1,l||tt(n._readableStreamController),h||tt(o._readableStreamController),n._readableStreamController._pendingPullIntos.length>0&&at(n._readableStreamController,0),o._readableStreamController._pendingPullIntos.length>0&&at(o._readableStreamController,0),l&&h||i(void 0)},_errorSteps:()=>{a=!1}})}function m(t,r){ie(s)&&(L(s),s=ft(e),v(s));const d=r?o:n,f=r?n:o;wt(s,t,1,{_chunkSteps:t=>{E(()=>{u=!1,c=!1;const n=r?h:l;if(r?l:h)n||ut(d._readableStreamController,t);else{let r;try{r=Re(t)}catch(t){return nt(d._readableStreamController,t),nt(f._readableStreamController,t),void i(Xr(e,t))}n||ut(d._readableStreamController,t),rt(f._readableStreamController,r)}a=!1,u?y():c&&b()})},_closeSteps:e=>{a=!1;const t=r?h:l,n=r?l:h;t||tt(d._readableStreamController),n||tt(f._readableStreamController),void 0!==e&&(t||ut(d._readableStreamController,e),!n&&f._readableStreamController._pendingPullIntos.length>0&&at(f._readableStreamController,0)),t&&n||i(void 0)},_errorSteps:()=>{a=!1}})}function y(){if(a)return u=!0,p(void 0);a=!0;const e=it(n._readableStreamController);return null===e?_():m(e._view,!1),p(void 0)}function b(){if(a)return c=!0,p(void 0);a=!0;const e=it(o._readableStreamController);return null===e?_():m(e._view,!0),p(void 0)}function w(){}return n=Kr(w,y,function(n){if(l=!0,t=n,h){const n=fe([t,r]),o=Xr(e,n);i(o)}return d}),o=Kr(w,b,function(n){if(h=!0,r=n,l){const n=fe([t,r]),o=Xr(e,n);i(o)}return d}),v(s),[n,o]}(e):function(e){const t=J(e);let r,n,o,i,s,a=!1,u=!1,c=!1,l=!1;const h=f(e=>{s=e});function d(){return a?(u=!0,p(void 0)):(a=!0,se(t,{_chunkSteps:e=>{E(()=>{u=!1;const t=e,r=e;c||Lr(o._readableStreamController,t),l||Lr(i._readableStreamController,r),a=!1,u&&d()})},_closeSteps:()=>{a=!1,c||Dr(o._readableStreamController),l||Dr(i._readableStreamController),c&&l||s(void 0)},_errorSteps:()=>{a=!1}}),p(void 0))}function v(){}return o=zr(v,d,function(t){if(c=!0,r=t,l){const t=fe([r,n]),o=Xr(e,t);s(o)}return h}),i=zr(v,d,function(t){if(l=!0,n=t,c){const t=fe([r,n]),o=Xr(e,t);s(o)}return h}),g(t._closedPromise,e=>(kr(o._readableStreamController,e),kr(i._readableStreamController,e),c&&l||s(void 0),null)),[o,i]}(e)}(this))}values(e=void 0){if(!Qr(this))throw tn("values");return function(e,t){const r=J(e),n=new Se(r,t),o=Object.create(Ae);return o._asyncIteratorImpl=n,o}(this,function(e){H(e,"First parameter");const t=null==e?void 0:e.preventCancel;return{preventCancel:Boolean(t)}}(e).preventCancel)}[be](e){return this.values(e)}static from(e){return Br(e)}}function zr(e,t,r,n=1,o=()=>1){const i=Object.create(Yr.prototype);return $r(i),jr(i,Object.create(Or.prototype),e,t,r,n,o),i}function Kr(e,t,r){const n=Object.create(Yr.prototype);return $r(n),ct(n,Object.create(xe.prototype),e,t,r,0,void 0),n}function $r(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function Qr(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")&&e instanceof Yr}function Jr(e){return void 0!==e._reader}function Xr(e,t){if(e._disturbed=!0,"closed"===e._state)return p(void 0);if("errored"===e._state)return v(e._storedError);Zr(e);const r=e._reader;if(void 0!==r&&bt(r)){const e=r._readIntoRequests;r._readIntoRequests=new A,e.forEach(e=>{e._closeSteps(void 0)})}return b(e._readableStreamController[O](t),o)}function Zr(e){e._state="closed";const t=e._reader;if(void 0!==t&&(q(t),ie(t))){const e=t._readRequests;t._readRequests=new A,e.forEach(e=>{e._closeSteps()})}}function en(e,t){e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(j(r,t),ie(r)?ue(r,t):Et(r,t))}function tn(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function rn(e,t){H(e,t);const r=null==e?void 0:e.highWaterMark;return Y(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:z(r)}}Object.defineProperties(Yr,{from:{enumerable:!0}}),Object.defineProperties(Yr.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),a(Yr.from,"from"),a(Yr.prototype.cancel,"cancel"),a(Yr.prototype.getReader,"getReader"),a(Yr.prototype.pipeThrough,"pipeThrough"),a(Yr.prototype.pipeTo,"pipeTo"),a(Yr.prototype.tee,"tee"),a(Yr.prototype.values,"values"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Yr.prototype,Symbol.toStringTag,{value:"ReadableStream",configurable:!0}),Object.defineProperty(Yr.prototype,be,{value:Yr.prototype.values,writable:!0,configurable:!0});const nn=e=>e.byteLength;a(nn,"size");class on{constructor(e){G(e,1,"ByteLengthQueuingStrategy"),e=rn(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!an(this))throw sn("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!an(this))throw sn("size");return nn}}function sn(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function an(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")&&e instanceof on}Object.defineProperties(on.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(on.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const un=()=>1;a(un,"size");class cn{constructor(e){G(e,1,"CountQueuingStrategy"),e=rn(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!hn(this))throw ln("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!hn(this))throw ln("size");return un}}function ln(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function hn(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")&&e instanceof cn}function dn(e,t,r){return V(e,r),r=>I(e,t,[r])}function fn(e,t,r){return V(e,r),r=>S(e,t,[r])}function pn(e,t,r){return V(e,r),(r,n)=>I(e,t,[r,n])}function vn(e,t,r){return V(e,r),r=>I(e,t,[r])}Object.defineProperties(cn.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(cn.prototype,Symbol.toStringTag,{value:"CountQueuingStrategy",configurable:!0});class _n{constructor(e={},t={},r={}){void 0===e&&(e=null);const n=Tt(t,"Second parameter"),o=Tt(r,"Third parameter"),i=function(e,t){H(e,t);const r=null==e?void 0:e.cancel,n=null==e?void 0:e.flush,o=null==e?void 0:e.readableType,i=null==e?void 0:e.start,s=null==e?void 0:e.transform,a=null==e?void 0:e.writableType;return{cancel:void 0===r?void 0:vn(r,e,`${t} has member 'cancel' that`),flush:void 0===n?void 0:dn(n,e,`${t} has member 'flush' that`),readableType:o,start:void 0===i?void 0:fn(i,e,`${t} has member 'start' that`),transform:void 0===s?void 0:pn(s,e,`${t} has member 'transform' that`),writableType:a}}(e,"First parameter");if(void 0!==i.readableType)throw new RangeError("Invalid readableType specified");if(void 0!==i.writableType)throw new RangeError("Invalid writableType specified");const s=It(o,0),a=At(o),u=It(n,1),c=At(n);let l;!function(e,t,r,n,o,i){function s(){return t}e._writable=function(e,t,r,n,o=1,i=()=>1){const s=Object.create(Dt.prototype);return kt(s),tr(s,Object.create(Zt.prototype),e,t,r,n,o,i),s}(s,function(t){return function(e,t){const r=e._transformStreamController;return e._backpressure?b(e._backpressureChangePromise,()=>{const n=e._writable;if("erroring"===n._state)throw n._storedError;return Tn(r,t)}):Tn(r,t)}(e,t)},function(){return function(e){const t=e._transformStreamController;if(void 0!==t._finishPromise)return t._finishPromise;const r=e._readable;t._finishPromise=f((e,r)=>{t._finishPromise_resolve=e,t._finishPromise_reject=r});const n=t._flushAlgorithm();return In(t),m(n,()=>("errored"===r._state?Rn(t,r._storedError):(Dr(r._readableStreamController),On(t)),null),e=>(kr(r._readableStreamController,e),Rn(t,e),null)),t._finishPromise}(e)},function(t){return function(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=e._readable;r._finishPromise=f((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t});const o=r._cancelAlgorithm(t);return In(r),m(o,()=>("errored"===n._state?Rn(r,n._storedError):(kr(n._readableStreamController,t),On(r)),null),e=>(kr(n._readableStreamController,e),Rn(r,e),null)),r._finishPromise}(e,t)},r,n),e._readable=zr(s,function(){return function(e){return wn(e,!1),e._backpressureChangePromise}(e)},function(t){return function(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=e._writable;r._finishPromise=f((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t});const o=r._cancelAlgorithm(t);return In(r),m(o,()=>("errored"===n._state?Rn(r,n._storedError):(ir(n._writableStreamController,t),bn(e),On(r)),null),t=>(ir(n._writableStreamController,t),bn(e),Rn(r,t),null)),r._finishPromise}(e,t)},o,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,wn(e,!0),e._transformStreamController=void 0}(this,f(e=>{l=e}),u,c,s,a),function(e,t){const r=Object.create(En.prototype);let n,o,i;n=void 0!==t.transform?e=>t.transform(e,r):e=>{try{return An(r,e),p(void 0)}catch(e){return v(e)}},o=void 0!==t.flush?()=>t.flush(r):()=>p(void 0),i=void 0!==t.cancel?e=>t.cancel(e):()=>p(void 0),function(e,t,r,n,o){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=n,t._cancelAlgorithm=o,t._finishPromise=void 0,t._finishPromise_resolve=void 0,t._finishPromise_reject=void 0}(e,r,n,o,i)}(this,i),void 0!==i.start?l(i.start(this._transformStreamController)):l(void 0)}get readable(){if(!mn(this))throw Cn("readable");return this._readable}get writable(){if(!mn(this))throw Cn("writable");return this._writable}}function mn(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")&&e instanceof _n}function yn(e,t){kr(e._readable._readableStreamController,t),gn(e,t)}function gn(e,t){In(e._transformStreamController),ir(e._writable._writableStreamController,t),bn(e)}function bn(e){e._backpressure&&wn(e,!1)}function wn(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=f(t=>{e._backpressureChangePromise_resolve=t}),e._backpressure=t}Object.defineProperties(_n.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(_n.prototype,Symbol.toStringTag,{value:"TransformStream",configurable:!0});class En{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!Sn(this))throw Pn("desiredSize");return xr(this._controlledTransformStream._readable._readableStreamController)}enqueue(e=void 0){if(!Sn(this))throw Pn("enqueue");An(this,e)}error(e=void 0){if(!Sn(this))throw Pn("error");var t;t=e,yn(this._controlledTransformStream,t)}terminate(){if(!Sn(this))throw Pn("terminate");!function(e){const t=e._controlledTransformStream;Dr(t._readable._readableStreamController),gn(t,new TypeError("TransformStream terminated"))}(this)}}function Sn(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")&&e instanceof En}function In(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0,e._cancelAlgorithm=void 0}function An(e,t){const r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!Mr(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{Lr(n,t)}catch(e){throw gn(r,e),r._readable._storedError}const o=function(e){return!Nr(e)}(n);o!==r._backpressure&&wn(r,!0)}function Tn(e,t){return b(e._transformAlgorithm(t),void 0,t=>{throw yn(e._controlledTransformStream,t),t})}function Pn(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function On(e){void 0!==e._finishPromise_resolve&&(e._finishPromise_resolve(),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function Rn(e,t){void 0!==e._finishPromise_reject&&(w(e._finishPromise),e._finishPromise_reject(t),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function Cn(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}Object.defineProperties(En.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),a(En.prototype.enqueue,"enqueue"),a(En.prototype.error,"error"),a(En.prototype.terminate,"terminate"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(En.prototype,Symbol.toStringTag,{value:"TransformStreamDefaultController",configurable:!0});var Nn,Un=(Nn=function(e,t){return Nn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},Nn(e,t)},function(e,t){function r(){this.constructor=e}Nn(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),Dn=function(){return Dn=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Dn.apply(this,arguments)},Ln="Error when aborting requestTask",kn=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=o||"请求超时",r._restrictedMethods=i||["get","post","upload","download"],r}return Un(t,e),t.prototype.post=function(e){var t=this;return new Promise(function(r,o){var i=e.url,s=e.data,a=e.headers,u=wx.request({url:(0,n.formatUrl)("https:",i),data:s,timeout:t._timeout,method:"POST",header:a,success:function(e){e.statusCode>=200&&e.statusCode<300?r({statusCode:e.statusCode,status:e.statusCode,data:e.data}):o(e)},fail:function(e){o(e)},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("post")&&"request:fail timeout"===e.errMsg){console.warn(t._timeoutMsg);try{u.abort()}catch(e){}}}})})},t.prototype.get=function(e){var t=this;return new Promise(function(r,o){var i=e.url,s=e.body,a=e.headers,u=(0,n.formatUrl)("https:",i),c=wx.request({url:u,data:s,timeout:t._timeout,method:"GET",header:a,success:function(e){e.statusCode>=200&&e.statusCode<300?r({statusCode:e.statusCode,status:e.statusCode,data:e.data}):o(e)},fail:function(e){o(e)},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("get")&&e.errMsg.includes("timeout")){console.warn(t._timeoutMsg);try{c.abort()}catch(e){console.warn(Ln,e)}}}})})},t.prototype.upload=function(e){var t=this,r=this;return new Promise(function(n){return function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})}(t,void 0,void 0,function(){var t,o,i,s,a,u;return function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,function(c){return t=e.url,o=e.file,i=e.data,s=e.headers,a=e.onUploadProgress,u=wx.uploadFile({url:t,filePath:o,name:"file",formData:Dn({},i),header:s,timeout:this._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(t.statusCode=parseInt(i.success_action_status,10)),n(t)},fail:function(e){n(e)},complete:function(e){if(e&&e.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{u.abort()}catch(e){}}}}),a&&u.onProgressUpdate(function(e){a(e)}),[2]})})})},t.prototype.download=function(e){var t=this,r=this;return new Promise(function(o,i){var s=e.url,a=e.headers,u=wx.downloadFile({url:(0,n.formatUrl)("https:",s),header:a,timeout:t._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?o({statusCode:200,tempFilePath:e.tempFilePath}):o(e)},fail:function(e){i(e)},complete:function(e){if(e&&e.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("download")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{u.abort()}catch(e){}}}})})},t.prototype.fetch=function(e){var t=e.url,r=e.body,o=e.enableAbort,i=e.headers,s=e.method,a=e.stream,u=void 0!==a&&a,c=e.signal,l=e.timeout,h=this,d=null!=l?l:this._timeout,f=null,p=new Yr({start:function(e){f=e},cancel:function(){f=null}});return new Promise(function(e,a){u&&e({data:p});var l=wx.request({url:(0,n.formatUrl)("https:",t),data:r,timeout:d,method:s.toUpperCase(),header:i,success:function(t){null==f||f.close(),!u&&e(t)},fail:function(e){if(null==f||f.close(),a(e),u)throw e},complete:function(e){if(e&&e.errMsg&&d&&-1!==h._restrictedMethods.indexOf("post")&&o&&"request:fail timeout"===e.errMsg){console.warn(h._timeoutMsg);try{l.abort()}catch(e){console.warn(Ln,e)}}},enableChunked:u});if(l.onChunkReceived(function(e){null==f||f.enqueue(new Uint8Array(e.data))}),c){var v=function(){try{l.abort()}catch(e){console.warn(Ln,e)}};c.aborted?v():c.addEventListener("abort",function(){return v()})}})},t.prototype.patch=function(e){var t=e.method,r=e.headers,n=JSON.parse(JSON.stringify(r||{}));return"PATCH"===t.toUpperCase()&&(n["X-HTTP-Method-Override"]="PATCH",t="POST"),this.post(Dn(Dn({},e),{method:t,headers:n}))},t}(n.AbstractSDKRequest),xn={setItem:function(e,t){wx.setStorageSync(e,t)},getItem:function(e){return wx.getStorageSync(e)},removeItem:function(e){wx.removeStorageSync(e)},clear:function(){wx.clearStorageSync()}},Mn=function(e,t){void 0===t&&(t={});var r=wx.connectSocket(Dn({url:e},t));return{set onopen(e){r.onOpen(e)},set onmessage(e){r.onMessage(e)},set onclose(e){r.onClose(e)},set onerror(e){r.onError(e)},send:function(e){return r.send({data:e})},close:function(e,t){return r.close({code:e,reason:t})},get readyState(){return r.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};function jn(e){var t={},r=e.replace(/^[?#]/,"");return r?(r.split("&").forEach(function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)}),t):t}const qn={genAdapter:function(e){return{root:{globalThis:{}},reqClass:kn,wsClass:Mn,captchaOptions:{openURIWithCallback:function(t){var r=e.EventBus,n={},o=t;console.log("openURIWithCallback",t);var i=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){o=i[1],console.log("openURIWithCallback url",o);var s=i[2];s&&(n=jn(s))}console.log("openURIWithCallback queryObj",n);var a=n.token,u=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(n,["token"]);return/^data:/.test(o)&&!a?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: "+t}):a?new Promise(function(e){console.log("wait for captcha..."),r.$emit("CAPTCHA_DATA_CHANGE",Dn(Dn({},u),{token:a,url:o})),r.$once("RESOLVE_CAPTCHA_DATA",function(t){e(t)})}):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:xn,primaryStorage:n.StorageType.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(e){return!1}return!0},runtime:"wx_mp"}},548:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.useAuthAdapter=void 0;var s=r(19),a=function(){function e(e){var t,r;try{this.localStorage=(null==e?void 0:e.localStorage)||((null===(r=null===(t=null==e?void 0:e.adapter)||void 0===t?void 0:t.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(t){this.localStorage=(null==e?void 0:e.localStorage)||{}}}return e.prototype.getItem=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.localStorage.getItem(e)]})})},e.prototype.removeItem=function(e){return o(this,void 0,void 0,function(){return i(this,function(t){return this.localStorage.removeItem(e),[2]})})},e.prototype.setItem=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(r){return this.localStorage.setItem(e,t),[2]})})},e.prototype.getItemSync=function(e){return this.localStorage.getItem(e)},e.prototype.setItemSync=function(e,t){this.localStorage.setItem(e,t)},e.prototype.removeItemSync=function(e){this.localStorage.removeItem(e)},e}(),u=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,c=function(e,t){var r,n,o,i,s=null===(r=null==t?void 0:t.headers)||void 0===r?void 0:r["x-request-id"];return e||(e={}),((null==e?void 0:e.code)||(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.error_code))&&(e={error:e.code||e.data.error,error_description:e.data.error_description||e.message||e.code||e.data.error_code,request_id:e.requestId,error_code:null===(o=e.data)||void 0===o?void 0:o.error_code}),(null==e?void 0:e.request_id)||(e.request_id=e.request_id||s),(null==e?void 0:e.error)?(e.error_uri=(i=null==t?void 0:t.url,u.test(i)?RegExp.$1:i),e):(null==e?void 0:e.data)||{}};t.useAuthAdapter=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var r=n({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(r.storage=new a({localStorage:t.localStorage,adapter:t})),!e.captchaOptions&&(null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!e.baseRequest&&!e.request&&(null==t?void 0:t.reqClass)){var s={timeout:1e4,restrictedMethods:["get","post","upload","download","request"],auth:e.auth},u=new t.reqClass(s);r.baseRequest=function(e,t){var r,s,a,l,h;return o(this,void 0,void 0,function(){var o,d,f,p;return i(this,function(i){switch(i.label){case 0:if(o={},d=(null===(r=t.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(f=null===(a=null===(s=null==u?void 0:u[d])||void 0===s?void 0:s.bind)||void 0===a?void 0:a.call(s,u)))throw new Error("invalid 【".concat(d,"】 request method"));i.label=1;case 1:return i.trys.push([1,3,,4]),(null===(l=t.headers)||void 0===l?void 0:l["content-type"])&&!(null===(h=t.headers)||void 0===h?void 0:h["content-type"].includes("application/json"))||["string","undefined"].includes(typeof t.body)||(t.data=t.data||t.body,t.body=JSON.stringify(t.body)),[4,f(n({url:e},t))];case 2:return o=i.sent(),o=c(o,n(n({},t),{url:e})),[3,4];case 3:throw p=i.sent(),o=n(n({},null==p?void 0:p.data),p);case 4:if(null==o?void 0:o.error)throw o;return[2,o]}})})}}}catch(e){console.error("user adapter generate fail:",e)}return r}(e,e.adapter):function(e,t){var r=n({},e),u={};if((null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!s.adapterForWxMp.isMatch()||e.storage&&e.baseRequest)return r;try{var l=s.adapterForWxMp.genAdapter({}),h=l.localStorage,d=l.reqClass;if(h&&(u.storage=new a({localStorage:h,adapter:t})),d){var f=new d({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});u.request=function(e){return function(t,r){return o(this,void 0,void 0,function(){return i(this,function(o){return[2,new Promise(function(o,i){var s=Object.assign({},r);s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));var a=wx.request({url:t,data:s.body,timeout:e._timeout,method:s.method||"GET",header:s.headers,success:function(e){(e=c(e,n(n({},r),{url:t}))).error&&i(e),o(e)},fail:function(e){i({error:"unreachable",error_description:e.message})},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("request")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{a.abort()}catch(e){}}}})})]})})}}(f)}return r.captchaOptions&&(u.baseRequest=u.request,u.request=void 0),n(n({},r),u)}catch(e){console.error("adapter generate fail:",e)}return r}(e,e.adapter)}},895:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},u=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},c=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},l=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=t.AuthError=t.AuthErrorCode=t.AuthErrorCategory=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=t.Auth=t.generateAuthInstance=t.LoginState=t.User=void 0;var h=r(722),d=r(548),f=r(19),p=r(266),v=r(916);Object.defineProperty(t,"WeixinAuthProvider",{enumerable:!0,get:function(){return v.WeixinAuthProvider}}),Object.defineProperty(t,"CustomAuthProvider",{enumerable:!0,get:function(){return v.CustomAuthProvider}}),Object.defineProperty(t,"AnonymousAuthProvider",{enumerable:!0,get:function(){return v.AnonymousAuthProvider}});var _=r(683),m=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},y=t.User=function(){function e(e){var t=e.cache,r=e.oauthInstance;this.cache=t,this.oauthInstance=r,this.setUserInfo()}var t,r,n;return e.prototype.checkLocalInfo=function(){return u(this,void 0,void 0,function(){return c(this,function(e){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]})})},e.prototype.checkLocalInfoAsync=function(){return u(this,void 0,void 0,function(){var e,t,r,n;return c(this,function(o){switch(o.label){case 0:return e=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return e.uid=o.sent(),t=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return t.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),r=this,[4,this.getLocalUserInfoAsync("email")];case 3:return r.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),n=this,[4,this.getLocalUserInfoAsync("username")];case 4:return n.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}})})},e.prototype.update=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(i({},e))];case 1:return t=r.sent(),this.setLocalUserInfo(t),[2]}})})},e.prototype.updateUserBasicInfo=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(i({},e))];case 1:return t.sent(),[4,this.refresh()];case 2:return t.sent(),[2]}})})},e.prototype.updatePassword=function(e,t){return this.oauthInstance.authApi.updatePasswordByOld({old_password:t,new_password:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(e)];case 1:if("INVALID_ACCESS_TOKEN"===(t=r.sent()).code)throw this.setLocalUserInfo({}),t;return this.setLocalUserInfo(t),[2,t]}})})},e.prototype.getLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);return e?r[e]:r||{}},e.prototype.setLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey;this.cache.setStore(t,e),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(t)];case 1:return[2,r.sent()[e]]}})})},e.prototype.setUserInfo=function(){var e=this,t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at","open_id"].forEach(function(t){e[t]=r[t]})},s([(0,f.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(t=void 0!==h.authModels&&h.authModels.UserProfile)?t:Object]),a("design:returntype","function"==typeof(r="undefined"!=typeof Promise&&Promise)?r:Object)],e.prototype,"update",null),s([(0,f.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String,String]),a("design:returntype",void 0)],e.prototype,"updatePassword",null),s([(0,f.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype",void 0)],e.prototype,"updateUsername",null),s([(0,f.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(n="undefined"!=typeof Promise&&Promise)?n:Object)],e.prototype,"refresh",null),e}();(0,v.applyUserV1Compat)(y);var g=function(){function e(e){var t=e.envId,r=e.cache,n=e.oauthInstance;t||(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new y({cache:this.cache,oauthInstance:n})}return e.prototype.checkLocalState=function(){var e;this.oauthLoginState=null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},e.prototype.checkLocalStateAsync=function(){var e;return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.getLoginState()];case 1:return t.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return t.sent(),[2]}})})},e}();t.LoginState=g;var b=function(e){function t(t){var r=e.call(this)||this;return r.listeners=new Map,r.hasListenerSetUp=!1,r.config=t,r.oauthInstance=t.oauthInstance,r.cache=t.cache,r.init(),r.setAccessKey(),r}var r,n,d,v,y,b,w,E,S,I,A,T,P,O,R,C,N,U,D,L;return o(t,e),t.prototype.signInAnonymously=function(e){return u(this,void 0,Promise,function(){var t,r,n,o,s;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];case 1:return a.sent(),[4,this.createLoginState()];case 2:return t=a.sent(),[4,this.getSession()];case 3:return r=a.sent().data,n=(void 0===r?{}:r).session,[2,i(i({},t),{data:{user:n.user,session:n},error:null})];case 4:return o=a.sent(),(s=new h.AuthError(o,{method:"signInAnonymously"})).category===h.AuthErrorCategory.PROVIDER_NOT_ENABLED?(console.error(s.helpMessage),console.error("[CloudBase Auth] 提示:匿名登录需要在控制台开启「匿名登录」。\n 如果您需要使用用户名密码登录,请改用 auth.signInWithPassword({ username, password })。\n 不要在匿名登录失败后自动回退到密码登录,这两种方式的使用场景不同。")):(console.warn("[CloudBase Auth] signInAnonymously 失败 [".concat(s.category,"]: ").concat(s.message)),s.loginMethodHint&&console.warn(s.loginMethodHint)),[2,{data:{user:null,session:null},error:s}];case 5:return[2]}})})},t.prototype.signUp=function(e){return u(this,void 0,Promise,function(){var t,r,n=this;return c(this,function(o){switch(o.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?(e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[4,this.oauthInstance.authApi.signUp(e)]):[3,2];case 1:return o.sent(),[2,this.createLoginState()];case 2:return o.trys.push([2,4,,5]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)})];case 3:return t=o.sent(),[2,{data:{verifyOtp:function(r){var o=r.token,s=r.messageId,a=void 0===s?t.verification_id:s;return u(n,void 0,Promise,function(){var r,n,s,u,l;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.verify({verification_id:a||t.verification_id,verification_code:String(o)})];case 1:return r=c.sent(),t.is_user?[4,this.signIn({username:e.email||this.formatPhone(e.phone),verification_token:r.verification_token})]:[3,3];case 2:return c.sent(),[3,6];case 3:return delete(n=JSON.parse(JSON.stringify(e))).email,delete n.phone,[4,this.oauthInstance.authApi.signUp(i(i(i({},n),e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}),{verification_token:r.verification_token,verification_code:o}))];case 4:return c.sent(),[4,this.createLoginState()];case 5:c.sent(),c.label=6;case 6:return[4,this.getSession()];case 7:return s=c.sent().data,[2,{data:{user:(u=(void 0===s?{}:s).session).user,session:u},error:null}];case 8:return l=c.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(l,{method:"signUp"})}];case 9:return[2]}})})}},error:null}];case 4:return r=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(r,{method:"signUp"})}];case 5:return[2]}})})},t.prototype.signOut=function(e){var t,r;return u(this,void 0,Promise,function(){var n,o,s;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),n=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return o=a.sent(),[4,this.cache.removeStoreAsync(n)];case 2:return a.sent(),this.setAccessKey(),null===(t=this.config.eventBus)||void 0===t||t.fire(h.EVENTS.LOGIN_STATE_CHANGED,{eventType:h.LOGIN_STATE_CHANGED_TYPE.SIGN_OUT}),null===(r=this.config.eventBus)||void 0===r||r.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT}),[2,i(i({},o),{data:{},error:null})];case 3:return s=a.sent(),[2,{data:{},error:new h.AuthError(s,{method:"signOut"})}];case 4:return[2]}})})},t.prototype.onAuthStateChange=function(e){var t=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var r=Math.random().toString(36);return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(e),{data:{subscription:{id:r,callback:e,unsubscribe:function(){var n=t.listeners.get(r);n&&(n.delete(e),0===n.size&&t.listeners.delete(r))}}}}},t.prototype.signInWithPassword=function(e){return u(this,void 0,Promise,function(){var t,r,n,o;return c(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),this.validateAtLeastOne(e,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.signIn(i({username:e.username||e.email||this.formatPhone(e.phone),password:e.password},e.is_encrypt?{isEncrypt:!0,version:"v2"}:{}))];case 1:return s.sent(),[4,this.getSession()];case 2:return t=s.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=s.sent(),(o=new h.AuthError(n,{method:"signInWithPassword"})).category===h.AuthErrorCategory.PROVIDER_NOT_ENABLED?console.error(o.helpMessage):o.category===h.AuthErrorCategory.INVALID_CREDENTIALS||o.category===h.AuthErrorCategory.USER_NOT_FOUND?console.warn(o.helpMessage):console.warn("[CloudBase Auth] signInWithPassword 失败 [".concat(o.category,"]: ").concat(o.message)),o.loginMethodHint&&console.info(o.loginMethodHint),[2,{data:{user:null,session:null},error:o}];case 4:return[2]}})})},t.prototype.signInWithIdToken=function(e){return u(this,void 0,Promise,function(){var t,r,n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:e.token})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(n,{method:"signInWithIdToken"})}];case 4:return[2]}})})},t.prototype.signInWithOtp=function(e){var t,r,n,o;return u(this,void 0,Promise,function(){var s,a,l=this;return c(this,function(d){switch(d.label){case 0:if(!(null===(t=e.options)||void 0===t?void 0:t.emailRedirectTo)&&(void 0===(null===(r=e.options)||void 0===r?void 0:r.shouldCreateUser)||(null===(n=e.options)||void 0===n?void 0:n.shouldCreateUser)))return[2,this.signUp({email:e.email,phone:e.phone})];d.label=1;case 1:return d.trys.push([1,3,,4]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(i(i({email_redirect_to:null===(o=e.options)||void 0===o?void 0:o.emailRedirectTo},e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}),{target:"USER"}))];case 2:return s=d.sent(),[2,{data:{user:null,session:null,verifyOtp:function(t){var r=t.token,n=t.messageId,o=void 0===n?s.verification_id:n;return u(l,void 0,Promise,function(){return c(this,function(t){return[2,this.verifyOtp({email:e.email,phone:e.phone,token:String(r),messageId:o})]})})}},error:null}];case 3:return a=d.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(a,{method:"signInWithOtp"})}];case 4:return[2]}})})},t.prototype.verifyOAuth=function(e){return u(this,void 0,Promise,function(){var t,r,n,o,s,a,u,l,d;return c(this,function(c){switch(c.label){case 0:t={},c.label=1;case 1:return c.trys.push([1,7,,8]),r=(null==e?void 0:e.code)||_.utils.getQuery("code"),n=(null==e?void 0:e.state)||_.utils.getQuery("state"),r?n?(o=(0,p.getBrowserSession)(n),t.type=null==o?void 0:o.type,(s=(null==e?void 0:e.provider)||(null==o?void 0:o.provider)||_.utils.getQuery("provider"))?[4,this.grantProviderToken({provider_id:s,provider_redirect_uri:location.origin+location.pathname,provider_code:r})]:[2,{data:i(i({},t),{user:null,session:null,redirectUrl:null}),error:new h.AuthError({message:"Provider is required"})}]):[2,{data:{user:null,session:null,redirectUrl:null},error:new h.AuthError({message:"State is required"})}]:[2,{data:{user:null,session:null,redirectUrl:null},error:new h.AuthError({message:"Code is required"})}];case 2:return a=c.sent().provider_token,u=void 0,o.type!==h.OAUTH_TYPE.BIND_IDENTITY?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:a,provider:s,fireEvent:!0})];case 3:return u=c.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:a})];case 5:(u=c.sent()).data=i(i({},t),u.data),c.label=6;case 6:return(l=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),l.delete("state"),u.data.redirectUrl=(0,p.addUrlSearch)(void 0===(null==o?void 0:o.search)?"?".concat(l.toString()):null==o?void 0:o.search,(null==o?void 0:o.hash)||location.hash),(0,p.removeBrowserSession)(n),[2,u];case 7:return d=c.sent(),[2,{data:i(i({},t),{user:null,session:null,redirectUrl:null}),error:new h.AuthError(d,{method:"verifyOAuth"})}];case 8:return[2]}})})},t.prototype.signInWithOAuth=function(e){var t,r,n,o,i;return u(this,void 0,Promise,function(){var s,a,u,l,d,f,v,_,y;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),s=(null===(t=e.options)||void 0===t?void 0:t.redirectTo)||location.href,a=new URL(s),u=a.origin+a.pathname,l=(null===(r=e.options)||void 0===r?void 0:r.state)||"prd-".concat(e.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:e.provider,provider_redirect_uri:u,state:l})];case 1:return d=c.sent().uri,f=decodeURIComponent(d),v=f,(null===(n=e.options)||void 0===n?void 0:n.queryParams)&&(_=new URL(f),Object.entries(e.options.queryParams).forEach(function(e){var t=e[0],r=e[1];_.searchParams.set(t,r)}),v=_.toString()),(0,p.saveToBrowserSession)(l,{provider:e.provider,search:a.search,hash:a.hash,type:(null===(o=e.options)||void 0===o?void 0:o.type)||h.OAUTH_TYPE.SIGN_IN}),m()&&!(null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect)&&window.location.assign(v),[2,{data:{url:v,provider:e.provider},error:null}];case 2:return y=c.sent(),[2,{data:{url:null,provider:null},error:new h.AuthError(y,{method:"signInWithOAuth"})}];case 3:return[2]}})})},t.prototype.getClaims=function(){return u(this,void 0,Promise,function(){var e,t;return c(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return e=r.sent().accessToken,[2,{data:(0,h.weAppJwtDecodeAll)(e),error:null}];case 2:return t=r.sent(),[2,{data:{claims:null,header:null,signature:null},error:new h.AuthError(t,{method:"getClaims"})}];case 3:return[2]}})})},t.prototype.resetPasswordForEmail=function(e,t){return u(this,void 0,Promise,function(){var r,n,o,s,a,l,d=this;return c(this,function(f){switch(f.label){case 0:return f.trys.push([0,2,,3]),this.validateParams({emailOrPhone:e},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),r=(t||{}).redirectTo,n=e.includes("@"),o=void 0,n?o={email:e}:(s=this.formatPhone(e),o={phone_number:s}),[4,this.getVerification(i(i({},o),{target:"USER"}))];case 1:return a=f.sent(),[2,{data:{updateUser:function(t){return u(d,void 0,Promise,function(){var o,i,s,u;return c(this,function(c){switch(c.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.verify({verification_id:a.verification_id,verification_code:t.nonce})];case 2:return o=c.sent(),[4,this.oauthInstance.authApi.resetPassword({email:n?e:void 0,phone_number:n?void 0:e,new_password:t.password,verification_token:o.verification_token})];case 3:return c.sent(),null===(u=this.config.eventBus)||void 0===u||u.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:n?e:void 0,phone:n?void 0:e,password:t.password})];case 4:return i=c.sent(),r&&m()&&window.location.assign(r),[2,i];case 5:return s=c.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(s,{method:"resetPasswordForEmail"})}];case 6:return[2]}})})}},error:null}];case 2:return l=f.sent(),[2,{data:{updateUser:null},error:new h.AuthError(l,{method:"resetPasswordForEmail"})}];case 3:return[2]}})})},t.prototype.resetPasswordForOld=function(e){return u(this,void 0,void 0,function(){var t,r,n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:e.old_password,new_password:e.new_password})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(n,{method:"resetPasswordForOld"})}];case 4:return[2]}})})},t.prototype.verifyOtp=function(e){return u(this,void 0,Promise,function(){var t,r,n,o,i;return c(this,function(s){switch(s.label){case 0:return s.trys.push([0,6,,7]),t=e.type,r=String(e.token),this.validateParams(e,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(t)?[4,this.verify({verification_id:e.messageId,verification_code:r})]:[3,2];case 1:return s.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:e.messageId,is_user:!0},verificationCode:r,username:e.email||this.formatPhone(e.phone)||"",loginType:e.email?"email":"phone"})];case 3:s.sent(),s.label=4;case 4:return[4,this.getSession()];case 5:return n=s.sent().data,[2,{data:{user:(o=(void 0===n?{}:n).session).user,session:o},error:null}];case 6:return i=s.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(i,{method:"verifyOtp"})}];case 7:return[2]}})})},t.prototype.getSession=function(){return u(this,void 0,Promise,function(){var e,t,r,n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=o.sent())&&"accessKey"!==e.scope?[4,this.getUser(!1)]:[2,{data:{session:null,user:null},error:null}];case 2:return t=o.sent().data,r=(void 0===t?{}:t).user,[2,{data:{session:i(i({},e),{user:r}),user:r},error:null}];case 3:return n=o.sent(),[2,{data:{session:null,user:null},error:new h.AuthError(n,{method:"getSession"})}];case 4:return[2]}})})},t.prototype.refreshSession=function(e){return u(this,void 0,Promise,function(){var t,r,n,o,s;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(t=a.sent()).refresh_token=e||t.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(t)];case 2:return r=a.sent(),[4,this.getUser(!1)];case 3:return n=a.sent().data,[2,{data:{user:o=(void 0===n?{}:n).user,session:i(i({},r),{user:o})},error:null}];case 4:return s=a.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(s,{method:"refreshSession"})}];case 5:return[2]}})})},t.prototype.getUser=function(e){return void 0===e&&(e=!0),u(this,void 0,Promise,function(){var t,r,n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(t=o.sent())&&"accessKey"!==t.scope?(r=this.convertToUser,[4,this.getCurrentUser(e)]):[2,{data:{user:null},error:null}];case 2:return[2,{data:{user:r.apply(this,[o.sent()])},error:null}];case 3:return n=o.sent(),[2,{data:{user:null},error:new h.AuthError(n,{method:"getUser"})}];case 4:return[2]}})})},t.prototype.refreshUser=function(){return u(this,void 0,Promise,function(){var e,t,r;return c(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return n.sent(),[4,this.getSession()];case 2:return e=n.sent().data,[2,{data:{user:(t=(void 0===e?{}:e).session).user,session:t},error:null}];case 3:return r=n.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(r,{method:"refreshUser"})}];case 4:return[2]}})})},t.prototype.updateUser=function(e){var t;return u(this,void 0,Promise,function(){var r,n,o,s,a,d,f,p,v,_,m,y,g=this;return c(this,function(b){switch(b.label){case 0:if(b.trys.push([0,8,,9]),!Object.keys(e).some(function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]}))throw new h.AuthError({message:"At least one field must be provided for update"});return r=e.email,n=e.phone,o=l(e,["email","phone"]),a=void 0!==n,d={},(s=void 0!==r)||a?(f=void 0,s?(f={email:e.email},p="email_change"):(v=this.formatPhone(e.phone),f={phone_number:v},p="phone_change"),[4,this.getVerification(i({},f))]):[3,4];case 1:return _=b.sent(),Object.keys(o).length>0?[4,this.updateUserBasicInfo(o)]:[3,3];case 2:b.sent(),b.label=3;case 3:return d={messageId:_.verification_id,verifyOtp:function(t){return u(g,void 0,Promise,function(){var r,n,o,i;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,11,,12]),t.email&&e.email===t.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:t.token,messageId:_.verification_id})]:[3,3];case 1:return(r=a.sent()).error?[2,r]:[4,this.updateUserBasicInfo({email:e.email})];case 2:return a.sent(),[3,9];case 3:return t.phone&&e.phone===t.phone?[4,this.verifyOtp({type:"phone_change",phone:e.phone,token:t.token,messageId:_.verification_id})]:[3,6];case 4:return(r=a.sent()).error?[2,r]:[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return a.sent(),[3,9];case 6:return[4,this.verifyOtp({type:p,email:s?e.email:void 0,phone:s?void 0:e.phone,token:t.token,messageId:_.verification_id})];case 7:return(r=a.sent()).error?[2,r]:[4,this.updateUserBasicInfo(e)];case 8:a.sent(),a.label=9;case 9:return[4,this.getUser(!1)];case 10:return n=a.sent().data.user,null===(i=this.config.eventBus)||void 0===i||i.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:{user:n},error:null}];case 11:return o=a.sent(),[2,{data:{user:null},error:new h.AuthError(o,{method:"updateUser"})}];case 12:return[2]}})})}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:b.sent(),b.label=6;case 6:return[4,this.getUser(!1)];case 7:return m=b.sent().data.user,Object.keys(o).length>0&&(null===(t=this.config.eventBus)||void 0===t||t.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.USER_UPDATED})),[2,{data:i({user:m},d),error:null}];case 8:return y=b.sent(),[2,{data:{user:null},error:new h.AuthError(y,{method:"updateUser"})}];case 9:return[2]}})})},t.prototype.getUserIdentities=function(){var e;return u(this,void 0,Promise,function(){var t,r;return c(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return t=n.sent(),[2,{data:{identities:null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.filter(function(e){return!!e.bind})},error:null}];case 2:return r=n.sent(),[2,{data:{identities:null},error:new h.AuthError(r,{method:"getUserIdentities"})}];case 3:return[2]}})})},t.prototype.linkIdentity=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:e.provider,options:{type:h.OAUTH_TYPE.BIND_IDENTITY}})];case 1:return r.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return t=r.sent(),[2,{data:{provider:null},error:new h.AuthError(t,{method:"linkIdentity"})}];case 3:return[2]}})})},t.prototype.unlinkIdentity=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:e.provider})];case 1:return r.sent(),[2,{data:{},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new h.AuthError(t,{method:"unlinkIdentity"})}];case 3:return[2]}})})},t.prototype.reauthenticate=function(){return u(this,void 0,Promise,function(){var e,t,r,n,o=this;return c(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.getUser(!1)];case 1:return e=s.sent().data.user,this.validateAtLeastOne(e,[["email","phone"]],"You must provide either an email or phone number"),t=e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)},[4,this.getVerification(t)];case 2:return r=s.sent(),[2,{data:{updateUser:function(e){return u(o,void 0,Promise,function(){var n,o,s,a,u;return c(this,function(c){switch(c.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"}}),c.label=1;case 1:return c.trys.push([1,9,,10]),e.password?[4,this.verify({verification_id:r.verification_id,verification_code:e.nonce})]:[3,5];case 2:return n=c.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:n.verification_token})];case 3:return o=c.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:e.password,sudo_token:o.sudo_token})];case 4:return c.sent(),[3,7];case 5:return[4,this.signInWithUsername(i(i({verificationInfo:r,verificationCode:e.nonce},t),{loginType:t.email?"email":"phone"}))];case 6:c.sent(),c.label=7;case 7:return[4,this.getSession()];case 8:return s=c.sent().data,[2,{data:{user:(a=(void 0===s?{}:s).session).user,session:a},error:null}];case 9:return u=c.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(u,{method:"reauthenticate"})}];case 10:return[2]}})})}},error:null}];case 3:return n=s.sent(),[2,{data:{updateUser:null},error:new h.AuthError(n,{method:"reauthenticate"})}];case 4:return[2]}})})},t.prototype.resend=function(e){return u(this,void 0,Promise,function(){var t,r,n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),t="signup"===e.type?"ANY":"USER",r={target:t},"email"in e&&(r.email=e.email),"phone"in e&&(r.phone_number=this.formatPhone(e.phone)),[4,this.oauthInstance.authApi.getVerification(r)];case 1:return[2,{data:{messageId:o.sent().verification_id},error:null}];case 2:return n=o.sent(),[2,{data:{messageId:null},error:new h.AuthError(n,{method:"resend"})}];case 3:return[2]}})})},t.prototype.setSession=function(e){var t;return u(this,void 0,Promise,function(){var r,n,o;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(e,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(e,{throwError:!0})];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,n=(void 0===r?{}:r).session,null===(t=this.config.eventBus)||void 0===t||t.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,{data:{user:n.user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(o,{method:"setSession"})}];case 4:return[2]}})})},t.prototype.exchangeCodeForSession=function(){return u(this,void 0,void 0,function(){return c(this,function(e){return[2]})})},t.prototype.deleteUser=function(e){return u(this,void 0,Promise,function(){var t,r;return c(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(e)];case 1:return t=n.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:t})];case 2:return n.sent(),[2,{data:{},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new h.AuthError(r,{method:"deleteUser"})}];case 4:return[2]}})})},t.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),u(this,void 0,Promise,function(){var t,r,n,o,i;return c(this,function(s){try{return t=e.config_version||"env",r=Object.keys(e.query||{}).map(function(t){return"".concat(t,"=").concat(e.query[t])}).join("&"),f.adapterForWxMp.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(r?"?".concat(r):"")}):(n=e.redirect_uri||window.location.href,o=new URL(n),i="".concat(o.origin,"/__auth/?app_id=").concat(e.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(t,"&redirect_uri=").concat(encodeURIComponent(n)).concat(r?"&".concat(r):""),window.location.href=i),[2,{data:{},error:null}]}catch(e){return[2,{data:{},error:new h.AuthError(e,{method:"toDefaultLoginPage"})}]}return[2]})})},t.prototype.signInWithCustomTicket=function(e){return u(this,void 0,Promise,function(){var t,r,n,o;return c(this,function(s){switch(s.label){case 0:e&&this.setCustomSignFunc(e),s.label=1;case 1:return s.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return s.sent(),[4,this.createLoginState()];case 3:return t=s.sent(),[4,this.getSession()];case 4:return r=s.sent().data,n=(void 0===r?{}:r).session,[2,i(i({},t),{data:{user:n.user,session:n},error:null})];case 5:return o=s.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(o,{method:"signInWithCustomTicket"})}];case 6:return[2]}})})},t.prototype.signInWithOpenId=function(e){var t=(void 0===e?{}:e).useWxCloud,r=void 0===t||t;return u(this,void 0,Promise,function(){var e,t,n,o,s,a,l=this;return c(this,function(d){switch(d.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,t=function(t){return u(l,void 0,void 0,function(){var n,o;return c(this,function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},r)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:n.provider_token},r)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}})})},d.label=1;case 1:return d.trys.push([1,5,,6]),[4,new Promise(function(e,r){wx.login({success:function(n){return u(l,void 0,void 0,function(){var o;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(n.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return o=i.sent(),r(o),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})})];case 2:return d.sent(),[4,this.createLoginState()];case 3:return n=d.sent(),[4,this.getSession()];case 4:return o=d.sent().data,s=(void 0===o?{}:o).session,[2,i(i({},n),{data:{user:s.user,session:s},error:null})];case 5:return a=d.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(a,{method:"signInWithOpenId"})}];case 6:return[2]}})})},t.prototype.signInWithPhoneAuth=function(e){var t=e.phoneCode,r=void 0===t?"":t,n=e.useWxCloud,o=void 0!==n&&n;return u(this,void 0,Promise,function(){var e,t,n,s,a,u,l,d,p;return c(this,function(c){switch(c.label){case 0:return f.adapterForWxMp.isMatch()?(e=wx.getAccountInfoSync().miniProgram,t={provider_params:{provider_code_type:"phone",code:r,appid:e.appId},provider_id:e.appId},[4,wx.login()]):[2,{data:{user:null,session:null},error:new h.AuthError({message:"wx api undefined"})}];case 1:n=c.sent().code,t.provider_code=n,c.label=2;case 2:return c.trys.push([2,5,,6]),[4,this.oauthInstance.authApi.grantProviderToken(t,o)];case 3:if((s=c.sent()).error_code)throw s;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:s.provider_token},o)];case 4:if(null==(a=c.sent())?void 0:a.error_code)throw a;return[3,6];case 5:return u=c.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(u,{method:"signInWithPhoneAuth"})}];case 6:return[4,this.createLoginState()];case 7:return l=c.sent(),[4,this.getSession()];case 8:return d=c.sent().data,p=(void 0===d?{}:d).session,[2,i(i({},l),{data:{user:p.user,session:p},error:null})]}})})},t.prototype.bindPhoneNumber=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.editContact(e)]})})},t.prototype.unbindProvider=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.unbindProvider(e)]})})},t.prototype.bindEmail=function(e){return this.oauthInstance.authApi.editContact(e)},t.prototype.verify=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.verify(e)]})})},t.prototype.getVerification=function(e,t){return u(this,void 0,Promise,function(){return c(this,function(r){return e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[2,this.oauthInstance.authApi.getVerification(e,t)]})})},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var e=this.hasLoginState();return e&&e.user||null}(0,f.printWarn)(f.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(e){return void 0===e&&(e=!0),u(this,void 0,Promise,function(){var t,r,n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),e?[4,this.getLoginState()]:[3,3];case 1:return(t=o.sent())?[4,t.user.refresh()]:[3,3];case 2:o.sent(),o.label=3;case 3:return[3,5];case 4:return o.sent(),[3,5];case 5:return[4,this.getLoginState()];case 6:return(r=o.sent())?(n=r.user.getLocalUserInfo(),[4,r.user.checkLocalInfoAsync()]):[3,8];case 7:return o.sent(),[2,i(i({},r.user),n)];case 8:return[2,null]}})})},t.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return u(this,void 0,Promise,function(){var e,r,n=this;return c(this,function(o){switch(o.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,r=function(r){return u(n,void 0,void 0,function(){var n,o;return c(this,function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},t)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:n.provider_token},t)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[2]}})})},[4,new Promise(function(e,t){wx.login({success:function(o){return u(n,void 0,void 0,function(){var n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return n=i.sent(),t(n),[3,3];case 3:return[2]}})})},fail:function(e){var r=new Error(null==e?void 0:e.errMsg);r.code=null==e?void 0:e.errno,t(r)}})})];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}})})},t.prototype.bindOpenId=function(){return u(this,void 0,Promise,function(){var e,t,r=this;return c(this,function(n){switch(n.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return u(r,void 0,void 0,function(){var r;return c(this,function(n){switch(n.label){case 0:r=void 0,n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}})];case 2:if((null==(r=n.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:r.provider_token})];case 3:return n.sent(),[3,5];case 4:throw n.sent();case 5:return[2]}})})},[4,new Promise(function(e,n){wx.login({success:function(o){return u(r,void 0,void 0,function(){var r;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})})];case 1:return n.sent(),[2]}})})},t.prototype.signInWithUnionId=function(){return u(this,void 0,Promise,function(){var e=this;return c(this,function(t){switch(t.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise(function(t,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return u(e,void 0,void 0,function(){var e,i,s,a,u;return c(this,function(c){switch(c.label){case 0:e=null==n?void 0:n.appId,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:o.code,provider_id:e,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return i=c.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:e,provider_token:s})]:(r(i),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(t(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})})];case 2:return t.sent(),[3,4];case 3:throw t.sent();case 4:return[2,this.createLoginState()]}})})},t.prototype.signInWithSms=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.phoneNum,s=void 0===i?"":i,a=e.bindInfo,l=void 0===a?void 0:a;return u(this,void 0,Promise,function(){return c(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:l,username:s,loginType:"sms"})]}catch(e){throw e}return[2]})})},t.prototype.signInWithEmail=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.bindInfo,s=void 0===i?void 0:i,a=e.email,l=void 0===a?"":a;return u(this,void 0,Promise,function(){return c(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:s,username:l,loginType:"email"})]}catch(e){throw e}return[2]})})},t.prototype.setCustomSignFunc=function(e){this.oauthInstance.authApi.setCustomSignFunc(e)},t.prototype.signIn=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signIn(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.setPassword=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.setPassword(e)]})})},t.prototype.isUsernameRegistered=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:e})];case 1:return[2,t.sent().exist]}})})},t.prototype.hasLoginState=function(){var e;if("async"!==this.cache.mode)return(null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync())?new g({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,f.printWarn)(f.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},t.prototype.getLoginState=function(){return u(this,void 0,void 0,function(){var e;return c(this,function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,null];case 4:return e?[2,new g({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}})})},t.prototype.getUserInfo=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.getCurrentUser()]})})},t.prototype.getWedaUserInfo=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]})})},t.prototype.updateUserBasicInfo=function(e){return u(this,void 0,void 0,function(){var t;return c(this,function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(t=r.sent())?[4,t.user.updateUserBasicInfo(e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}})})},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]})})},t.prototype.queryUser=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]})})},t.prototype.getAccessToken=function(){return u(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:e.sent(),env:this.config.env}]}})})},t.prototype.grantProviderToken=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]})})},t.prototype.patchProviderToken=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]})})},t.prototype.signInWithProvider=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.grantToken=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.grantToken(e)];case 1:return t.sent(),[2,this.createLoginState()]}})})},t.prototype.genProviderRedirectUri=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]})})},t.prototype.resetPassword=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]})})},t.prototype.deviceAuthorize=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]})})},t.prototype.sudo=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.sudo(e)]})})},t.prototype.deleteMe=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]})})},t.prototype.getProviders=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getProviders()]})})},t.prototype.loginScope=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.loginScope()]})})},t.prototype.loginGroups=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.loginGroups()]})})},t.prototype.onLoginStateChanged=function(e){var t;return u(this,void 0,void 0,function(){var r,n=this;return c(this,function(o){switch(o.label){case 0:return null===(t=this.config.eventBus)||void 0===t||t.on(h.EVENTS.LOGIN_STATE_CHANGED,function(t){return u(n,void 0,void 0,function(){var r,n,o;return c(this,function(s){switch(s.label){case 0:return(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.eventType)===h.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR?[3,2]:[4,this.getLoginState()];case 1:return n=s.sent(),[3,3];case 2:n={},s.label=3;case 3:return r=n,e.call(this,i(i({},t),r)),[2]}})})}),[4,this.getLoginState()];case 1:return r=o.sent(),e.call(this,r),[2]}})})},t.prototype.refreshTokenForce=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]})})},t.prototype.getCredentials=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getCredentials()]})})},t.prototype.setCredentials=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(e)];case 1:return t.sent(),[2]}})})},t.prototype.getProviderSubType=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]})})},t.prototype.createCaptchaData=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]})})},t.prototype.verifyCaptchaData=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]})})},t.prototype.getMiniProgramQrCode=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]})})},t.prototype.getMiniProgramQrCodeStatus=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]})})},t.prototype.modifyPassword=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]})})},t.prototype.modifyPasswordWithoutLogin=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]})})},t.prototype.getUserBehaviorLog=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.getUserBehaviorLog(e)]})})},t.prototype.signInWithUsername=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,s=e.username,a=void 0===s?"":s,l=e.bindInfo,h=void 0===l?void 0:l,d=e.loginType,f=void 0===d?"":d;return u(this,void 0,Promise,function(){var e,t,n,s,u,l,d;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:o})];case 1:if(null==(e=c.sent())?void 0:e.error_code)throw e;return t=e.verification_token,n=this.formatPhone(a),s={phone_number:n},"email"===f&&(s={email:n=a}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:t})]:[3,5];case 2:if(null==(u=c.sent())?void 0:u.error_code)throw u;return h?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==h?void 0:h.providerToken})]:[3,4];case 3:if(null==(l=c.sent())?void 0:l.error_code)throw l;c.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(i(i({},s),{verification_token:t,provider_token:null==h?void 0:h.providerId}))];case 6:if(null==(d=c.sent())?void 0:d.error_code)throw d;c.label=7;case 7:return[2,this.createLoginState()];case 8:throw c.sent();case 9:return[2]}})})},t.prototype.createLoginState=function(e,t){var r,n;return u(this,void 0,Promise,function(){var o;return c(this,function(i){switch(i.label){case 0:return[4,(o=new g({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return i.sent(),(null==t?void 0:t.userInfo)?(o.user.setLocalUserInfo(t.userInfo),[3,5]):[3,2];case 2:return(null==t?void 0:t.asyncRefreshUser)?(o.user.refresh(e),[3,5]):[3,3];case 3:return[4,o.user.refresh(e)];case 4:i.sent(),i.label=5;case 5:return null===(r=this.config.eventBus)||void 0===r||r.fire(h.EVENTS.LOGIN_STATE_CHANGED,{eventType:h.LOGIN_STATE_CHANGED_TYPE.SIGN_IN}),null===(n=this.config.eventBus)||void 0===n||n.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,o]}})})},t.prototype.setAccessKey=function(){var e,t;return u(this,void 0,void 0,function(){var r,n;return c(this,function(o){if(r="",n="",this.config.accessKey?(r=this.config.accessKey,n="accessKey"):(null===(e=this.config.auth)||void 0===e?void 0:e.secretId)&&(null===(t=this.config.auth)||void 0===t?void 0:t.secretKey)&&(r="",n=h.DEFAULT_NODE_ACCESS_SCOPE),!n)return[2];try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:r,token_type:"Bearer",scope:n,expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]})})},t.prototype.formatPhone=function(e){return!/\s+/.test(e)&&/^\+\d{1,3}\d+/.test(e)?e.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(e)?e:"+86 ".concat(e)},t.prototype.notifyListeners=function(e,t,r){this.listeners.forEach(function(n){n.forEach(function(n){try{n(e,t,r)}catch(e){console.error("Error in auth state change callback:",e)}})})},t.prototype.setupListeners=function(){var e,t=this;null===(e=this.config.eventBus)||void 0===e||e.on(h.EVENTS.AUTH_STATE_CHANGED,function(e){return u(t,void 0,void 0,function(){var t,r,n,o,i;return c(this,function(s){switch(s.label){case 0:return t=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.event,r=null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(t,n,r),[2]}})})})},t.prototype.convertToUser=function(e){var t,r,n,o,i,s;if(!e)return null;var a=(null==e?void 0:e.email)||"",u=(null==e?void 0:e.phone_number)||"",c=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:c,aud:"authenticated",role:null===(r=null===(t=e.groups)||void 0===t?void 0:t.map)||void 0===r?void 0:r.call(t,function(e){return"string"==typeof e?e:e.id}),email:a||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:u,phone_confirmed_at:u?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(n=e.loginType)||void 0===n?void 0:n.toLowerCase())||"cloudbase",providers:[(null===(o=e.loginType)||void 0===o?void 0:o.toLowerCase())||"cloudbase"]},user_metadata:{name:null==e?void 0:e.name,picture:null==e?void 0:e.picture,username:null==e?void 0:e.username,gender:null==e?void 0:e.gender,locale:null==e?void 0:e.locale,uid:e.uid,nickName:e.nickName||(null==e?void 0:e.name),avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:null!==(i=e.hasPassword)&&void 0!==i?i:"SET"===e.password,open_id:null==e?void 0:e.open_id},identities:(null===(s=null==e?void 0:e.providers)||void 0===s?void 0:s.map(function(t){return{id:t.id||"",identity_id:t.id||"",user_id:c,identity_data:{provider_id:t.id,provider_user_id:t.provider_user_id,name:t.name},provider:t.id||"cloudbase",created_at:e.created_at,updated_at:e.updated_at,last_sign_in_at:e.last_sign_in_at}}))||[],created_at:e.created_at,updated_at:e.updated_at,is_anonymous:"anonymous"===e.name}},t.prototype.validateParams=function(e,t){for(var r=0,n=Object.entries(t);r<n.length;r++){var o=n[r],i=o[0],s=o[1];if(s.required&&(void 0===(null==e?void 0:e[i])||null===(null==e?void 0:e[i])||""===(null==e?void 0:e[i])))throw new h.AuthError({message:s.message})}},t.prototype.validateAtLeastOne=function(e,t,r){if(!t.some(function(t){return t.some(function(t){return void 0!==(null==e?void 0:e[t])&&null!==(null==e?void 0:e[t])&&""!==(null==e?void 0:e[t])})}))throw new h.AuthError({message:r})},t.prototype.init=function(){var e;return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return t.sent()&&(null===(e=this.config.eventBus)||void 0===e||e.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION})),[3,3];case 2:return t.sent(),[3,3];case 3:return[2,{error:null}]}})})},s([(0,f.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(r=void 0!==h.authModels&&h.authModels.BindPhoneRequest)?r:Object]),a("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),s([(0,f.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(n=void 0!==h.authModels&&h.authModels.UnbindProviderRequest)?n:Object]),a("design:returntype","function"==typeof(d="undefined"!=typeof Promise&&Promise)?d:Object)],t.prototype,"unbindProvider",null),s([(0,f.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(v=void 0!==h.authModels&&h.authModels.BindEmailRequest)?v:Object]),a("design:returntype",void 0)],t.prototype,"bindEmail",null),s([(0,f.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(y=void 0!==h.authModels&&h.authModels.VerifyRequest)?y:Object]),a("design:returntype","function"==typeof(b="undefined"!=typeof Promise&&Promise)?b:Object)],t.prototype,"verify",null),s([(0,f.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(w=void 0!==h.authModels&&h.authModels.GetVerificationRequest)?w:Object,Object]),a("design:returntype","function"==typeof(E="undefined"!=typeof Promise&&Promise)?E:Object)],t.prototype,"getVerification",null),s([(0,f.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(S="undefined"!=typeof Promise&&Promise)?S:Object)],t.prototype,"getCurrentUser",null),s([(0,f.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(I="undefined"!=typeof Promise&&Promise)?I:Object)],t.prototype,"signInAnonymouslyInWx",null),s([(0,f.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(A="undefined"!=typeof Promise&&Promise)?A:Object)],t.prototype,"bindOpenId",null),s([(0,f.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],t.prototype,"signInWithUnionId",null),s([(0,f.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(P="undefined"!=typeof Promise&&Promise)?P:Object)],t.prototype,"signInWithSms",null),s([(0,f.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(O="undefined"!=typeof Promise&&Promise)?O:Object)],t.prototype,"signInWithEmail",null),s([(0,f.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype","function"==typeof(R="undefined"!=typeof Promise&&Promise)?R:Object)],t.prototype,"isUsernameRegistered",null),s([(0,f.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],t.prototype,"getLoginState",null),s([(0,f.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(C="undefined"!=typeof Promise&&Promise)?C:Object)],t.prototype,"getUserInfo",null),s([(0,f.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(N="undefined"!=typeof Promise&&Promise)?N:Object)],t.prototype,"getWedaUserInfo",null),s([(0,f.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(U=void 0!==h.authModels&&h.authModels.BindWithProviderRequest)?U:Object]),a("design:returntype","function"==typeof(D="undefined"!=typeof Promise&&Promise)?D:Object)],t.prototype,"bindWithProvider",null),s([(0,f.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(L="undefined"!=typeof Promise&&Promise)?L:Object)],t.prototype,"getProviderSubType",null),t}(v.AuthV1Compat);function w(e,t){var r,n,o,s,a=this,l=e.region,p=void 0===l?"ap-shanghai":l,v=e.i18n,_=e.accessKey,m=e.useWxCloud,y=(null==t?void 0:t.platform)||f.useDefaultAdapter.bind(t)(),g=y.runtime,w=y.adapter,E=t||{},S=E.env,I=E.clientId,A=E.debug,T=E.cache,P=E.app,O=E.getApiOrigin,R=(t||{}).apiOrigin;R||(R="https://".concat(S,".").concat(p,".tcb-api.tencentcloudapi.com"));var C,N={env:S,clientId:I,i18n:v,accessKey:_,useWxCloud:m,eventBus:new f.CloudbaseEventEmitter},U=new h.CloudbaseOAuth((0,d.useAuthAdapter)(i(i({},N),{apiOrigin:R,getApiOrigin:O,apiPath:(null==e?void 0:e.apiPath)||h.AUTH_API_PREFIX,storage:null==e?void 0:e.storage,baseRequest:null==e?void 0:e.baseRequest,request:null==e?void 0:e.request,anonymousSignInFunc:null==e?void 0:e.anonymousSignInFunc,captchaOptions:null==e?void 0:e.captchaOptions,wxCloud:null==e?void 0:e.wxCloud,adapter:w,onCredentialsError:(C=N.eventBus,function(e){C.fire(h.EVENTS.LOGIN_STATE_CHANGED,i(i({},e),{eventType:h.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR}))}),headers:i({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:A,auth:null===(n=null===(r=t.app)||void 0===r?void 0:r.config)||void 0===n?void 0:n.auth}))),D=new b(i(i({},N),{region:p,persistence:e.persistence,debug:A,cache:T||new f.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(S)},platformInfo:y}),runtime:g||"web",_fromApp:P,oauthInstance:U,auth:null===(s=null===(o=t.app)||void 0===o?void 0:o.config)||void 0===s?void 0:s.auth}));return U.initializeSession(function(e,t){return u(a,void 0,void 0,function(){return c(this,function(r){return e?(e.type===h.OAUTH_TYPE.SIGN_IN?t?N.eventBus.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.SIGNED_IN,info:i(i({},e),{error:t})}):e.user&&D.createLoginState({},{userInfo:e.user}):e.type===h.OAUTH_TYPE.BIND_IDENTITY&&N.eventBus.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:i(i({},e),{error:t})}),[2]):[2]})})}),{authInstance:D,oauthInstance:U}}t.Auth=b,t.generateAuthInstance=w;var E="auth";function S(e,t){for(var r=[],n=0;n<=e.length;n++)r[n]=[n];for(var o=0;o<=t.length;o++)r[0][o]=o;for(n=1;n<=e.length;n++)for(o=1;o<=t.length;o++){var i=e[n-1].toLowerCase()===t[o-1].toLowerCase()?0:1;r[n][o]=Math.min(r[n-1][o]+1,r[n][o-1]+1,r[n-1][o-1]+i)}return r[e.length][t.length]}var I={name:"auth",namespace:E,entity:function(e){var t=function(e){var t,r=this;if(this.authInstance&&!e)return this.authInstance;e=e||{region:"",persistence:"local",apiPath:h.AUTH_API_PREFIX};var n=this.platform.adapter,o=e.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var s=w(i(i({wxCloud:this.config.wxCloud,storage:this.config.storage},e),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(t=this.config.auth)||void 0===t?void 0:t.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,getApiOrigin:function(){return r.request.getBaseEndPoint(r.config.endPointMode||"CLOUD_API")},platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),a=s.authInstance,u=s.oauthInstance;return this.oauthInstance=u,this.authInstance=a,this.authInstance},r=t.call(this,e);Object.assign(t,r),Object.setPrototypeOf(t,Object.getPrototypeOf(r));var n="undefined"!=typeof Proxy?new Proxy(t,{get:function(e,t,r){var n=Reflect.get(e,t,r);if(void 0!==n||"string"!=typeof t)return n;var o=function(e,t){for(var r=null,n=1/0,o=0,i=t;o<i.length;o++){var s=i[o];if(!s.startsWith("_")&&"constructor"!==s){var a=S(e,s);a<n&&(n=a,r=s)}}return r}(t,Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)).filter(function(t){return"function"==typeof e[t]}));return o&&console.warn("[CloudBase Auth] auth.".concat(t," is not a function. Did you mean: auth.").concat(o,"() ?")),n}}):t;return this[E]=n,n}};try{cloudbase.registerComponent(I)}catch(e){}var A=r(722);Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return A.AuthErrorCategory}}),Object.defineProperty(t,"AuthErrorCode",{enumerable:!0,get:function(){return A.AuthErrorCode}}),Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return A.AuthError}}),t.registerAuth=function(e){try{e.registerComponent(I)}catch(e){console.warn(e)}}},19:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.adapterForWxMp=t.CloudbaseCache=t.CloudbaseEventEmitter=t.catchErrorsDecorator=t.COMMUNITY_SITE_URL=t.ERRORS=t.throwError=t.printWarn=void 0;var o=r(616);Object.defineProperty(t,"printWarn",{enumerable:!0,get:function(){return o.printWarn}}),Object.defineProperty(t,"throwError",{enumerable:!0,get:function(){return o.throwError}});var i=r(794);Object.defineProperty(t,"ERRORS",{enumerable:!0,get:function(){return i.ERRORS}}),Object.defineProperty(t,"COMMUNITY_SITE_URL",{enumerable:!0,get:function(){return i.COMMUNITY_SITE_URL}});var s=r(141);Object.defineProperty(t,"catchErrorsDecorator",{enumerable:!0,get:function(){return s.catchErrorsDecorator}});var a=r(689);Object.defineProperty(t,"CloudbaseEventEmitter",{enumerable:!0,get:function(){return a.CloudbaseEventEmitter}});var u=r(197);Object.defineProperty(t,"CloudbaseCache",{enumerable:!0,get:function(){return u.CloudbaseCache}});var c=r(882);Object.defineProperty(t,"adapterForWxMp",{enumerable:!0,get:function(){return n(c).default}});var l=r(182);Object.defineProperty(t,"useDefaultAdapter",{enumerable:!0,get:function(){return l.useDefaultAdapter}})},266:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.removeUrlParams=t.addUrlSearch=t.removeBrowserSession=t.getBrowserSession=t.saveToBrowserSession=void 0,t.saveToBrowserSession=function(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch(e){console.error("Failed to save to browser session:",e)}},t.getBrowserSession=function(e){try{return JSON.parse(sessionStorage.getItem(e))}catch(e){return console.error("Failed to get browser session:",e),null}},t.removeBrowserSession=function(e){try{return sessionStorage.removeItem(e),!0}catch(e){return console.error("Failed to remove browser session:",e),null}},t.addUrlSearch=function(e,t){if(void 0!==e){var r=new URL(window.location.href);return r.search=e,r.hash=t||r.hash,window.history.replaceState({},"",r.href),r.href}},t.removeUrlParams=function(e){if("undefined"!=typeof window)try{var t=new URL(window.location.href);e.forEach(function(e){t.searchParams.delete(e)}),window.history.replaceState({},"",t.href)}catch(e){console.error("Failed to remove URL params:",e)}}},916:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.applyUserV1Compat=t.AuthV1Compat=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=void 0;var s=r(722),a=r(19),u=function(){function e(e){}return e.prototype.signInWithRedirect=function(){throw new Error("[v1 兼容] WeixinAuthProvider.signInWithRedirect() 在当前版本中无法实现。 建议使用 auth.signInWithOAuth({ provider: 'providerId' }) 替代。")},e.prototype.getRedirectResult=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getRedirectResult() 在当前版本中无法实现。 建议使用 auth.verifyOAuth({ code, state, provider }) 替代。")})})},e.prototype.getLinkRedirectResult=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getLinkRedirectResult() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")})})},e}();t.WeixinAuthProvider=u;var c=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.authInstance.signInWithCustomTicket(function(){return Promise.resolve(e)})];case 1:return t.sent(),[2]}})})},e}();t.CustomAuthProvider=c;var l=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.authInstance.signInAnonymously({})];case 1:return e.sent(),[2]}})})},e}();t.AnonymousAuthProvider=l;var h=function(){function e(){}return e.prototype.weixinAuthProvider=function(e){return new u({authInstance:this,appid:e.appid,scope:e.scope})},e.prototype.customAuthProvider=function(){return new c({authInstance:this})},e.prototype.anonymousAuthProvider=function(){return new l({authInstance:this})},e.prototype.signUpWithEmailAndPassword=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signUp({email:e,password:t})];case 1:return[2,r.sent()]}})})},e.prototype.signInWithEmailAndPassword=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}})})},e.prototype.sendPasswordResetEmail=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),[4,this.getVerification({email:e})];case 1:return t.sent(),[2]}})})},e.prototype.signInWithUsernameAndPassword=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"username must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}})})},e.prototype.sendPhoneCode=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),t=this.formatPhone(e),[4,this.getVerification({phone_number:t})];case 1:return r.sent(),[2,!0]}})})},e.prototype.signUpWithPhoneCode=function(e,t,r){return o(this,void 0,Promise,function(){var o;return i(this,function(i){switch(i.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),o=this.formatPhone(e),[4,this.signUp(n({phone_number:o,verification_code:t},r?{password:r}:{}))];case 1:return i.sent(),[2,this.createLoginState()]}})})},e.prototype.signInWithPhoneCodeOrPassword=function(e){return o(this,void 0,Promise,function(){var t,r,n,o;return i(this,function(i){switch(i.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),o=this.formatPhone(t),n?[4,this.signIn({username:o,password:n})]:[3,2];case 1:return i.sent(),[3,5];case 2:return r?[4,this.signIn({username:o,verification_token:r})]:[3,4];case 3:return i.sent(),[3,5];case 4:(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode or password must be provided"),i.label=5;case 5:return[2,this.createLoginState()]}})})},e.prototype.forceResetPwdByPhoneCode=function(e){return o(this,void 0,Promise,function(){var t,r,n,o;return i(this,function(i){switch(i.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof r&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),"string"!=typeof n&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),o=this.formatPhone(t),[4,this.resetPassword({phone_number:o,new_password:n,verification_token:r})];case 1:return i.sent(),[4,this.signIn({username:o,password:n})];case 2:return i.sent(),[2,this.createLoginState()]}})})},e.prototype.shouldRefreshAccessToken=function(e){throw new Error("[v1 兼容] shouldRefreshAccessToken() 在当前版本中无法实现。 建议使用 auth.onAuthStateChange(callback) 来监听 TOKEN_REFRESHED 事件替代。")},e.prototype.onLoginStateExpired=function(e){var t=this;this.onLoginStateChanged(function(r){(null==r?void 0:r.eventType)===s.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR&&e.call(t)})},e.prototype.onAccessTokenRefreshed=function(e){var t=this;this.onAuthStateChange(function(r){r===s.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED&&e.call(t)})},e.prototype.onAnonymousConverted=function(e){var t=this;this.onAuthStateChange(function(r){r===s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&e.call(t)})},e.prototype.onLoginTypeChanged=function(e){var t=this;this.onAuthStateChange(function(r){r!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&r!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT||e.call(t)})},e}();t.AuthV1Compat=h,t.applyUserV1Compat=function(e){e.prototype.linkWithTicket=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.linkWithTicket() 在当前版本中无法实现。 建议使用 auth.signInWithCustomTicket(() => Promise.resolve(ticket)) 替代。")})})},e.prototype.linkWithRedirect=function(e){throw new Error("[v1 兼容] User.linkWithRedirect() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")},e.prototype.updateEmail=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"newEmail must be a string"),[4,this.updateUserBasicInfo({email:e})];case 1:return t.sent(),[2]}})})},e.prototype.linkWithPhoneNumber=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.linkWithPhoneNumber() 在当前版本中无法实现。 建议使用 auth.bindPhoneNumber({ phone_number, verification_token, sudo_token }) 替代。")})})},e.prototype.updatePhoneNumber=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.updatePhoneNumber() 在当前版本中无法实现。 建议使用 auth.updateUser({ phone: newPhoneNumber }) 替代。")})})},e.prototype.unlink=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.unlink() 在当前版本中无法实现。 建议使用 auth.unlinkIdentity({ provider: loginType }) 替代。")})})}}},304:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=void 0;var n=r(895);t.registerAuth=n.registerAuth;try{window.registerAuth=t.registerAuth}catch(e){}},413:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Auth=void 0;var u=r(949),c=r(257),l=r(462),h=r(631),d=a(r(639)),f=r(308);function p(e,t){var n;return o(this,void 0,void 0,function(){var s,a=this;return i(this,function(u){s=function(){return o(a,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,1,,6]),[2,r(814)];case 1:e.sent(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,Promise.resolve().then(r.t.bind(r,814,23))];case 3:return[2,e.sent()];case 4:return e.sent(),[2];case 5:return[3,6];case 6:return[2]}})})};try{if(((null===(n=null==t?void 0:t.root)||void 0===n?void 0:n.globalThis)||globalThis).IS_MP_BUILD)return[2]}catch(t){if(e)return[2,s()]}return[2]})})}var v=function(){function e(e){var t=e.request,r=e.credentialsClient;if(!r){var o={apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,storage:e.storage,env:e.env,baseRequest:e.baseRequest,anonymousSignInFunc:e.anonymousSignInFunc,wxCloud:e.wxCloud,onCredentialsError:e.onCredentialsError,headers:e.headers||{},i18n:e.i18n,debug:e.debug};r=new c.OAuth2Client(o)}if(!t){var i=r.request.bind(r),s=new l.Captcha(n({env:e.env,clientId:e.clientId,request:i,storage:e.storage,adapter:e.adapter,oauthInstance:this},e.captchaOptions));t=s.request.bind(s)}this.config={env:e.env,apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,request:t,credentialsClient:r,storage:e.storage||c.defaultStorage,adapter:e.adapter}}return e.parseParamsToSearch=function(e){return Object.keys(e).forEach(function(t){e[t]||delete e[t]}),new d.default(e).toString()},e.prototype.getParamsByVersion=function(e,t){var r,n=(0,h.deepClone)(e),o=(null===(r={v2:u.ApiUrlsV2}[null==n?void 0:n.version])||void 0===r?void 0:r[t])||u.ApiUrls[t];return n&&delete n.version,{params:n,url:o}},e.prototype.signIn=function(e){return o(this,void 0,Promise,function(){var t,r,o,s;return i(this,function(i){switch(i.label){case 0:return t=e.version||"v1",(r=this.getParamsByVersion(e,"AUTH_SIGN_IN_URL")).params.query&&delete r.params.query,[4,this.getEncryptParams(r.params)];case 1:return o=i.sent(),[4,this.config.request(r.url,{method:"POST",body:o})];case 2:return s=i.sent(),[4,this.config.credentialsClient.setCredentials(n(n({},s),{version:t}))];case 3:return i.sent(),[2,Promise.resolve(s)]}})})},e.prototype.signInAnonymously=function(e,t){return void 0===e&&(e={}),void 0===t&&(t=!1),o(this,void 0,Promise,function(){var r;return i(this,function(n){switch(n.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:e,useWxCloud:t})];case 1:return r=n.sent(),[4,this.config.credentialsClient.setCredentials(r)];case 2:return n.sent(),[2,Promise.resolve(r)]}})})},e.prototype.signUp=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_UP_URL,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}})})},e.prototype.signOut=function(e){return o(this,void 0,Promise,function(){var t,r,n,o;return i(this,function(i){switch(i.label){case 0:if(t={},!e)return[3,6];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.config.request(u.ApiUrls.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:e})];case 2:return t=i.sent(),[3,4];case 3:return(r=i.sent()).error!==u.ErrorType.UNAUTHENTICATED&&console.log("sign_out_error",r),[3,4];case 4:return[4,this.config.credentialsClient.setCredentials()];case 5:return i.sent(),[2,t];case 6:return[4,this.config.credentialsClient.getAccessToken()];case 7:return n=i.sent(),[4,this.config.request(u.ApiUrls.AUTH_REVOKE_URL,{method:"POST",body:{token:n}})];case 8:return o=i.sent(),[4,this.config.credentialsClient.setCredentials()];case 9:return i.sent(),[2,Promise.resolve(o)]}})})},e.prototype.revokeAllDevices=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})];case 1:return e.sent(),[2]}})})},e.prototype.revokeDevice=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.config.request(u.ApiUrls.AUTHORIZED_DEVICES_DELETE_URL+e.device_id,{method:"DELETE",withCredentials:!0})];case 1:return t.sent(),[2]}})})},e.prototype.getVerification=function(e,t){return o(this,void 0,Promise,function(){var r,n;return i(this,function(o){switch(o.label){case 0:return r=!1,"CUR_USER"!==e.target?[3,1]:(r=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:o.sent()&&(r=!0),o.label=3;case 3:return(n=(0,h.deepClone)(e)).phone_number&&!/^\+\d{1,3}\s+\d+/.test(n.phone_number)&&(n.phone_number="+86 ".concat(n.phone_number)),[2,this.config.request(u.ApiUrls.VERIFICATION_URL,{method:"POST",body:n,withCaptcha:(null==t?void 0:t.withCaptcha)||!1,withCredentials:r})]}})})},e.prototype.verify=function(e){return o(this,void 0,Promise,function(){var t,r;return i(this,function(o){switch(o.label){case 0:return t=this.getParamsByVersion(e,"VERIFY_URL"),[4,this.config.request(t.url,{method:"POST",body:t.params})];case 1:return r=o.sent(),"v2"!==(null==e?void 0:e.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(n(n({},r),{version:"v2"}))];case 2:o.sent(),o.label=3;case 3:return[2,r]}})})},e.prototype.genProviderRedirectUri=function(t){return o(this,void 0,Promise,function(){var r,n,o,a,c;return i(this,function(i){return r=t.provider_redirect_uri,n=t.other_params,o=void 0===n?{}:n,a=s(t,["provider_redirect_uri","other_params"]),r&&!a.redirect_uri&&(a.redirect_uri=r),c="".concat(u.ApiUrls.PROVIDER_URI_URL,"?").concat(e.parseParamsToSearch(a)),Object.keys(o).forEach(function(e){var t=o[e];("sign_out_uri"!==e||(null==t?void 0:t.length)>0)&&(c+="&other_params[".concat(e,"]=").concat(encodeURIComponent(t)))}),[2,this.config.request(c,{method:"GET"})]})})},e.prototype.grantProviderToken=function(e,t){return void 0===t&&(t=!1),o(this,void 0,Promise,function(){return i(this,function(r){return[2,this.config.request(u.ApiUrls.PROVIDER_TOKEN_URL,{method:"POST",body:e,useWxCloud:t})]})})},e.prototype.patchProviderToken=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})]})})},e.prototype.signInWithProvider=function(e,t){return void 0===t&&(t=!1),o(this,void 0,Promise,function(){var r,o;return i(this,function(i){switch(i.label){case 0:return r=this.getParamsByVersion(e,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:t})];case 1:return o=i.sent(),[4,this.config.credentialsClient.setCredentials(n(n({},o),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return i.sent(),[2,Promise.resolve(o)]}})})},e.prototype.toBindIdentity=function(e){var t,r;return o(this,void 0,void 0,function(){var n,o,s,a;return i(this,function(i){switch(i.label){case 0:return(o=e.credentials)?[3,2]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 1:o=i.sent(),i.label=2;case 2:n=o,i.label=3;case 3:return i.trys.push([3,5,,6]),[4,this.bindWithProvider({provider_token:e.provider_token},n)];case 4:return i.sent(),s={data:{type:u.OAUTH_TYPE.BIND_IDENTITY,provider:e.provider},error:null},[3,6];case 5:return a=i.sent(),s={data:{type:u.OAUTH_TYPE.BIND_IDENTITY},error:new f.AuthError(a)},[3,6];case 6:return e.fireEvent&&(null===(r=null===(t=this.config.eventBus)||void 0===t?void 0:t.fire)||void 0===r||r.call(t,u.EVENTS.AUTH_STATE_CHANGED,{event:u.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:s})),[2,s]}})})},e.prototype.getInitialSession=function(){return o(this,void 0,Promise,function(){var e,t,r,o,s,a,c,l,h,d,p,v,_,m,y;return i(this,function(i){switch(i.label){case 0:e={},i.label=1;case 1:if(i.trys.push([1,12,,13]),"undefined"==typeof window||"undefined"==typeof document)return[2,{data:null,error:null}];if(t=new URLSearchParams(null===location||void 0===location?void 0:location.search),r=t.get("code"),o=t.get("state"),!r||!o)return[2,{data:null,error:null}];s=null;try{s=JSON.parse(sessionStorage.getItem(o)||"null")}catch(e){}return e={type:null==s?void 0:s.type},a=t.get("error"),c=t.get("error_description"),a||c?[2,{data:e,error:new f.AuthError({message:c||a||"Unknown error from OAuth provider"})}]:(l=(null==s?void 0:s.provider)||t.get("provider"))?(h=location.origin+location.pathname,[4,this.grantProviderToken({provider_id:l,provider_redirect_uri:h,provider_code:r})]):[2,{data:e,error:new f.AuthError({message:"Provider is required for OAuth verification"})}];case 2:return d=i.sent().provider_token,p=void 0,v=null,_=void 0,s.type!==u.OAUTH_TYPE.BIND_IDENTITY?[3,5]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 3:return p=i.sent(),[4,this.toBindIdentity({provider:l,provider_token:d,credentials:p})];case 4:return _=i.sent(),[3,11];case 5:return s.type!==u.OAUTH_TYPE.SIGN_IN?[3,11]:(_=this.getParamsByVersion({provider:l},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(_.url,{method:"POST",body:{provider_token:d}})]);case 6:p=i.sent(),i.label=7;case 7:return i.trys.push([7,9,,10]),[4,this.getUserInfo({credentials:p})];case 8:return v=i.sent(),[3,10];case 9:return m=i.sent(),console.error("get user info error",m),[3,10];case 10:_={data:n(n({},e),{session:p,user:v}),error:null},i.label=11;case 11:t.delete("code"),t.delete("state"),t.delete("provider"),this.restoreUrlState(void 0===(null==s?void 0:s.search)?"?".concat(t.toString()):s.search,(null==s?void 0:s.hash)||location.hash);try{sessionStorage.removeItem(o)}catch(e){}return[2,_];case 12:return y=i.sent(),[2,{data:e,error:new f.AuthError(y)}];case 13:return[2]}})})},e.prototype.signInCustom=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}})})},e.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),o(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}})})},e.prototype.bindWithProvider=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(r){return[2,this.config.request(u.ApiUrls.PROVIDER_BIND_URL,{method:"POST",body:e,withCredentials:!0,getCredentials:t?function(){return t}:void 0})]})})},e.prototype.getUserProfile=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.getUserInfo(e)]})})},e.prototype.getUserInfo=function(e){var t,r,n;return void 0===e&&(e={}),o(this,void 0,Promise,function(){var o,s,a,u,c;return i(this,function(i){switch(i.label){case 0:return o=this.getParamsByVersion(e,"USER_ME_URL"),(null===(t=o.params)||void 0===t?void 0:t.query)&&(s=new d.default(o.params.query),o.url+="?".concat(s.toString())),[4,this.config.request(o.url,{method:"GET",withCredentials:!0,getCredentials:e.credentials?function(){return e.credentials}:void 0})];case 1:if((a=i.sent()).sub&&(a.uid=a.sub),null===(r=a.providers)||void 0===r?void 0:r.length)try{"undefined"!=typeof wx&&wx.getAccountInfoSync&&(u=null===(n=wx.getAccountInfoSync().miniProgram)||void 0===n?void 0:n.appId,(null==(c=a.providers.find(function(e){return e.id===u}))?void 0:c.provider_user_id)&&(a.open_id=c.provider_user_id))}catch(e){}return[2,a]}})})},e.prototype.getWedaUserInfo=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.config.request(u.ApiUrls.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,e.sent()]}})})},e.prototype.deleteMe=function(t){return o(this,void 0,Promise,function(){var r,n;return i(this,function(o){return r=this.getParamsByVersion(t,"USER_ME_URL"),n="".concat(r.url,"?").concat(e.parseParamsToSearch(r.params)),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]})})},e.prototype.hasLoginState=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}})})},e.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},e.prototype.getLoginState=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.credentialsClient.getCredentialsAsync()]})})},e.prototype.transByProvider=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})]})})},e.prototype.grantToken=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){return t=this.getParamsByVersion(e,"AUTH_TOKEN_URL"),[2,this.config.request(t.url,{method:"POST",body:t.params})]})})},e.prototype.getProviders=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.request(u.ApiUrls.PROVIDER_LIST,{method:"GET",withCredentials:!0})]})})},e.prototype.unbindProvider=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})]})})},e.prototype.checkPassword=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.editContact=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})]})})},e.prototype.setPassword=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})]})})},e.prototype.updatePasswordByOld=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return[4,this.sudo({password:e.old_password})];case 1:return t=r.sent(),[2,this.setPassword({sudo_token:t.sudo_token,new_password:e.new_password})]}})})},e.prototype.sudo=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.SUDO_URL),{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.sendVerificationCodeToCurrentUser=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return e.target="CUR_USER",[2,this.config.request(u.ApiUrls.VERIFICATION_URL,{method:"POST",body:e,withCredentials:!0,withCaptcha:!0})]})})},e.prototype.changeBoundProvider=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.PROVIDER_LIST,"/").concat(e.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:e.trans_token},withCredentials:!0})]})})},e.prototype.setUserProfile=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})]})})},e.prototype.updateUserBasicInfo=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.queryUserProfile=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){return t=new d.default(e),[2,this.config.request("".concat(u.ApiUrls.USER_QUERY_URL,"?").concat(t.toString()),{method:"GET",withCredentials:!0})]})})},e.prototype.setCustomSignFunc=function(e){this.getCustomSignTicketFn=e},e.prototype.signInWithCustomTicket=function(){return o(this,void 0,Promise,function(){var e,t;return i(this,function(r){switch(r.label){case 0:return(e=this.getCustomSignTicketFn)?[4,e()]:[2,Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"})];case 1:return t=r.sent(),[2,this.signInCustom({provider_id:"custom",ticket:t})]}})})},e.prototype.resetPassword=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.AUTH_RESET_PASSWORD,{method:"POST",body:e})]})})},e.prototype.authorize=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.authorizeDevice=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.deviceAuthorize=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.AUTH_GET_DEVICE_CODE,{method:"POST",body:e})]})})},e.prototype.authorizeInfo=function(t){return o(this,void 0,Promise,function(){var r,n,o;return i(this,function(i){switch(i.label){case 0:return r="".concat(u.ApiUrls.AUTHORIZE_INFO_URL,"?").concat(e.parseParamsToSearch(t)),n=!0,o=!1,[4,this.hasLoginState()];case 1:return i.sent()&&(o=!0,n=!1),[2,this.config.request(r,{method:"GET",withBasicAuth:n,withCredentials:o})]}})})},e.prototype.checkUsername=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})]})})},e.prototype.checkIfUserExist=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){return t=new d.default(e),[2,this.config.request("".concat(u.ApiUrls.CHECK_IF_USER_EXIST,"?").concat(t.toString()),{method:"GET"})]})})},e.prototype.loginScope=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.credentialsClient.getScope()]})})},e.prototype.loginGroups=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.credentialsClient.getGroups()]})})},e.prototype.refreshTokenForce=function(e){return o(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return t=r.sent(),[4,this.config.credentialsClient.refreshToken(n(n({},t),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return[2,r.sent()]}})})},e.prototype.getCredentials=function(){return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.config.credentialsClient.getCredentials()]})})},e.prototype.getPublicKey=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.request(u.ApiUrlsV2.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]})})},e.prototype.getEncryptParams=function(e){return o(this,void 0,Promise,function(){var t,r,n,o,s,a;return i(this,function(i){switch(i.label){case 0:return t=e.isEncrypt,delete e.isEncrypt,r=(0,h.deepClone)(e),[4,p(t,this.config.adapter)];case 1:if(!(n=i.sent()))return[2,e];o="",s="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(a=i.sent(),o=a.public_key,s=a.public_key_thumbprint,!o||!s)throw a;return[3,5];case 4:throw i.sent();case 5:return[2,{params:n.getEncryptInfo({publicKey:o,payload:r}),public_key_thumbprint:s}]}})})},e.prototype.getProviderSubType=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.request(u.ApiUrls.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})]})})},e.prototype.verifyCaptchaData=function(e){var t=e.token,r=e.key;return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.config.request(u.ApiUrls.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:r},withCredentials:!1})]})})},e.prototype.createCaptchaData=function(e){var t=e.state,r=e.redirect_uri,n=void 0===r?void 0:r;return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.config.request(u.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:n},withCredentials:!1})]})})},e.prototype.getMiniProgramCode=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.GET_MINIPROGRAM_QRCODE,{method:"POST",body:e})]})})},e.prototype.getMiniProgramQrCodeStatus=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:e})]})})},e.prototype.getUserBehaviorLog=function(e){return o(this,void 0,Promise,function(){var t,r;return i(this,function(n){return t={LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"},r="".concat(u.ApiUrls.GET_USER_BEHAVIOR_LOG,"?").concat(t[e.type],"&limit=").concat(e.limit).concat(e.page_token?"&page_token=".concat(e.page_token):""),[2,this.config.request(r,{method:"GET",withCredentials:!0})]})})},e.prototype.modifyPassword=function(e){return o(this,void 0,Promise,function(){var t,r,n,o,s,a;return i(this,function(i){switch(i.label){case 0:return t="",r="",[4,p(!0,this.config.adapter)];case 1:if(!(n=i.sent()))throw new Error("do not support encrypt, a encrypt util required.");i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=i.sent(),t=o.public_key,r=o.public_key_thumbprint,!t||!r)throw o;return[3,5];case 4:throw i.sent();case 5:return s=e.password?n.getEncryptInfo({publicKey:t,payload:e.password}):"",a=n.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(u.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:e.user_id,encrypt_password:s,encrypt_new_password:a,public_key_thumbprint:r}})]}})})},e.prototype.modifyPasswordWithoutLogin=function(e){return o(this,void 0,Promise,function(){var t,r,n,o,s,a;return i(this,function(i){switch(i.label){case 0:return t="",r="",[4,p(!0,this.config.adapter)];case 1:if(!(n=i.sent()))throw new Error("do not support encrypt, a encrypt util required.");i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=i.sent(),t=o.public_key,r=o.public_key_thumbprint,!t||!r)throw o;return[3,5];case 4:throw i.sent();case 5:return s=e.password?n.getEncryptInfo({publicKey:t,payload:e.password}):"",a=n.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(u.ApiUrlsV2.AUTH_RESET_PASSWORD,{method:"POST",body:{username:e.username,password:s,new_password:a,public_key_thumbprint:r}})]}})})},e.prototype.restoreUrlState=function(e,t){if(void 0!==e)try{var r=new URL(window.location.href);r.search=e,r.hash=t||"",window.history.replaceState(null,"",r.toString()),window.location.replace(r.toString())}catch(e){}},e}();t.Auth=v},308:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.AuthError=t.AuthErrorCategory=void 0;var i,s=r(949);!function(e){e.PROVIDER_NOT_ENABLED="PROVIDER_NOT_ENABLED",e.INVALID_CREDENTIALS="INVALID_CREDENTIALS",e.USER_NOT_FOUND="USER_NOT_FOUND",e.USER_STATUS_ABNORMAL="USER_STATUS_ABNORMAL",e.SERVICE_ERROR="SERVICE_ERROR",e.INVALID_PARAMS="INVALID_PARAMS",e.AUTH_METHOD_MISMATCH="AUTH_METHOD_MISMATCH",e.RATE_LIMITED="RATE_LIMITED",e.CAPTCHA_REQUIRED="CAPTCHA_REQUIRED",e.CAPTCHA_INVALID="CAPTCHA_INVALID",e.MFA_REQUIRED="MFA_REQUIRED",e.PRECONDITION_FAILED="PRECONDITION_FAILED",e.VERIFICATION_FAILED="VERIFICATION_FAILED",e.UNKNOWN="UNKNOWN"}(i=t.AuthErrorCategory||(t.AuthErrorCategory={}));var a="https://tcb.cloud.tencent.com/dev?envId=#/identity/login-manage",u="https://docs.cloudbase.net/api-reference/webv3-next/initialization",c=function(e){function t(t,r){var n,o=this,c=t.error_description||t.message;return(o=e.call(this,c)||this).__isAuthError=!0,o.name="AuthError",o.status=t.error,o.code=String(t.error||t.error_code||"unknown").toLowerCase(),o.errorCode="number"==typeof t.error_code?t.error_code:"string"==typeof t.error_code&&parseInt(t.error_code,10)||void 0,o.requestId=t.requestId,o.category=function(e,t,r){if(!e&&!t&&!r)return i.UNKNOWN;try{var n=(e||"").toLowerCase(),o="string"==typeof r?parseInt(r,10):r;return o===s.AuthErrorCode.CAPTCHA_REQUIRED||t===s.ErrorType.CAPTCHA_REQUIRED?i.CAPTCHA_REQUIRED:o===s.AuthErrorCode.CAPTCHA_INVALID||t===s.ErrorType.CAPTCHA_INVALID?i.CAPTCHA_INVALID:o===s.AuthErrorCode.MFA_PHONE_REQUIRED||t===s.ErrorType.MFA_PHONE_REQUIRED?i.MFA_REQUIRED:o===s.AuthErrorCode.LOGIN_TYPE_DISABLED||t===s.ErrorType.LOGIN_TYPE_DISABLED?i.PROVIDER_NOT_ENABLED:o===s.AuthErrorCode.RESOURCE_EXHAUSTED||t===s.ErrorType.RESOURCE_EXHAUSTED?i.RATE_LIMITED:o===s.AuthErrorCode.INTERNAL||o===s.AuthErrorCode.UNAVAILABLE||o===s.AuthErrorCode.UNIMPLEMENTED||o===s.AuthErrorCode.ABORTED?i.SERVICE_ERROR:o===s.AuthErrorCode.NOT_FOUND?i.USER_NOT_FOUND:o===s.AuthErrorCode.UNAUTHENTICATED?i.INVALID_CREDENTIALS:o===s.AuthErrorCode.INVALID_ARGUMENT&&(n.includes("验证码")||n.includes("verification")||n.includes("verification_code")||n.includes("verification_id")||n.includes("does not match")||n.includes("token expired")||n.includes("token error")||n.includes("过期"))?i.VERIFICATION_FAILED:t===s.ErrorType.PROVIDER_NOT_ENABLED||t===s.ErrorType.LOGIN_METHOD_DISABLED||n.includes("身份源")||n.includes("开启")||n.includes("identity provider")||n.includes("provider not enabled")||n.includes("login method")||n.includes("登录方式")||n.includes("not enabled")||n.includes("未开启")||n.includes("未启用")||n.includes("请联系开发者")||n.includes("anonymous login is not enabled")||n.includes("匿名登录未开启")?i.PROVIDER_NOT_ENABLED:t===s.ErrorType.FAILED_PRECONDITION||o===s.AuthErrorCode.FAILED_PRECONDITION&&!n.includes("请联系开发者")?n.includes("不存在")||n.includes("not found")||n.includes("未注册")?i.USER_NOT_FOUND:i.PRECONDITION_FAILED:t===s.ErrorType.INVALID_PASSWORD||t===s.ErrorType.INVALID_GRANT||t===s.ErrorType.INVALID_VERIFICATION_CODE||t===s.ErrorType.INVALID_USERNAME_OR_PASSWORD||t===s.ErrorType.INVALID_CREDENTIALS||t===s.ErrorType.WRONG_PASSWORD||t===s.ErrorType.UNAUTHENTICATED||t===s.ErrorType.INVALID_TWO_FACTOR||t===s.ErrorType.INVALID_TWO_FACTOR_RECOVERY||t===s.ErrorType.PASSWORD_NOT_SET||n.includes("密码不正确")||n.includes("password")||n.includes("invalid_password")||n.includes("凭据")||n.includes("credentials")||n.includes("验证码")||n.includes("verification")||n.includes("invalid_verification_code")||n.includes("invalid_username_or_password")||n.includes("username or password")||n.includes("用户名或密码")||n.includes("wrong password")||n.includes("incorrect password")?i.INVALID_CREDENTIALS:t===s.ErrorType.NOT_FOUND||t===s.ErrorType.USER_NOT_FOUND||n.includes("用户不存在")||n.includes("not found")||n.includes("user not found")||n.includes("no such user")||n.includes("user does not exist")?i.USER_NOT_FOUND:t===s.ErrorType.USER_BLOCKED||t===s.ErrorType.USER_PENDING||t===s.ErrorType.UNDER_REVIEW||t===s.ErrorType.INVALID_STATUS||n.includes("被封禁")||n.includes("blocked")||n.includes("pending")||n.includes("审核")||n.includes("review")||n.includes("locked")||n.includes("已锁定")?i.USER_STATUS_ABNORMAL:t===s.ErrorType.SERVER_ERROR||t===s.ErrorType.UNAVAILABLE||t===s.ErrorType.TEMPORARILY_UNAVAILABLE||t===s.ErrorType.INTERNAL||t===s.ErrorType.UNREACHABLE||t===s.ErrorType.DEADLINE_EXCEEDED||t===s.ErrorType.DATA_LOSS||t===s.ErrorType.ABORTED||n.includes("network")||n.includes("timeout")||n.includes("timed out")||n.includes("超时")||n.includes("smtp is not set")||n.includes("sms sender does not config")?i.SERVICE_ERROR:t===s.ErrorType.INVALID_ARGUMENT||t===s.ErrorType.INVALID_REQUEST||t===s.ErrorType.INVALID_SCOPE||t===s.ErrorType.INVALID_REQUEST_URI||t===s.ErrorType.INVALID_REQUEST_OBJECT||o===s.AuthErrorCode.INVALID_ARGUMENT?i.INVALID_PARAMS:t===s.ErrorType.PERMISSION_DENIED||t===s.ErrorType.ACCESS_DENIED||t===s.ErrorType.UNAUTHORIZED_CLIENT?i.PROVIDER_NOT_ENABLED:i.UNKNOWN}catch(e){return t}}(c,o.status,o.errorCode),o.helpMessage=function(e,t){var r=(null==t?void 0:t.method)||"signIn",n={signInWithPassword:"「用户名密码登录」",signInAnonymously:"「匿名登录」",signInWithOtp:"「短信验证码登录」或「邮箱验证码登录」",signUp:"「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"对应的第三方身份源",signInWithIdToken:"对应的第三方身份源",signInWithOpenId:"「微信小程序 OpenID 登录」",signInWithPhoneAuth:"「微信小程序手机号授权登录」",signInWithCustomTicket:"「自定义登录」",getVerification:"「短信验证码登录」或「邮箱验证码登录」",verify:"「短信验证码登录」或「邮箱验证码登录」",verifyOtp:"「短信验证码登录」或「邮箱验证码登录」",resetPasswordForEmail:"「邮箱验证码登录」",reauthenticate:"「短信验证码登录」或「邮箱验证码登录」"}[r]||"对应的登录方式";switch(e){case i.PROVIDER_NOT_ENABLED:return"[CloudBase Auth] 登录方式未开启\n\n"+" 当前调用的 ".concat(r,"() 所需的登录方式尚未在云开发控制台启用。\n")+" 需要开启的登录方式:".concat(n,"\n")+"\n 请按以下步骤开启:\n"+" 1. 打开云开发控制台:".concat(a,"\n")+" 2. 选择对应的云开发环境\n 3. 进入「登录授权」页面,在「登录方式」或「身份源列表」中开启所需的登录方式\n\n 各登录方法与所需登录方式的对应关系:\n - signInWithPassword → 「用户名密码登录」\n - signInAnonymously → 「匿名登录」\n - signInWithOtp/signUp → 「短信验证码登录」或「邮箱验证码登录」\n - signInWithOAuth/signInWithIdToken → 对应的第三方身份源\n\n 如使用 CLI/MCP 工具,可通过 auth 工具查询和配置身份源状态。\n"+" 更多帮助请参考文档:".concat(u);case i.INVALID_CREDENTIALS:return"[CloudBase Auth] 凭据验证失败\n\n"+" 调用 ".concat(r,"() 时凭据校验未通过。\n")+"\n 请按优先级逐项排查:\n 1. 确认用户名/邮箱/手机号是否拼写正确、格式完整\n 2. 确认密码是否正确(注意大小写、特殊字符、前后空格)\n 3. 确认用户账号确实存在(可通过 auth.isUsernameRegistered() 检查)\n 4. 确认凭据参数来源可靠(环境变量、配置文件中的值是否已正确设置)\n 5. 如使用加密登录(is_encrypt: true),请确认公钥版本正确\n\n 如忘记密码,可通过 auth.resetPasswordForEmail() 重置密码。\n\n 提示:如果是 AI agent / 自动化测试场景,请确认 ENV_ID、USERNAME、PASSWORD\n 等环境变量已正确传入,且对应用户已在目标环境中注册。";case i.USER_NOT_FOUND:return"[CloudBase Auth] 用户不存在\n\n 请检查以下项目:\n 1. 确认用户名/邮箱/手机号是否正确\n 2. 确认是在正确的云开发环境(envId)下操作\n 3. 如果是新用户,请先通过 auth.signUp() 注册\n"+" 4. 也可在云开发控制台手动创建用户:".concat(a,"\n")+"\n 提示:不同环境(开发/测试/生产)的用户库是隔离的,请确认 envId 正确。";case i.USER_STATUS_ABNORMAL:return"[CloudBase Auth] 用户状态异常\n\n 当前用户账号可能处于以下状态之一:\n - 账号已被封禁\n - 账号正在审核中\n - 账号已被锁定(多次密码错误)\n\n"+" 请联系管理员在云开发控制台检查用户状态:".concat(a);case i.SERVICE_ERROR:return"[CloudBase Auth] 服务异常\n\n 请检查以下项目:\n 1. 网络连接是否正常\n 2. 云开发环境是否正常运行\n 3. 稍后重试,如持续失败请联系技术支持\n\n 提示:如果是超时错误,请检查网络环境和请求频率。\n 常见服务端错误:smtp 未配置、短信服务未配置、wedaapis 未设置等。";case i.INVALID_PARAMS:return"[CloudBase Auth] 参数错误\n\n 请检查传入的参数是否符合要求:\n - 不能同时输入手机号和邮箱\n - 手机号格式需正确(如 +86 开头)\n - 必须提供手机号或邮箱\n\n"+" 参考 API 文档确认各参数的格式和约束:".concat(u);case i.AUTH_METHOD_MISMATCH:return"[CloudBase Auth] 登录方式不匹配\n\n"+" 调用 ".concat(r,"() 时遇到错误,可能原因:\n")+" - 匿名登录失败后尝试了用户名密码登录,但凭据不正确或用户不存在\n - 应使用匿名登录但传入了密码参数\n - 应使用密码登录但未传入正确的凭据\n\n 建议:\n 1. 明确当前场景需要的登录方式:\n - 无需用户注册 → auth.signInAnonymously()\n - 有用户名和密码 → auth.signInWithPassword({ username, password })\n - 第三方平台 → auth.signInWithOAuth({ provider })\n 2. 不要在同一流程中混合使用不同的登录方式\n 3. 每种登录方式需要在控制台开启对应的身份源\n"+" 4. 控制台地址:".concat(a);case i.RATE_LIMITED:return"[CloudBase Auth] 发送频率受限\n\n 验证码发送过于频繁,已触发频率限制。\n\n 限制规则:\n - 手机号:每分钟最多 1 条,每天有上限\n - 邮箱:每分钟有上限,每天有上限(默认 50 条)\n\n 建议:\n 1. 检查 error.retryAfter 获取建议等待时间\n 2. 在 UI 中显示倒计时,防止用户重复点击\n 3. 如业务需要更高频率,请联系技术支持调整限额";case i.CAPTCHA_REQUIRED:return"[CloudBase Auth] 需要滑块验证码\n\n 当前操作触发了风控策略,需要完成滑块验证。\n\n 处理方式:\n 1. 调用滑块验证码 SDK 展示验证组件\n 2. 用户完成验证后,将 captcha_token 附带到请求中重新发送\n 3. 可通过 getVerification 的 options.withCaptcha 参数自动携带验证码";case i.CAPTCHA_INVALID:return"[CloudBase Auth] 滑块验证码校验失败\n\n 提交的验证码 token 校验未通过(可能已过期或 client_id 不匹配)。\n\n 处理方式:\n 1. 刷新滑块验证码,让用户重新验证\n 2. 确认 captcha 组件初始化的 client_id 与认证配置一致";case i.MFA_REQUIRED:return"[CloudBase Auth] 需要 MFA 验证\n\n 当前操作要求用户绑定手机号进行多因素认证 (MFA)。\n\n 处理方式:\n 1. 引导用户进入手机号绑定流程\n 2. 绑定完成后重新执行原操作\n 3. error 中可能包含 MFA 详情信息";case i.PRECONDITION_FAILED:return"[CloudBase Auth] 前置条件不满足\n\n 当前操作的前置条件不满足,常见原因:\n - 该手机号/邮箱已被其他账号绑定\n - 目标用户不存在或已存在(与 target 参数冲突)\n - 当前邮箱/手机号未注册用户\n\n 请根据 error.message 中的具体描述处理。";case i.VERIFICATION_FAILED:return'[CloudBase Auth] 验证码校验失败\n\n 验证码验证未通过,常见原因:\n - 验证码已过期(通常有效期为几分钟)\n - 验证码输入不正确\n - verification_id 无效或已被使用\n - 验证码不属于当前项目(project id does not match)\n\n 处理方式:\n 1. 提示用户"验证码已过期或不正确,请重新获取"\n 2. 调用 getVerification() 重新发送验证码\n 3. 确保 verification_id 与最新发送的验证码对应\n\n 注意:每次重新发送验证码后,之前的 verification_id 即失效。';default:return"[CloudBase Auth] 操作失败\n\n 如果问题持续存在,建议:\n"+" 1. 检查云开发控制台的认证配置:".concat(a,"\n")+" 2. 到官方问答社区提问:https://cnb.cool/tencent/cloud/cloudbase/community/-/issues\n"+" 3. 查阅文档:".concat(u)}}(o.category,r),o.loginMethodHint=(n=null==r?void 0:r.method)&&{signInWithPassword:"当前使用「用户名密码登录」,需确保:\n ✓ 控制台已开启「用户名密码登录」\n ✓ 用户已注册且凭据正确\n 如果不需要用户系统,建议改用 auth.signInAnonymously()",signInAnonymously:"当前使用「匿名登录」,需确保:\n ✓ 控制台已开启「匿名登录」\n 注意:匿名用户无需用户名密码,适用于快速体验或临时访问场景",signInWithOtp:"当前使用「OTP 验证码登录」,需确保:\n ✓ 控制台已开启「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"当前使用「第三方 OAuth 登录」,需确保:\n ✓ 控制台已配置并开启对应的第三方身份源"}[n]||"",o.category===i.RATE_LIMITED&&(o.retryAfter=t.retry_after||t.retryAfter||void 0),o}return o(t,e),t}(Error);t.AuthError=c},949:(e,t)=>{var r,n,o,i,s;Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.EVENTS=t.AUTH_STATE_CHANGED_TYPE=t.LOGIN_STATE_CHANGED_TYPE=t.AuthErrorCode=t.ErrorType=t.VerificationUsages=t.ApiUrlsV2=t.ApiUrls=t.AUTH_API_PREFIX=void 0,t.AUTH_API_PREFIX="/auth",(s=t.ApiUrls||(t.ApiUrls={})).AUTH_SIGN_UP_URL="/v1/signup",s.AUTH_TOKEN_URL="/v1/token",s.AUTH_REVOKE_URL="/v1/revoke",s.WEDA_USER_URL="/v1/plugin/weda/userinfo",s.AUTH_RESET_PASSWORD="/v1/reset",s.AUTH_GET_DEVICE_CODE="/v1/device/code",s.CHECK_USERNAME="/v1/checkUsername",s.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",s.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",s.AUTH_SIGN_IN_URL="/v1/signin",s.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",s.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",s.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",s.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",s.PROVIDER_TOKEN_URL="/v1/provider/token",s.PROVIDER_URI_URL="/v1/provider/uri",s.USER_ME_URL="/v1/user/me",s.AUTH_SIGNOUT_URL="/v1/user/signout",s.USER_QUERY_URL="/v1/user/query",s.USER_PRIFILE_URL="/v1/user/profile",s.USER_BASIC_EDIT_URL="/v1/user/basic/edit",s.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",s.PROVIDER_LIST="/v1/user/provider",s.PROVIDER_BIND_URL="/v1/user/provider/bind",s.PROVIDER_UNBIND_URL="/v1/user/provider",s.CHECK_PWD_URL="/v1/user/sudo",s.SUDO_URL="/v1/user/sudo",s.BIND_CONTACT_URL="/v1/user/contact",s.AUTH_SET_PASSWORD="/v1/user/password",s.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",s.AUTHORIZE_URL="/v1/user/authorize",s.AUTHORIZE_INFO_URL="/v1/user/authorize/info",s.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",s.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",s.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",s.VERIFICATION_URL="/v1/verification",s.VERIFY_URL="/v1/verification/verify",s.CAPTCHA_DATA_URL="/v1/captcha/data",s.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",s.GET_CAPTCHA_URL="/v1/captcha/init",s.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",s.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status",(i=t.ApiUrlsV2||(t.ApiUrlsV2={})).AUTH_SIGN_IN_URL="/v2/signin/username",i.AUTH_TOKEN_URL="/v2/token",i.USER_ME_URL="/v2/user/me",i.VERIFY_URL="/v2/signin/verificationcode",i.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",i.AUTH_PUBLIC_KEY="/v2/signin/publichkey",i.AUTH_RESET_PASSWORD="/v2/signin/password/update",(o=t.VerificationUsages||(t.VerificationUsages={})).REGISTER="REGISTER",o.SIGN_IN="SIGN_IN",o.PASSWORD_RESET="PASSWORD_RESET",o.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",o.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE",(n=t.ErrorType||(t.ErrorType={})).UNREACHABLE="unreachable",n.LOCAL="local",n.CANCELLED="cancelled",n.UNKNOWN="unknown",n.UNAUTHENTICATED="unauthenticated",n.RESOURCE_EXHAUSTED="resource_exhausted",n.FAILED_PRECONDITION="failed_precondition",n.INVALID_ARGUMENT="invalid_argument",n.DEADLINE_EXCEEDED="deadline_exceeded",n.NOT_FOUND="not_found",n.ALREADY_EXISTS="already_exists",n.PERMISSION_DENIED="permission_denied",n.ABORTED="aborted",n.OUT_OF_RANGE="out_of_range",n.UNIMPLEMENTED="unimplemented",n.INTERNAL="internal",n.UNAVAILABLE="unavailable",n.DATA_LOSS="data_loss",n.INVALID_PASSWORD="invalid_password",n.PASSWORD_NOT_SET="password_not_set",n.INVALID_STATUS="invalid_status",n.USER_PENDING="user_pending",n.USER_BLOCKED="user_blocked",n.INVALID_VERIFICATION_CODE="invalid_verification_code",n.TWO_FACTOR_REQUIRED="two_factor_required",n.INVALID_TWO_FACTOR="invalid_two_factor",n.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",n.UNDER_REVIEW="under_review",n.INVALID_REQUEST="invalid_request",n.UNAUTHORIZED_CLIENT="unauthorized_client",n.ACCESS_DENIED="access_denied",n.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",n.INVALID_SCOPE="invalid_scope",n.INVALID_GRANT="invalid_grant",n.SERVER_ERROR="server_error",n.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",n.INTERACTION_REQUIRED="interaction_required",n.LOGIN_REQUIRED="login_required",n.ACCOUNT_SELECTION_REQUIRED="account_selection_required",n.CONSENT_REQUIRED="consent_required",n.INVALID_REQUEST_URI="invalid_request_uri",n.INVALID_REQUEST_OBJECT="invalid_request_object",n.REQUEST_NOT_SUPPORTED="request_not_supported",n.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",n.REGISTRATION_NOT_SUPPORTED="registration_not_supported",n.CAPTCHA_REQUIRED="captcha_required",n.CAPTCHA_INVALID="captcha_invalid",n.PROVIDER_NOT_ENABLED="provider_not_enabled",n.LOGIN_METHOD_DISABLED="login_method_disabled",n.INVALID_USERNAME_OR_PASSWORD="invalid_username_or_password",n.INVALID_CREDENTIALS="invalid_credentials",n.WRONG_PASSWORD="wrong_password",n.USER_NOT_FOUND="user_not_found",n.MFA_PHONE_REQUIRED="mfa_phone_required",n.LOGIN_TYPE_DISABLED="login_type_disabled",n.PROVIDER_ERROR="provider_error",(r=t.AuthErrorCode||(t.AuthErrorCode={}))[r.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",r[r.NOT_FOUND=5]="NOT_FOUND",r[r.PERMISSION_DENIED=7]="PERMISSION_DENIED",r[r.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",r[r.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",r[r.ABORTED=10]="ABORTED",r[r.UNIMPLEMENTED=12]="UNIMPLEMENTED",r[r.INTERNAL=13]="INTERNAL",r[r.UNAVAILABLE=14]="UNAVAILABLE",r[r.UNAUTHENTICATED=16]="UNAUTHENTICATED",r[r.CAPTCHA_REQUIRED=4001]="CAPTCHA_REQUIRED",r[r.CAPTCHA_INVALID=4002]="CAPTCHA_INVALID",r[r.PROVIDER_ERROR=4019]="PROVIDER_ERROR",r[r.UNAUTHORIZED_CLIENT=4022]="UNAUTHORIZED_CLIENT",r[r.MFA_PHONE_REQUIRED=4042]="MFA_PHONE_REQUIRED",r[r.LOGIN_TYPE_DISABLED=4045]="LOGIN_TYPE_DISABLED",t.LOGIN_STATE_CHANGED_TYPE={SIGN_OUT:"sign_out",SIGN_IN:"sign_in",CREDENTIALS_ERROR:"credentials_error"},t.AUTH_STATE_CHANGED_TYPE={SIGNED_OUT:"SIGNED_OUT",SIGNED_IN:"SIGNED_IN",INITIAL_SESSION:"INITIAL_SESSION",PASSWORD_RECOVERY:"PASSWORD_RECOVERY",TOKEN_REFRESHED:"TOKEN_REFRESHED",USER_UPDATED:"USER_UPDATED",BIND_IDENTITY:"BIND_IDENTITY"},t.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",AUTH_STATE_CHANGED:"authStateChanged"},t.OAUTH_TYPE={SIGN_IN:"sign_in",BIND_IDENTITY:"bind_identity"},t.DEFAULT_NODE_ACCESS_SCOPE="node-sdk-scope"},538:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},84:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.openURIWithCallback=void 0;var s=r(689),a=r(616),u=function(e,t){var r;return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout(function(){return e.apply(null,n)},t)}},c=new s.CloudbaseEventEmitter,l="resolveCaptchaData",h="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",d="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",f="background:#6c757d;cursor:not-allowed";t.openURIWithCallback=function(e,t){return o(void 0,void 0,Promise,function(){var r,s,p,v;return i(this,function(_){return r=(0,a.parseCaptcha)(e),s=r.captchaData,p=r.state,v=r.token,function(e){var t=e.oauthInstance,r=e.captchaState,s="captcha-image",a=function(){return o(void 0,void 0,void 0,function(){var e,o;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t.createCaptchaData({state:r.state})];case 1:return e=i.sent(),r=n(n({},r),{captchaData:e.data,token:e.token}),document.getElementById(s).src=e.data,[3,3];case 2:return o=i.sent(),console.error("刷新图形验证码失败",o),[3,3];case 3:return[2]}})})},p=function(e,t,r){var n=document.createElement(e);return t&&(n.style.cssText=t),r&&(n.textContent=r),n},v=p("div","position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999"),_=p("div","position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:320px;padding:20px;background:#fff;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.2);z-index:1000");_.appendChild(p("p","margin-bottom:15px","请输入你看到的字符:"));var m=p("div","display:flex;align-items:center;justify-content:space-between;margin-bottom:15px"),y=p("img","width:100%;height:auto;border:1px solid #eee");y.id=s,y.src=r.captchaData,m.appendChild(y);var g=p("button",h,"刷新");g.onclick=u(function(){return o(void 0,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:g.textContent="加载中...",g.disabled=!0,g.style.cssText="".concat(h,";").concat(f),e.label=1;case 1:return e.trys.push([1,,3,4]),[4,a()];case 2:return e.sent(),[3,4];case 3:return g.textContent="刷新",g.disabled=!1,g.style.cssText=h,[7];case 4:return[2]}})})},500),m.appendChild(g),_.appendChild(m);var b=p("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");b.type="text",b.placeholder="输入字符",b.maxLength=4,_.appendChild(b);var w=p("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");_.appendChild(w);var E=function(e){w.textContent=e,w.style.display="block"},S=p("button",d,"确定");S.onclick=u(function(){return o(void 0,void 0,void 0,function(){var e,n,o,s;return i(this,function(i){switch(i.label){case 0:if(!(e=b.value.trim()))return E("请输入字符"),[2];w.style.display="none",S.textContent="验证中...",S.disabled=!0,S.style.cssText="".concat(d,";").concat(f),i.label=1;case 1:return i.trys.push([1,3,5,6]),[4,t.verifyCaptchaData({token:r.token,key:e})];case 2:return n=i.sent(),c.fire(l,n),console.log("图形验证码校验成功"),document.body.removeChild(v),document.body.removeChild(_),[3,6];case 3:return o=i.sent(),console.error("图形验证码校验失败",o),s=o.error_description||"图形验证码校验失败",E(s),b.value="",b.focus(),[4,a()];case 4:return i.sent(),[3,6];case 5:return S.textContent="确定",S.disabled=!1,S.style.cssText=d,[7];case 6:return[2]}})})},500),_.appendChild(S),document.body.appendChild(v),document.body.appendChild(_)}({oauthInstance:t,captchaState:{captchaData:s,state:p,token:v}}),[2,new Promise(function(e){console.log("等待图形验证码校验结果..."),c.on(l,function(t){e(null==t?void 0:t.data)})})]})})}},462:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.Captcha=void 0;var i=r(949),s=r(257),a=r(425),u=r(84),c=function(){function e(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=s.defaultStorage),this.config=e,this.tokenSectionName="captcha_".concat(e.clientId||e.env)}return e.prototype.isMatch=function(){var e,t,r;return(null===(r=null===(t=null===(e=this.config)||void 0===e?void 0:e.adapter)||void 0===t?void 0:t.isMatch)||void 0===r?void 0:r.call(t))||(0,a.isMp)()},e.prototype.request=function(e,t){return n(this,void 0,Promise,function(){var r,n,s,a;return o(this,function(o){switch(o.label){case 0:return t||(t={}),t.method||(t.method="GET"),r="".concat(t.method,":").concat(e),n=e,t.withCaptcha?[4,this.appendCaptchaTokenToURL(e,r,!1)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return o.trys.push([2,4,,7]),[4,this.config.request(n,t)];case 3:return s=o.sent(),[3,7];case 4:return(a=o.sent()).error!==i.ErrorType.CAPTCHA_REQUIRED&&a.error!==i.ErrorType.CAPTCHA_INVALID?[3,6]:[4,this.appendCaptchaTokenToURL(e,r,a.error===i.ErrorType.CAPTCHA_INVALID)];case 5:return e=o.sent(),[2,this.config.request(e,t)];case 6:return[2,Promise.reject(a)];case 7:return[2,s]}})})},e.prototype.getDefaultOpenURIWithCallback=function(){var e=this;return function(t){return(0,u.openURIWithCallback)(t,e.config.oauthInstance)}},e.prototype.getCaptchaToken=function(e,t){return n(this,void 0,Promise,function(){var r,n,s,a;return o(this,function(o){switch(o.label){case 0:return e?[3,2]:[4,this.findCaptchaToken()];case 1:if(r=o.sent())return[2,r];o.label=2;case 2:return[4,this.config.request(i.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:""},withCredentials:!1})];case 3:return n=o.sent(),s="".concat(n.data,"?state=").concat(encodeURIComponent(t),"&token=").concat(encodeURIComponent(n.token)),[4,this.config.openURIWithCallback(s)];case 4:return a=o.sent(),this.saveCaptchaToken(a),[2,a.captcha_token]}})})},e.prototype.appendCaptchaTokenToURL=function(e,t,r){return n(this,void 0,Promise,function(){var n;return o(this,function(o){switch(o.label){case 0:return[4,this.getCaptchaToken(r,t)];case 1:return n=o.sent(),e.indexOf("?")>0?e+="&captcha_token=".concat(n):e+="?captcha_token=".concat(n),[2,e]}})})},e.prototype.saveCaptchaToken=function(e){return n(this,void 0,void 0,function(){var t;return o(this,function(r){switch(r.label){case 0:return e.expires_at=new Date(Date.now()+1e3*(e.expires_in-10)),t=JSON.stringify(e),[4,this.config.storage.setItem(this.tokenSectionName,t)];case 1:return r.sent(),[2]}})})},e.prototype.findCaptchaToken=function(){return n(this,void 0,Promise,function(){var e,t;return o(this,function(r){switch(r.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=r.sent()))return[3,5];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),t.expires_at<new Date?[2,null]:[2,t.captcha_token];case 3:return r.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),[2,null];case 5:return[2,null]}})})},e}();t.Captcha=c},722:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseOAuth=t.AuthErrorCode=t.AUTH_STATE_CHANGED_TYPE=t.EVENTS=t.LOGIN_STATE_CHANGED_TYPE=t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.AUTH_API_PREFIX=t.weAppJwtDecodeAll=t.authModels=t.AuthErrorCategory=t.AuthError=t.Auth=void 0;var a=r(257),u=r(413),c=r(949),l=r(413);Object.defineProperty(t,"Auth",{enumerable:!0,get:function(){return l.Auth}});var h=r(308);Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return h.AuthError}}),Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return h.AuthErrorCategory}}),t.authModels=s(r(538));var d=r(344);Object.defineProperty(t,"weAppJwtDecodeAll",{enumerable:!0,get:function(){return d.weAppJwtDecodeAll}});var f=r(949);Object.defineProperty(t,"AUTH_API_PREFIX",{enumerable:!0,get:function(){return f.AUTH_API_PREFIX}}),Object.defineProperty(t,"OAUTH_TYPE",{enumerable:!0,get:function(){return f.OAUTH_TYPE}}),Object.defineProperty(t,"DEFAULT_NODE_ACCESS_SCOPE",{enumerable:!0,get:function(){return f.DEFAULT_NODE_ACCESS_SCOPE}}),Object.defineProperty(t,"LOGIN_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return f.LOGIN_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"EVENTS",{enumerable:!0,get:function(){return f.EVENTS}}),Object.defineProperty(t,"AUTH_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return f.AUTH_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"AuthErrorCode",{enumerable:!0,get:function(){return f.AuthErrorCode}});var p=function(){function e(e){var t=e.apiOrigin,r=e.getApiOrigin,o=e.apiPath,i=void 0===o?c.AUTH_API_PREFIX:o,s=e.clientId,l=e.env,h=e.storage,d=e.request,f=e.baseRequest,p=e.anonymousSignInFunc,v=e.wxCloud,_=e.adapter,m=e.onCredentialsError,y=e.headers,g=e.i18n,b=e.useWxCloud,w=e.eventBus,E=e.detectSessionInUrl,S=e.debug;if(this.detectSessionInUrl=null!=E&&E,this.oauth2client=new a.OAuth2Client({apiOrigin:t,getApiOrigin:r,apiPath:i,clientId:s,env:l,storage:h,baseRequest:f||d,anonymousSignInFunc:p,wxCloud:v,onCredentialsError:m,headers:y||{},i18n:g,useWxCloud:b,eventBus:w,debug:S}),this.authApi=new u.Auth(n(n({credentialsClient:this.oauth2client},e),{request:d?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:_})),E)this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));else try{var I=new URL(window.location.href),A=I.searchParams.get("code"),T=I.searchParams.get("state"),P=JSON.parse(sessionStorage.getItem(T)||"null");A&&T&&(null==P?void 0:P.hash)&&(I.hash=P.hash,window.history.replaceState(null,"",I.toString()),window.location.replace(I.toString()))}catch(e){}}return e.prototype.initializeSession=function(e){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(e),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))},e}();t.CloudbaseOAuth=p},877:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Syntax=t.ErrorType=void 0;var n,o=r(949);Object.defineProperty(t,"ErrorType",{enumerable:!0,get:function(){return o.ErrorType}}),(n=t.Syntax||(t.Syntax={})).CLIENT_ID="client_id",n.CLIENT_SECRET="client_secret",n.RESPONSE_TYPE="response_type",n.SCOPE="scope",n.STATE="state",n.REDIRECT_URI="redirect_uri",n.ERROR="error",n.ERROR_DESCRIPTION="error_description",n.ERROR_URI="error_uri",n.GRANT_TYPE="grant_type",n.CODE="code",n.ACCESS_TOKEN="access_token",n.TOKEN_TYPE="token_type",n.EXPIRES_IN="expires_in",n.USERNAME="username",n.PASSWORD="password",n.REFRESH_TOKEN="refresh_token"},257:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.OAuth2Client=t.defaultStorage=t.generateRequestId=t.toResponseError=t.defaultRequest=void 0;var a=r(877),u=r(949),c=r(873),l=r(631),h=r(547),d=r(344),f=r(425),p=r(683),v="x-request-id",_="x-device-id",m="device_id";function y(){return(0,c.uuidv4)()}t.defaultRequest=function(e,t){return o(this,void 0,Promise,function(){var r,n,o,s,u;return i(this,function(i){switch(i.label){case 0:r=null,n=null,i.label=1;case 1:return i.trys.push([1,4,,5]),(o=Object.assign({},t)).method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body)),[4,fetch(e,o)];case 2:return[4,i.sent().json()];case 3:return(null==(s=i.sent())?void 0:s.error)?(n=s).error_uri=new URL(e).pathname:r=s,[3,5];case 4:return u=i.sent(),n={error:a.ErrorType.UNREACHABLE,error_description:u.message,error_uri:new URL(e).pathname},[3,5];case 5:if(n)throw n;return[2,r]}})})},t.toResponseError=function(e,t){var r,n=t||{};if(e instanceof Error)r={error:n.error||a.ErrorType.LOCAL,error_description:n.error_description||e.message,error_uri:n.error_uri,details:n.details||e.stack};else{var o=e||{};r={error:n.error||o.error||a.ErrorType.LOCAL,error_description:n.error_description||o.error_description,error_uri:n.error_uri||o.error_uri,details:n.details||o.details}}return r},t.generateRequestId=y;var g=function(){function e(e){this._env=(null==e?void 0:e.env)||""}return e.prototype.getItem=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,window.localStorage.getItem("".concat(e).concat(this._env))]})})},e.prototype.removeItem=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return window.localStorage.removeItem("".concat(e).concat(this._env)),[2]})})},e.prototype.setItem=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(r){return window.localStorage.setItem("".concat(e).concat(this._env),t),[2]})})},e.prototype.getItemSync=function(e){return window.localStorage.getItem("".concat(e).concat(this._env))},e.prototype.removeItemSync=function(e){window.localStorage.removeItem("".concat(e).concat(this._env))},e.prototype.setItemSync=function(e,t){window.localStorage.setItem("".concat(e).concat(this._env),t)},e}();function b(e){var t=!0;return(null==e?void 0:e.expires_at)&&(null==e?void 0:e.access_token)&&(t=e.expires_at<new Date),t}t.defaultStorage=new g;var w=function(){function e(e){this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=e.tokenSectionName,this.storage=e.storage,this.clientId=e.clientId,this.singlePromise=new h.SinglePromise({clientId:this.clientId}),this.credentials=e.credentials||null}return e.prototype.getStorageCredentialsSync=function(){var e=null,t=this.storage.getItemSync(this.tokenSectionName);if(null!=t)try{(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at))}catch(t){this.storage.removeItem(this.tokenSectionName),e=null}return e},e.prototype.setCredentials=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return(null==e?void 0:e.expires_in)?((null==e?void 0:e.expires_at)||(e.expires_at=new Date(Date.now()+1e3*(e.expires_in-30))),this.storage?(t=JSON.stringify(e),[4,this.storage.setItem(this.tokenSectionName,t)]):[3,2]):[3,3];case 1:r.sent(),r.label=2;case 2:return this.credentials=e,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:r.sent(),r.label=5;case 5:this.credentials=null,r.label=6;case 6:return[2]}})})},e.prototype.setAccessKeyCredentials=function(e){this.accessKeyCredentials=e,e.scope===u.DEFAULT_NODE_ACCESS_SCOPE&&(this.credentials=e)},e.prototype.getCredentials=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){return[2,this.singlePromise.run("getCredentials",function(){return o(e,void 0,void 0,function(){var e,t;return i(this,function(r){switch(r.label){case 0:return b(this.credentials)?[4,this.getStorageCredentials()]:[3,2];case 1:if(e=r.sent(),t=e.credentials,e.isAccessKeyCredentials)return[2,t];this.credentials=t,r.label=2;case 2:return[2,this.credentials]}})})})]})})},e.prototype.getStorageCredentials=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){return[2,this.singlePromise.run("_getStorageCredentials",function(){return o(e,void 0,void 0,function(){var e,t,r;return i(this,function(n){switch(n.label){case 0:return e=null,t=!1,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(!(r=n.sent()))return[3,6];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(e=JSON.parse(r))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),e=null,[3,5];case 5:return[3,7];case 6:e=this.accessKeyCredentials||null,t=!0,n.label=7;case 7:return[2,{credentials:e,isAccessKeyCredentials:t}]}})})})]})})},e}();t.OAuth2Client=function(){function e(r){var n,o=this;this.initializePromise=null,this.lockAcquired=!1,this.pendingInLock=[],this.singlePromise=null,r.clientSecret||(r.clientSecret=""),!r.clientId&&r.env&&(r.clientId=r.env),this.apiOrigin=r.apiOrigin,this.getApiOriginFunc=r.getApiOrigin,this.apiPath=r.apiPath||u.AUTH_API_PREFIX,this.clientId=r.clientId,this.i18n=r.i18n,this.eventBus=r.eventBus,this.singlePromise=new h.SinglePromise({clientId:this.clientId}),this.retry=this.formatRetry(r.retry,e.defaultRetry),r.baseRequest?this.baseRequest=r.baseRequest:this.baseRequest=t.defaultRequest,this.tokenInURL=r.tokenInURL,this.headers=r.headers,this.storage=r.storage||t.defaultStorage,this.localCredentials=new w({tokenSectionName:"credentials_".concat(r.clientId),storage:this.storage,clientId:r.clientId}),this.clientSecret=r.clientSecret,r.clientId&&(this.basicAuth="Basic ".concat((0,d.weBtoa)("".concat(r.clientId,":").concat(this.clientSecret)))),this.wxCloud=r.wxCloud;try{(0,f.isMp)()&&(this.useWxCloud=r.useWxCloud,void 0===this.wxCloud&&r.env&&(wx.cloud.init({env:r.env}),this.wxCloud=wx.cloud))}catch(e){}this.refreshTokenFunc=r.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=r.anonymousSignInFunc,this.onCredentialsError=r.onCredentialsError,this.getInitialSession=r.getInitialSession,this.onInitialSessionObtained=r.onInitialSessionObtained,this.logDebugMessages=null!==(n=r.debug)&&void 0!==n&&n,p.langEvent.bus.on(p.langEvent.LANG_CHANGE_EVENT,function(e){var t;o.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||o.i18n})}return e.prototype.setGetInitialSession=function(e){this.getInitialSession=e},e.prototype.setOnInitialSessionObtained=function(e){this.onInitialSessionObtained=e},e.prototype.initialize=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(r){switch(r.label){case 0:return this.initializePromise?[4,this.initializePromise]:[3,2];case 1:case 3:case 5:return[2,r.sent()];case 2:return void 0===e?[3,4]:(this.initializePromise=e,[4,this.initializePromise]);case 4:return this.initializePromise=o(t,void 0,void 0,function(){var e=this;return i(this,function(t){switch(t.label){case 0:return[4,this._acquireLock(-1,function(){return o(e,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this._initialize()];case 1:return[2,e.sent()]}})})})];case 1:return[2,t.sent()]}})}),[4,this.initializePromise]}})})},e.prototype.setCredentials=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[2,this._acquireLock(-1,function(){return o(t,void 0,void 0,function(){return i(this,function(t){return[2,this.localCredentials.setCredentials(e)]})})})]}})})},e.prototype.setAccessKeyCredentials=function(e){return this.localCredentials.setAccessKeyCredentials(e)},e.prototype.getAccessToken=function(){return o(this,void 0,Promise,function(){var e,t;return i(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[4,this.getCredentials()];case 2:return(null==(e=r.sent())?void 0:e.scope)===u.DEFAULT_NODE_ACCESS_SCOPE||(null==e?void 0:e.access_token)?[2,Promise.resolve(e.access_token)]:(t={error:a.ErrorType.UNAUTHENTICATED},[2,Promise.reject(t)])}})})},e.prototype.request=function(t,r){var s,u;return o(this,void 0,Promise,function(){var o,c,l,h,d,f,p,m,g,b;return i(this,function(i){switch(i.label){case 0:return r||(r={}),o=this.formatRetry(r.retry,this.retry),r.headers=n(n({},r.headers),((b={})[null===(s=this.i18n)||void 0===s?void 0:s.LANG_HEADER_KEY]=null===(u=this.i18n)||void 0===u?void 0:u.lang,b)),this.headers&&(r.headers=n(n({},this.headers),r.headers)),r.headers[v]||(r.headers[v]=y()),r.headers[_]?[3,2]:[4,this.getDeviceId()];case 1:c=i.sent(),r.headers[_]=c,i.label=2;case 2:return(null==r?void 0:r.withBasicAuth)&&this.basicAuth&&(r.headers.Authorization=this.basicAuth),(null==r?void 0:r.withCredentials)?r.getCredentials?[4,r.getCredentials()]:[3,4]:[3,7];case 3:return h=i.sent(),[3,6];case 4:return[4,this.getCredentials()];case 5:h=i.sent(),i.label=6;case 6:return(l=h)&&(this.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+="access_token=".concat(l.access_token)):r.headers.Authorization="".concat(l.token_type," ").concat(l.access_token)),[3,8];case 7:this.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+="client_id=".concat(this.clientId)),i.label=8;case 8:t.startsWith("/")&&(d=this.getApiOriginFunc?this.getApiOriginFunc():this.apiOrigin,t="".concat(d).concat(this.apiPath).concat(t)),f=null,p=o+1,m=0,i.label=9;case 9:if(!(m<p))return[3,21];i.label=10;case 10:return i.trys.push([10,15,,18]),r.useWxCloud||this.useWxCloud?[4,this.wxCloudCallFunction(t,r)]:[3,12];case 11:return f=i.sent(),[3,14];case 12:return[4,this.baseRequest(t,r)];case 13:f=i.sent(),i.label=14;case 14:if(null==f?void 0:f.code)throw{error:f.code,error_description:f.message,error_uri:new URL(t).pathname};return[3,21];case 15:g=i.sent();try{g.requestId=g.requestId||r.headers[v]||""}catch(e){}return r.withCredentials&&g&&g.error===a.ErrorType.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,17];case 16:return i.sent(),[2,Promise.reject(g)];case 17:return m!==o&&g&&"unreachable"===g.error?[3,18]:[2,Promise.reject(g)];case 18:return[4,this.sleep(e.retryInterval)];case 19:i.sent(),i.label=20;case 20:return m++,[3,9];case 21:return[2,f]}})})},e.prototype.wxCloudCallFunction=function(e,t){var r;return o(this,void 0,Promise,function(){var o,s,u,c,h;return i(this,function(i){switch(i.label){case 0:o=null,s=null,i.label=1;case 1:i.trys.push([1,7,,8]),u="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,wx.getRendererUserAgent()];case 3:return u=i.sent(),[3,5];case 4:return i.sent(),[3,5];case 5:return[4,this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:e,method:t.method,headers:n({origin:"https://servicewechat.com","User-Agent":u},t.headers),body:t.body}})];case 6:return c=i.sent().result,(null===(r=null==c?void 0:c.body)||void 0===r?void 0:r.error_code)?(s=null==c?void 0:c.body).error_uri=(0,l.getPathName)(e):o=null==c?void 0:c.body,[3,8];case 7:return h=i.sent(),s={error:a.ErrorType.UNREACHABLE,error_description:h.message,error_uri:(0,l.getPathName)(e)},[3,8];case 8:if(s)throw s;return[2,o]}})})},e.prototype.getCredentials=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){switch(t.label){case 0:return[4,this.initializePromise];case 1:return t.sent(),[2,this._acquireLock(-1,function(){return o(e,void 0,void 0,function(){return i(this,function(e){return[2,this._getCredentials()]})})})]}})})},e.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},e.prototype.getCredentialsAsync=function(){return this.getCredentials()},e.prototype.getScope=function(){var e;return o(this,void 0,Promise,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=n.sent())?[2,t.scope]:(r="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}})})},e.prototype.getGroups=function(){var e;return o(this,void 0,Promise,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=n.sent())?[2,t.groups]:(r="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}})})},e.prototype.refreshToken=function(e,t){return o(this,void 0,Promise,function(){var r=this;return i(this,function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[2,this._acquireLock(-1,function(){return o(r,void 0,void 0,function(){return i(this,function(r){return[2,this._refreshToken(e,t)]})})})]}})})},e.prototype._refreshToken=function(e,t){return o(this,void 0,Promise,function(){var r=this;return i(this,function(n){return[2,this.singlePromise.run("_refreshToken",function(){return o(r,void 0,void 0,function(){var r,n,o,s,c,l,h;return i(this,function(i){switch(i.label){case 0:if((null==e?void 0:e.scope)===u.DEFAULT_NODE_ACCESS_SCOPE)return[2,e];if(!e||!e.refresh_token)return o="no refresh token found in credentials",null===(s=this.onCredentialsError)||void 0===s||s.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];i.label=1;case 1:return i.trys.push([1,4,,7]),[4,this.refreshTokenFunc(e.refresh_token,e)];case 2:return r=i.sent(),[4,this.localCredentials.setCredentials(r)];case 3:return i.sent(),null===(c=this.eventBus)||void 0===c||c.fire(u.EVENTS.AUTH_STATE_CHANGED,{event:u.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED}),[2,r];case 4:if(n=i.sent(),null==t?void 0:t.throwError)throw n;return n.error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return i.sent(),o=n.error_description,null===(l=this.onCredentialsError)||void 0===l||l.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];case 6:return null===(h=this.onCredentialsError)||void 0===h||h.call(this,{msg:n.error_description}),[2,Promise.reject(n)];case 7:return[2]}})})})]})})},e.prototype.anonymousLogin=function(e){return o(this,void 0,void 0,function(){var t=this;return i(this,function(r){return[2,this.singlePromise.run("_anonymousLogin",function(){return o(t,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return this.anonymousSignInFunc?[4,this.anonymousSignInFunc(e)]:[3,4];case 1:return t=n.sent(),(r=t)?[3,3]:[4,this.localCredentials.getCredentials()];case 2:r=n.sent(),n.label=3;case 3:return e=r,[3,6];case 4:return[4,this.anonymousSignIn(e)];case 5:e=n.sent(),n.label=6;case 6:return[2,e]}})})})]})})},e.prototype.checkRetry=function(t){var r=null;if(("number"!=typeof t||t<e.minRetry||t>e.maxRetry)&&(r={error:a.ErrorType.UNREACHABLE,error_description:"wrong options param: retry"}),r)throw r;return t},e.prototype.formatRetry=function(e,t){return void 0===e?t:this.checkRetry(e)},e.prototype.sleep=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,new Promise(function(t){setTimeout(function(){t()},e)})]})})},e.prototype.anonymousSignIn=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(r){return[2,this.singlePromise.run("_anonymous",function(){return o(t,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:if(!e||"anonymous"!==e.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];n.label=1;case 1:return n.trys.push([1,4,,7]),[4,this.request(u.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}})];case 2:return t=n.sent(),[4,this.localCredentials.setCredentials(t)];case 3:return n.sent(),[2,t];case 4:return(r=n.sent()).error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return n.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}})})})]})})},e.prototype.defaultRefreshTokenFunc=function(e,t){var r;return o(this,void 0,Promise,function(){var o,s,a;return i(this,function(i){switch(i.label){case 0:return void 0===e||""===e?(o="refresh token not found",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:o}),[2,this.unAuthenticatedError(o)]):(s=u.ApiUrls.AUTH_TOKEN_URL,"v2"===(null==t?void 0:t.version)&&(s=u.ApiUrlsV2.AUTH_TOKEN_URL),[4,this.request(s,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:e}})]);case 1:return a=i.sent(),[2,n(n({},a),{version:(null==t?void 0:t.version)||"v1"})]}})})},e.prototype.getDeviceId=function(){return o(this,void 0,Promise,function(){var e;return i(this,function(t){switch(t.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(m)];case 1:return"string"==typeof(e=t.sent())&&e.length>=16&&e.length<=48?[3,3]:(e=(0,c.uuidv4)(),[4,this.storage.setItem(m,e)]);case 2:t.sent(),t.label=3;case 3:return this.deviceID=e,[2,e]}})})},e.prototype.unAuthenticatedError=function(e){var t={error:a.ErrorType.UNAUTHENTICATED,error_description:e};return Promise.reject(t)},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logDebugMessages&&console.log.apply(console,s(["[OAuth2Client]"],e,!1))},e.prototype._initialize=function(){return o(this,void 0,Promise,function(){var e,t,r,n,o,s;return i(this,function(i){switch(i.label){case 0:if(i.trys.push([0,11,12,13]),!this.getInitialSession)return this._debug("#_initialize()","no getInitialSession callback set, skipping"),[2,{error:null}];this._debug("#_initialize()","calling getInitialSession callback"),i.label=1;case 1:return i.trys.push([1,9,,10]),[4,this.getInitialSession()];case 2:return s=i.sent(),e=s.data,t=s.error,(null==e?void 0:e.session)?(this._debug("#_initialize()","session obtained from getInitialSession",e.session),[4,this.localCredentials.setCredentials(null==e?void 0:e.session)]):[3,4];case 3:i.sent(),i.label=4;case 4:if(!this.onInitialSessionObtained)return[3,8];this._debug("#_initialize()","calling onInitialSessionObtained callback"),i.label=5;case 5:return i.trys.push([5,7,,8]),[4,this.onInitialSessionObtained(e,t)];case 6:return i.sent(),[3,8];case 7:return r=i.sent(),this._debug("#_initialize()","error in onInitialSessionObtained",r),[3,8];case 8:return t?(this._debug("#_initialize()","error from getInitialSession",t),[2,{error:t}]):[2,{error:null}];case 9:return n=i.sent(),this._debug("#_initialize()","exception during getInitialSession",n),[2,{error:n instanceof Error?n:new Error(String(n))}];case 10:return[3,13];case 11:return o=i.sent(),this._debug("#_initialize()","unexpected error",o),[2,{error:o instanceof Error?o:new Error(String(o))}];case 12:return this._debug("#_initialize()","end"),[7];case 13:return[2]}})})},e.prototype._acquireLock=function(e,t){return o(this,void 0,Promise,function(){var r,n,a,u,c=this;return i(this,function(l){switch(l.label){case 0:this._debug("#_acquireLock","begin",e),l.label=1;case 1:if(l.trys.push([1,,10,11]),this.lockAcquired)return r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=o(c,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,r];case 1:return e.sent(),[4,t()];case 2:return[2,e.sent()]}})}),this.pendingInLock.push(o(c,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,n];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})),[2,n];this._debug("#_acquireLock","acquiring lock for client",this.clientId),l.label=2;case 2:return l.trys.push([2,,8,9]),this.lockAcquired=!0,a=t(),this.pendingInLock.push(o(c,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,a];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})),[4,a];case 3:l.sent(),l.label=4;case 4:return this.pendingInLock.length?(u=s([],this.pendingInLock,!0),[4,Promise.all(u)]):[3,6];case 5:return l.sent(),this.pendingInLock.splice(0,u.length),[3,4];case 6:return[4,a];case 7:return[2,l.sent()];case 8:return this._debug("#_acquireLock","releasing lock for client",this.clientId),this.lockAcquired=!1,[7];case 9:return[3,11];case 10:return this._debug("#_acquireLock","end"),[7];case 11:return[2]}})})},e.prototype._getCredentials=function(){var e,t,r;return o(this,void 0,Promise,function(){var n,o,s;return i(this,function(i){switch(i.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:if((null==(n=i.sent())?void 0:n.scope)===u.DEFAULT_NODE_ACCESS_SCOPE)return[2,n];if(!n)return s="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];if(!b(n))return[3,12];if(!n.refresh_token)return[3,9];i.label=2;case 2:return i.trys.push([2,4,,8]),[4,this._refreshToken(n)];case 3:return n=i.sent(),[3,8];case 4:return o=i.sent(),"anonymous"!==n.scope?[3,6]:[4,this.anonymousLogin(n)];case 5:return n=i.sent(),[3,7];case 6:return null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:o.error_description}),[2,Promise.reject(o)];case 7:return[3,8];case 8:return[3,12];case 9:return"anonymous"!==n.scope?[3,11]:[4,this.anonymousLogin(n)];case 10:return n=i.sent(),[3,12];case 11:return s="no refresh token found in credentials",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];case 12:return[2,n]}})})},e.defaultRetry=2,e.minRetry=0,e.maxRetry=5,e.retryInterval=1e3,e}()},344:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.weAppJwtDecodeAll=t.weappJwtDecode=t.base64_url_decode=t.weAtob=t.weBtoa=void 0;var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function o(e){var r=e.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(e){return decodeURIComponent((0,t.weAtob)(e).replace(/(.)/g,function(e){var t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0".concat(t)),"%".concat(t)}))}(r)}catch(e){return(0,t.weAtob)(r)}}t.weBtoa=function(e){for(var t,n,o,i,s="",a=0,u=(e=String(e)).length%3;a<e.length;){if((n=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");s+=r.charAt((t=n<<16|o<<8|i)>>18&63)+r.charAt(t>>12&63)+r.charAt(t>>6&63)+r.charAt(63&t)}return u?s.slice(0,u-3)+"===".substring(u):s},t.weAtob=function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!n.test(e))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var o,i,s="",a=0;a<e.length;)t=r.indexOf(e.charAt(a++))<<18|r.indexOf(e.charAt(a++))<<12|(o=r.indexOf(e.charAt(a++)))<<6|(i=r.indexOf(e.charAt(a++))),s+=64===o?String.fromCharCode(t>>16&255):64===i?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return s},t.base64_url_decode=o,t.weappJwtDecode=function(e,t){if("string"!=typeof e)throw new Error("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(o(e.split(".")[r]))}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}},t.weAppJwtDecodeAll=function(e){if("string"!=typeof e)throw new Error("Invalid token specified");try{var t=e.split(".").map(function(e,t){return 2===t?e:JSON.parse(o(e))});return{claims:t[1],header:t[0],signature:t[2]}}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}}},814:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getEncryptInfo=void 0;var o=n(r(12)),i=r(631);t.getEncryptInfo=function(e){var t=void 0===e?{}:e,r=t.publicKey,n=void 0===r?"":r,s=t.payload,a=void 0===s?{}:s;if(!n)return"";try{var u=(0,i.deepClone)(a),c=new o.default;return c.setPublicKey(n),c.encryptLong("object"==typeof u?JSON.stringify(u):u)}catch(e){console.error("encrypt error:",e)}return""}},547:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SinglePromise=void 0;var o=new Map,i=function(){function e(e){this.clientId=(null==e?void 0:e.clientId)||"",o=o||new Map}return e.prototype.run=function(e,t){return r(this,void 0,Promise,function(){var i,s=this;return n(this,function(a){return e="".concat(this.clientId,"_").concat(e),(i=o.get(e))||(i=new Promise(function(i,a){r(s,void 0,void 0,function(){var r,s,u;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return n.sent(),r=t(),s=i,[4,r];case 2:return s.apply(void 0,[n.sent()]),[3,5];case 3:return u=n.sent(),a(u),[3,5];case 4:return o.delete(e),[7];case 5:return[2]}})})}),o.set(e,i)),[2,i]})})},e.prototype.runIdlePromise=function(){return Promise.resolve()},e}();t.SinglePromise=i},631:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getPathName=t.deepClone=void 0,t.deepClone=function(e){var r=function(r){for(var n in e)e.hasOwnProperty(n)&&(r[n]=(0,t.deepClone)(e[n]));return r},n=null==e?"NullOrUndefined":Object.prototype.toString.call(e).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(n))return e.slice();switch(n){case"Object":return r(Object.create(Object.getPrototypeOf(e)));case"Array":return r([]);case"Date":return new Date(e.valueOf());case"RegExp":return new RegExp(e.source,(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":""));default:return e}},t.getPathName=function(e){var t=e.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return t&&t[2]||""}},425:(e,t)=>{function r(){if("undefined"==typeof globalThis)return!1;var e=globalThis.wx;if(void 0===e)return!1;if(void 0===globalThis.Page)return!1;if(!e.getDeviceInfo)return!1;if(!e.getStorageSync)return!1;if(!e.setStorageSync)return!1;if(!e.connectSocket)return!1;if(!e.request)return!1;try{if(!e.getDeviceInfo())return!1;if("qq"===e.getDeviceInfo().platform)return!1}catch(e){return!1}return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.isInMpWebView=t.isMp=void 0,t.isMp=r;var n=!1;function o(){n=n||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{r()||(n=n||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?o():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",o,!1))}catch(e){}t.isInMpWebView=function(){return n}},639:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){if(this.params={},"string"==typeof e)this.parse(e);else if(e&&"object"==typeof e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.append(t,e[t])}return e.prototype.parse=function(e){var t=this;e.split("&").forEach(function(e){var r=e.split("=").map(decodeURIComponent),n=r[0],o=r[1];t.append(n,o)})},e.prototype.append=function(e,t){this.params[e]?this.params[e]=this.params[e].concat([t]):this.params[e]=[t]},e.prototype.get=function(e){return this.params[e]?this.params[e][0]:null},e.prototype.getAll=function(e){return this.params[e]||[]},e.prototype.delete=function(e){delete this.params[e]},e.prototype.has=function(e){return Object.prototype.hasOwnProperty.call(this.params,e)},e.prototype.set=function(e,t){this.params[e]=[t]},e.prototype.toString=function(){var e=[],t=function(t){Object.prototype.hasOwnProperty.call(r.params,t)&&r.params[t].forEach(function(r){e.push("".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(r)))})},r=this;for(var n in this.params)t(n);return e.join("&")},e}();t.default=r},873:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=void 0,t.uuidv4=function(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}},563:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(92)),c=r(962);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,o=(0,c.isArray)(e)?e:[e];r<o.length;r++){var i=o[r],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:n({isMatch:s},a(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},92:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(829),c=r(962),l=r(464),h=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,s=e.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(t).forEach(function(e){c.append(e,t[e])}),c.append("key",n),c.append("file",r),this.request(i(i({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,Promise,function(){var t,r,n,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise(function(t){t({statusCode:200,tempFilePath:e.url})})]}})})},t.prototype.fetch=function(e){var t;return s(this,void 0,Promise,function(){var r,n,o,u,c,l,h,d,f,p,v,_,m,y=this;return a(this,function(g){switch(g.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,u=void 0!==o&&o,c=e.stream,l=void 0!==c&&c,h=e.signal,d=e.timeout,f=e.shouldThrowOnError,p=void 0===f||f,v=null!=d?d:this.timeout,h&&(h.aborted&&r.abort(),h.addEventListener("abort",function(){return r.abort()})),_=null,u&&v&&(_=setTimeout(function(){console.warn(y.timeoutMsg),r.abort(new Error(y.timeoutMsg))},v)),[4,fetch(n,i(i({},e),{signal:r.signal})).then(function(e){return s(y,void 0,void 0,function(){var t,r,n;return a(this,function(o){switch(o.label){case 0:return clearTimeout(_),p?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(_),Promise.reject(e)})];case 1:return m=g.sent(),[2,{data:l?m.body:(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers,response:m}]}})})},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise(function(o){var i=e.url,s=e.headers,a=void 0===s?{}:s,u=e.data,h=e.responseType,d=e.withCredentials,f=e.body,p=e.onUploadProgress,v=(0,c.formatUrl)((0,l.getProtocol)(),i,"get"===n?u:{}),_=new XMLHttpRequest;_.open(n,v),h&&(_.responseType=h);var m,y,g=e.signal;g&&(g.aborted?_.abort():g.addEventListener("abort",function(){return _.abort()},{once:!0})),Object.keys(a).forEach(function(e){_.setRequestHeader(e,a[e])}),p&&_.upload.addEventListener("progress",p),_.onreadystatechange=function(){var e={};if(4===_.readyState){var t=_.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach(function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o}),e.header=r,e.statusCode=_.status;try{e.data="blob"===h?_.response:JSON.parse(_.responseText)}catch(t){e.data="blob"===h?_.response:_.responseText}clearTimeout(m),o(e)}},t&&r.timeout&&(m=setTimeout(function(){console.warn(r.timeoutMsg),_.abort()},r.timeout)),y=(0,c.isFormData)(u)?u:"application/x-www-form-urlencoded"===a["content-type"]?(0,c.toQueryString)(u):f||(u?JSON.stringify(u):void 0),d&&(_.withCredentials=!0),_.send(y)})},t}(u.AbstractSDKRequest);t.WebRequest=h,t.genAdapter=function(){return{type:"default",root:window,reqClass:h,wsClass:WebSocket,localStorage}}},464:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var r="@cloudbase/js-sdk";t.setSdkName=function(e){r=e},t.getSdkName=function(){return r};var n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},519:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},778:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(r(464),t),o(r(519),t),t.OATUH_LOGINTYPE="constants"},517:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=r(962),s=r(778),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),h=s.findIndex(function(e){return u.test(e)});if(-1!==h){var d=s.filter(function(e,t){return t>h});d.unshift(s[h].replace(l,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,h=void 0===a?{}:a,d=e.title,f=e.messages,p=void 0===f?[]:f;return function(e,t,a){if(s.IS_DEBUG_MODE){var f=h.className||e.constructor.name,v=h.methodName||t,_=a.value,m=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex(function(e){return u.test(e)});if(-1!==r){var n=c.exec(t[r+1]||"");e=n?n[0]:""}return e}();a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=l({err:new Error,className:f,methodName:v,sourceLink:m});try{return _.apply(this,e)}catch(e){var n=e,o=e.message,s=e.error,a=e.error_description,u={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=p.map(function(e){return{type:"info",body:e}}))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,function(){var t,r,n,s,a,u,c,h;return o(this,function(o){switch(o.label){case 0:t=l({err:new Error,className:f,methodName:v,sourceLink:m}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,_.apply(this,e)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(h=JSON.parse(s),c.subtitle=h,h.code&&(t?(t.code=h.code,t.message=h.msg):(r.code=h.code,r.message=h.msg),n=t||r,c.content=p.map(function(e){return{type:"info",body:e}}))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(c),n;case 4:return[2]}})})}}}}},260:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(517),t)},683:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.langEvent=t.AbortController=t.jwt=t.helpers=t.utils=t.events=t.cache=t.adapters=t.constants=void 0;var a=i(r(778));t.constants=a;var u=i(r(563));t.adapters=u;var c=i(r(865));t.cache=c;var l=i(r(940));t.events=l;var h=i(r(991));t.langEvent=h;var d=i(r(962));t.utils=d;var f=i(r(260));t.helpers=f;var p=s(r(644));t.AbortController=p.default;var v={decode:s(r(254)).default};t.jwt=v},644:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){var e=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(t,r){"abort"===t&&e.listeners.push(r)}}}return e.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach(function(e){return e()}))},e}();t.default=r},865:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(829),u=r(962),c=r(778),l=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage),h=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(t.root));case"none":return new l(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return i(this,void 0,void 0,function(){var n;return s(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return i(this,void 0,void 0,function(){var n;return s(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}})})},e}();t.CloudbaseCache=h},940:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(962),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return o(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,c=this.listeners[n]?i([],this.listeners[n],!0):[];o<c.length;o++)c[o].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var l=new c;t.addEventListener=function(e,t){l.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),l.fire(e,t)},t.removeEventListener=function(e,t){l.off(e,t)}},991:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LANG_CHANGE_EVENT=t.bus=void 0;var n=r(940);t.bus=new n.CloudbaseEventEmitter,t.LANG_CHANGE_EVENT="lang_change"},962:function(e,t,r){var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=r(778);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)})},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach(function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))}),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise(function(t,r){e=function(e,n){return e?r(e):t(n)}});return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,u=void 0!==a&&a,c=e.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,h=s;l<h.length;l++){var d=h[l],f=d.type,p=d.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)}),t},t.parseCaptcha=function(e){var r={},o=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){e=o[1];var i=o[2];i&&(r=(0,t.parseQueryString)(i))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},12:(e,t,r)=>{var n;if(r.r(t),r.d(t,{default:()=>x}),!globalThis.IS_MP_BUILD){var o="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;function M(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function j(e,t){return e&t}function q(e,t){return e|t}function B(e,t){return e^t}function W(e,t){return e&~t}function H(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function V(e){for(var t=0;0!=e;)e&=e-1,++t;return t}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function F(e){var t,r,n="";for(t=0;t+3<=e.length;t+=3)r=parseInt(e.substring(t,t+3),16),n+=i.charAt(r>>6)+i.charAt(63&r);for(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=i.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=i.charAt(r>>2)+i.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function G(e){var t,r="",n=0,o=0;for(t=0;t<e.length&&"="!=e.charAt(t);++t){var s=i.indexOf(e.charAt(t));s<0||(0==n?(r+=M(s>>2),o=3&s,n=1):1==n?(r+=M(o<<2|s>>4),o=15&s,n=2):2==n?(r+=M(o),r+=M(s>>2),o=3&s,n=3):(r+=M(o<<2|s>>4),r+=M(15&s),n=0))}return 1==n&&(r+=M(o<<2)),r}var s,a,u={decode:function(e){var t;if(void 0===s){var r="0123456789ABCDEF";for(s={},t=0;t<16;++t)s[r.charAt(t)]=t;for(r=r.toLowerCase(),t=10;t<16;++t)s[r.charAt(t)]=t;for(t=0;t<8;++t)s[" \f\n\r\t \u2028\u2029".charAt(t)]=-1}var n=[],o=0,i=0;for(t=0;t<e.length;++t){var a=e.charAt(t);if("="==a)break;if(-1!=(a=s[a])){if(void 0===a)throw new Error("Illegal character at offset "+t);o|=a,++i>=2?(n[n.length]=o,o=0,i=0):o<<=4}}if(i)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},c={decode:function(e){var t;if(void 0===a){for(a=Object.create(null),t=0;t<64;++t)a["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)]=t;for(t=0;t<9;++t)a["= \f\n\r\t \u2028\u2029".charAt(t)]=-1}var r=[],n=0,o=0;for(t=0;t<e.length;++t){var i=e.charAt(t);if("="==i)break;if(-1!=(i=a[i])){if(void 0===i)throw new Error("Illegal character at offset "+t);n|=i,++o>=4?(r[r.length]=n>>16,r[r.length]=n>>8&255,r[r.length]=255&n,n=0,o=0):n<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=n>>10;break;case 3:r[r.length]=n>>16,r[r.length]=n>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(e){var t=c.re.exec(e);if(t)if(t[1])e=t[1];else{if(!t[2])throw new Error("RegExp out of sync");e=t[2]}return c.decode(e)}},l=1e13;class Y{constructor(e){this.buf=[+e||0]}mulAdd(e,t){var r,n,o=this.buf,i=o.length;for(r=0;r<i;++r)(n=o[r]*e+t)<l?t=0:n-=(t=0|n/l)*l,o[r]=n;t>0&&(o[r]=t)}sub(e){var t,r,n=this.buf,o=n.length;for(t=0;t<o;++t)(r=n[t]-e)<0?(r+=l,e=1):e=0,n[t]=r;for(;0===n[n.length-1];)n.pop()}toString(e){if(10!=(e||10))throw new Error("only base 10 is supported");for(var t=this.buf,r=t[t.length-1].toString(),n=t.length-2;n>=0;--n)r+=(l+t[n]).toString().substring(1);return r}valueOf(){for(var e=this.buf,t=0,r=e.length-1;r>=0;--r)t=t*l+e[r];return t}simplify(){var e=this.buf;return 1==e.length?e[0]:this}}var h,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)?)?$/,f=/^(\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 z(e,t){return e.length>t&&(e=e.substring(0,t)+"…"),e}class K{constructor(e,t){this.hexDigits="0123456789ABCDEF",e instanceof K?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=t)}get(e){if(void 0===e&&(e=this.pos++),e>=this.enc.length)throw new Error("Requesting byte offset "+e+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(e):this.enc[e]}hexByte(e){return this.hexDigits.charAt(e>>4&15)+this.hexDigits.charAt(15&e)}hexDump(e,t,r){for(var n="",o=e;o<t;++o)if(n+=this.hexByte(this.get(o)),!0!==r)switch(15&o){case 7:n+=" ";break;case 15:n+="\n";break;default:n+=" "}return n}isASCII(e,t){for(var r=e;r<t;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(e,t){for(var r="",n=e;n<t;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(e,t){for(var r="",n=e;n<t;){var o=this.get(n++);r+=o<128?String.fromCharCode(o):o>191&&o<224?String.fromCharCode((31&o)<<6|63&this.get(n++)):String.fromCharCode((15&o)<<12|(63&this.get(n++))<<6|63&this.get(n++))}return r}parseStringBMP(e,t){for(var r,n,o="",i=e;i<t;)r=this.get(i++),n=this.get(i++),o+=String.fromCharCode(r<<8|n);return o}parseTime(e,t,r){var n=this.parseStringISO(e,t),o=(r?d:f).exec(n);return o?(r&&(o[1]=+o[1],o[1]+=+o[1]<70?2e3:1900),n=o[1]+"-"+o[2]+"-"+o[3]+" "+o[4],o[5]&&(n+=":"+o[5],o[6]&&(n+=":"+o[6],o[7]&&(n+="."+o[7]))),o[8]&&(n+=" UTC","Z"!=o[8]&&(n+=o[8],o[9]&&(n+=":"+o[9]))),n):"Unrecognized time: "+n}parseInteger(e,t){for(var r,n=this.get(e),o=n>127,i=o?255:0,s="";n==i&&++e<t;)n=this.get(e);if(0===(r=t-e))return o?-1:0;if(r>4){for(s=n,r<<=3;!(128&(+s^i));)s=+s<<1,--r;s="("+r+" bit)\n"}o&&(n-=256);for(var a=new Y(n),u=e+1;u<t;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(e,t,r){for(var n=this.get(e),o="("+((t-e-1<<3)-n)+" bit)\n",i="",s=e+1;s<t;++s){for(var a=this.get(s),u=s==t-1?n:0,c=7;c>=u;--c)i+=a>>c&1?"1":"0";if(i.length>r)return o+z(i,r)}return o+i}parseOctetString(e,t,r){if(this.isASCII(e,t))return z(this.parseStringISO(e,t),r);var n=t-e,o="("+n+" byte)\n";n>(r/=2)&&(t=e+r);for(var i=e;i<t;++i)o+=this.hexByte(this.get(i));return n>r&&(o+="…"),o}parseOID(e,t,r){for(var n="",o=new Y,i=0,s=e;s<t;++s){var a=this.get(s);if(o.mulAdd(128,127&a),i+=7,!(128&a)){if(""===n)if((o=o.simplify())instanceof Y)o.sub(80),n="2."+o.toString();else{var u=o<80?o<40?0:1:2;n=u+"."+(o-40*u)}else n+="."+o.toString();if(n.length>r)return z(n,r);o=new Y,i=0}}return i>0&&(n+=".incomplete"),n}}class ${constructor(e,t,r,n,o){if(!(n instanceof Q))throw new Error("Invalid tag value.");this.stream=e,this.header=t,this.length=r,this.tag=n,this.sub=o}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(e){if(void 0===this.tag)return null;void 0===e&&(e=1/0);var t=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(t)?"false":"true";case 2:return this.stream.parseInteger(t,t+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+r,e);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);case 6:return this.stream.parseOID(t,t+r,e);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return z(this.stream.parseStringUTF(t,t+r),e);case 18:case 19:case 20:case 21:case 22:case 26:return z(this.stream.parseStringISO(t,t+r),e);case 30:return z(this.stream.parseStringBMP(t,t+r),e);case 23:case 24:return this.stream.parseTime(t,t+r,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(e){void 0===e&&(e="");var t=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(t+=" (encapsulates)"),t+="\n",null!==this.sub){e+=" ";for(var r=0,n=this.sub.length;r<n;++r)t+=this.sub[r].toPrettyString(e)}return t}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(e){var t=e.get(),r=127&t;if(r==t)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(e.pos-1));if(0===r)return null;t=0;for(var n=0;n<r;++n)t=256*t+e.get();return t}getHexStringValue(){var e=this.toHexString(),t=2*this.header,r=2*this.length;return e.substr(t,r)}static decode(e){var t;t=e instanceof K?e:new K(e,0);var r=new K(t),n=new Q(t),o=$.decodeLength(t),i=t.pos,s=i-r.pos,a=null,u=function(){var e=[];if(null!==o){for(var r=i+o;t.pos<r;)e[e.length]=$.decode(t);if(t.pos!=r)throw new Error("Content size is not correct for container starting at offset "+i)}else try{for(;;){var n=$.decode(t);if(n.tag.isEOC())break;e[e.length]=n}o=i-t.pos}catch(e){throw new Error("Exception while decoding undefined length content: "+e)}return e};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=t.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(e){a=null}if(null===a){if(null===o)throw new Error("We can't skip over an invalid tag with undefined length at offset "+i);t.pos=i+Math.abs(o)}return new $(r,s,o,n,a)}}class Q{constructor(e){var t=e.get();if(this.tagClass=t>>6,this.tagConstructed=!!(32&t),this.tagNumber=31&t,31==this.tagNumber){var r=new Y;do{t=e.get(),r.mulAdd(128,127&t)}while(128&t);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var p=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],v=(1<<26)/p[p.length-1];class J{constructor(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}toString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,o=!1,i="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(o=!0,i=M(r));s>=0;)a<t?(r=(this[s]&(1<<a)-1)<<t-a,r|=this[--s]>>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(o=!0),o&&(i+=M(r));return o?i:"0"}negate(){var e=X();return J.ZERO.subTo(this,e),e}abs(){return this.s<0?this.negate():this}compareTo(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+ie(this[this.t-1]^this.s&this.DM)}mod(e){var t=X();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(J.ZERO)>0&&e.subTo(t,t),t}modPowInt(e,t){var r;return r=e<256||t.isEven()?new m(t):new y(t),this.exp(e,r)}clone(){var e=X();return this.copyTo(e),e}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var e=this.t,t=[];t[0]=this.s;var r,n=this.DB-e*this.DB%8,o=0;if(e-- >0)for(n<this.DB&&(r=this[e]>>n)!=(this.s&this.DM)>>n&&(t[o++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this[e]&(1<<n)-1)<<8-n,r|=this[--e]>>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),128&r&&(r|=-256),0==o&&(128&this.s)!=(128&r)&&++o,(o>0||r!=this.s)&&(t[o++]=r);return t}equals(e){return 0==this.compareTo(e)}min(e){return this.compareTo(e)<0?this:e}max(e){return this.compareTo(e)>0?this:e}and(e){var t=X();return this.bitwiseTo(e,j,t),t}or(e){var t=X();return this.bitwiseTo(e,q,t),t}xor(e){var t=X();return this.bitwiseTo(e,B,t),t}andNot(e){var t=X();return this.bitwiseTo(e,W,t),t}not(){for(var e=X(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e}shiftLeft(e){var t=X();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}shiftRight(e){var t=X();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}getLowestSetBit(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+H(this[e]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=V(this[r]^t);return e}testBit(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)}setBit(e){return this.changeBit(e,q)}clearBit(e){return this.changeBit(e,W)}flipBit(e){return this.changeBit(e,B)}add(e){var t=X();return this.addTo(e,t),t}subtract(e){var t=X();return this.subTo(e,t),t}multiply(e){var t=X();return this.multiplyTo(e,t),t}divide(e){var t=X();return this.divRemTo(e,t,null),t}remainder(e){var t=X();return this.divRemTo(e,null,t),t}divideAndRemainder(e){var t=X(),r=X();return this.divRemTo(e,t,r),[t,r]}modPow(e,t){var r,n,o=e.bitLength(),i=oe(1);if(o<=0)return i;r=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new m(t):t.isEven()?new g(t):new y(t);var s=[],a=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var l=X();for(n.sqrTo(s[1],l);a<=c;)s[a]=X(),n.mulTo(l,s[a-2],s[a]),a+=2}var h,d,f=e.t-1,p=!0,v=X();for(o=ie(e[f])-1;f>=0;){for(o>=u?h=e[f]>>o-u&c:(h=(e[f]&(1<<o+1)-1)<<u-o,f>0&&(h|=e[f-1]>>this.DB+o-u)),a=r;!(1&h);)h>>=1,--a;if((o-=a)<0&&(o+=this.DB,--f),p)s[h].copyTo(i),p=!1;else{for(;a>1;)n.sqrTo(i,v),n.sqrTo(v,i),a-=2;a>0?n.sqrTo(i,v):(d=i,i=v,v=d),n.mulTo(v,s[h],i)}for(;f>=0&&!(e[f]&1<<o);)n.sqrTo(i,v),d=i,i=v,v=d,--o<0&&(o=this.DB-1,--f)}return n.revert(i)}modInverse(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return J.ZERO;for(var r=e.clone(),n=this.clone(),o=oe(1),i=oe(0),s=oe(0),a=oe(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(o.isEven()&&i.isEven()||(o.addTo(this,o),i.subTo(e,i)),o.rShiftTo(1,o)):i.isEven()||i.subTo(e,i),i.rShiftTo(1,i);for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),t&&o.subTo(s,o),i.subTo(a,i)):(n.subTo(r,n),t&&s.subTo(o,s),a.subTo(i,a))}return 0!=n.compareTo(J.ONE)?J.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a}pow(e){return this.exp(e,new _)}gcd(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var o=t.getLowestSetBit(),i=r.getLowestSetBit();if(i<0)return t;for(o<i&&(i=o),i>0&&(t.rShiftTo(i,t),r.rShiftTo(i,r));t.signum()>0;)(o=t.getLowestSetBit())>0&&t.rShiftTo(o,t),(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return i>0&&r.lShiftTo(i,r),r}isProbablePrime(e){var t,r=this.abs();if(1==r.t&&r[0]<=p[p.length-1]){for(t=0;t<p.length;++t)if(r[0]==p[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<p.length;){for(var n=p[t],o=t+1;o<p.length&&n<v;)n*=p[o++];for(n=r.modInt(n);t<o;)if(n%p[t++]==0)return!1}return r.millerRabin(e)}copyTo(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}fromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}fromString(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,o=!1,i=0;--n>=0;){var s=8==r?255&+e[n]:ne(e,n);s<0?"-"==e.charAt(n)&&(o=!0):(o=!1,0==i?this[this.t++]=s:i+r>this.DB?(this[this.t-1]|=(s&(1<<this.DB-i)-1)<<i,this[this.t++]=s>>this.DB-i):this[this.t-1]|=s<<i,(i+=r)>=this.DB&&(i-=this.DB))}8==r&&128&+e[0]&&(this.s=-1,i>0&&(this[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),o&&J.ZERO.subTo(this,this)}clamp(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t}dlShiftTo(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s}drShiftTo(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s}lShiftTo(e,t){for(var r=e%this.DB,n=this.DB-r,o=(1<<n)-1,i=Math.floor(e/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)t[a+i+1]=this[a]>>n|s,s=(this[a]&o)<<r;for(a=i-1;a>=0;--a)t[a]=0;t[i]=s,t.t=this.t+i+1,t.s=this.s,t.clamp()}rShiftTo(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,o=this.DB-n,i=(1<<n)-1;t[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)t[s-r-1]|=(this[s]&i)<<o,t[s-r]=this[s]>>n;n>0&&(t[this.t-r-1]|=(this.s&i)<<o),t.t=this.t-r,t.clamp()}}subTo(e,t){for(var r=0,n=0,o=Math.min(e.t,this.t);r<o;)n+=this[r]-e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e[r],t[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()}multiplyTo(e,t){var r=this.abs(),n=e.abs(),o=r.t;for(t.t=o+n.t;--o>=0;)t[o]=0;for(o=0;o<n.t;++o)t[o+r.t]=r.am(0,n[o],t,o,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&J.ZERO.subTo(t,t)}squareTo(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()}divRemTo(e,t,r){var n=e.abs();if(!(n.t<=0)){var o=this.abs();if(o.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=X());var i=X(),s=this.s,a=e.s,u=this.DB-ie(n[n.t-1]);u>0?(n.lShiftTo(u,i),o.lShiftTo(u,r)):(n.copyTo(i),o.copyTo(r));var c=i.t,l=i[c-1];if(0!=l){var h=l*(1<<this.F1)+(c>1?i[c-2]>>this.F2:0),d=this.FV/h,f=(1<<this.F1)/h,p=1<<this.F2,v=r.t,_=v-c,m=null==t?X():t;for(i.dlShiftTo(_,m),r.compareTo(m)>=0&&(r[r.t++]=1,r.subTo(m,r)),J.ONE.dlShiftTo(c,m),m.subTo(i,i);i.t<c;)i[i.t++]=0;for(;--_>=0;){var y=r[--v]==l?this.DM:Math.floor(r[v]*d+(r[v-1]+p)*f);if((r[v]+=i.am(0,y,r,_,0,c))<y)for(i.dlShiftTo(_,m),r.subTo(m,r);r[v]<--y;)r.subTo(m,r)}null!=t&&(r.drShiftTo(c,t),s!=a&&J.ZERO.subTo(t,t)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&&J.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(e,t){if(e>4294967295||e<1)return J.ONE;var r=X(),n=X(),o=t.convert(this),i=ie(e)-1;for(o.copyTo(r);--i>=0;)if(t.sqrTo(r,n),(e&1<<i)>0)t.mulTo(n,o,r);else{var s=r;r=n,n=s}return t.revert(r)}chunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}toRadix(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=oe(r),o=X(),i=X(),s="";for(this.divRemTo(n,o,i);o.signum()>0;)s=(r+i.intValue()).toString(e).substr(1)+s,o.divRemTo(n,o,i);return i.intValue().toString(e)+s}fromRadix(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),o=!1,i=0,s=0,a=0;a<e.length;++a){var u=ne(e,a);u<0?"-"==e.charAt(a)&&0==this.signum()&&(o=!0):(s=t*s+u,++i>=r&&(this.dMultiply(n),this.dAddOffset(s,0),i=0,s=0))}i>0&&(this.dMultiply(Math.pow(t,i)),this.dAddOffset(s,0)),o&&J.ZERO.subTo(this,this)}fromNumber(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(J.ONE.shiftLeft(e-1),q,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(J.ONE.shiftLeft(e-1),this);else{var n=[],o=7&e;n.length=1+(e>>3),t.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(e,t,r){var n,o,i=Math.min(e.t,this.t);for(n=0;n<i;++n)r[n]=t(this[n],e[n]);if(e.t<this.t){for(o=e.s&this.DM,n=i;n<this.t;++n)r[n]=t(this[n],o);r.t=this.t}else{for(o=this.s&this.DM,n=i;n<e.t;++n)r[n]=t(o,e[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()}changeBit(e,t){var r=J.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r}addTo(e,t){for(var r=0,n=0,o=Math.min(e.t,this.t);r<o;)n+=this[r]+e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e[r],t[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()}dMultiply(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}multiplyLowerTo(e,t,r){var n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(var o=r.t-this.t;n<o;++n)r[n+this.t]=this.am(0,e[n],r,n,0,this.t);for(o=Math.min(e.t,t);n<o;++n)this.am(0,e[n],r,n,0,t-n);r.clamp()}multiplyUpperTo(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r[this.t+n-t]=this.am(t-n,e[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)}modInt(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r}millerRabin(e){var t=this.subtract(J.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>p.length&&(e=p.length);for(var o=X(),i=0;i<e;++i){o.fromInt(p[Math.floor(Math.random()*p.length)]);var s=o.modPow(n,this);if(0!=s.compareTo(J.ONE)&&0!=s.compareTo(t)){for(var a=1;a++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(J.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0}square(){var e=X();return this.squareTo(e),e}gcda(e,t){var r=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(r.compareTo(n)<0){var o=r;r=n,n=o}var i=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)t(r);else{i<s&&(s=i),s>0&&(r.rShiftTo(s,r),n.rShiftTo(s,n));var a=()=>{(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),(i=n.getLowestSetBit())>0&&n.rShiftTo(i,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n)),r.signum()>0?setTimeout(a,0):(s>0&&n.lShiftTo(s,n),setTimeout(function(){t(n)},0))};setTimeout(a,10)}}fromNumberAsync(e,t,r,n){if("number"==typeof t)if(e<2)this.fromInt(1);else{this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(J.ONE.shiftLeft(e-1),q,this),this.isEven()&&this.dAddOffset(1,0);var o=this,i=function(){o.dAddOffset(2,0),o.bitLength()>e&&o.subTo(J.ONE.shiftLeft(e-1),o),o.isProbablePrime(t)?setTimeout(function(){n()},0):setTimeout(i,0)};setTimeout(i,0)}else{var s=[],a=7&e;s.length=1+(e>>3),t.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var _=function(){function e(){}return e.prototype.convert=function(e){return e},e.prototype.revert=function(e){return e},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},e.prototype.sqrTo=function(e,t){e.squareTo(t)},e}(),m=function(){function e(e){this.m=e}return e.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),y=function(){function e(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}return e.prototype.convert=function(e){var t=X();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(J.ZERO)>0&&this.m.subTo(t,t),t},e.prototype.revert=function(e){var t=X();return e.copyTo(t),this.reduce(t),t},e.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],n=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),g=function(){function e(e){this.m=e,this.r2=X(),this.q3=X(),J.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e)}return e.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=X();return e.copyTo(t),this.reduce(t),t},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}();function X(){return new J(null)}function Z(e,t){return new J(e,t)}function ee(e,t,r,n,o,i){for(;--i>=0;){var s=t*this[e++]+r[n]+o;o=Math.floor(s/67108864),r[n++]=67108863&s}return o}function te(e,t,r,n,o,i){for(var s=32767&t,a=t>>15;--i>=0;){var u=32767&this[e],c=this[e++]>>15,l=a*u+c*s;o=((u=s*u+((32767&l)<<15)+r[n]+(1073741823&o))>>>30)+(l>>>15)+a*c+(o>>>30),r[n++]=1073741823&u}return o}function re(e,t,r,n,o,i){for(var s=16383&t,a=t>>14;--i>=0;){var u=16383&this[e],c=this[e++]>>14,l=a*u+c*s;o=((u=s*u+((16383&l)<<14)+r[n]+o)>>28)+(l>>14)+a*c,r[n++]=268435455&u}return o}void 0!==o&&"Microsoft Internet Explorer"==(null==o?void 0:o.appName)?(J.prototype.am=te,h=30):"Netscape"!=(null==o?void 0:o.appName)?(J.prototype.am=ee,h=26):(J.prototype.am=re,h=28),J.prototype.DB=h,J.prototype.DM=(1<<h)-1,J.prototype.DV=1<<h,J.prototype.FV=Math.pow(2,52),J.prototype.F1=52-h,J.prototype.F2=2*h-52;var b,w,E=[];for(b="0".charCodeAt(0),w=0;w<=9;++w)E[b++]=w;for(b="a".charCodeAt(0),w=10;w<36;++w)E[b++]=w;for(b="A".charCodeAt(0),w=10;w<36;++w)E[b++]=w;function ne(e,t){var r=E[e.charCodeAt(t)];return null==r?-1:r}function oe(e){var t=X();return t.fromInt(e),t}function ie(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}J.ZERO=oe(0),J.ONE=oe(1);class se{constructor(){this.i=0,this.j=0,this.S=[]}init(e){var t,r,n;for(t=0;t<256;++t)this.S[t]=t;for(r=0,t=0;t<256;++t)r=r+this.S[t]+e[t%e.length]&255,n=this.S[t],this.S[t]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]}}var S,I,A=null;if(null==A){A=[],I=0;var T,P,O=void 0;if("undefined"!=typeof window&&null!==(T=window)&&void 0!==T&&T.crypto&&null!==(P=window)&&void 0!==P&&P.crypto.getRandomValues){var R,C=new Uint32Array(256);for(null===(R=window)||void 0===R||R.crypto.getRandomValues(C),O=0;O<C.length;++O)A[I++]=255&C[O]}var N,U,D,L=function(e){var t,r,n;if(this.count=this.count||0,this.count>=256||I>=256){if("undefined"!=typeof window)if(null!==(t=window)&&void 0!==t&&t.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",L,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",L)}}else try{var i=e.x+e.y;A[I++]=255&i,this.count+=1}catch(e){}};if("undefined"!=typeof window)if(null!==(N=window)&&void 0!==N&&N.addEventListener)null===(D=window)||void 0===D||D.addEventListener("mousemove",L,!1);else if(null!==(U=window)&&void 0!==U&&U.attachEvent){var k;null===(k=window)||void 0===k||k.attachEvent("onmousemove",L)}}function ae(){if(null==S){for(S=new se;I<256;){var e=Math.floor(65536*Math.random());A[I++]=255&e}for(S.init(A),I=0;I<A.length;++I)A[I]=0;I=0}return S.next()}class ue{constructor(){}nextBytes(e){for(var t=0;t<e.length;++t)e[t]=ae()}}function ce(e,t){if(t<e.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=e.length-1;n>=0&&t>0;){var o=e.charCodeAt(n--);o<128?r[--t]=o:o>127&&o<2048?(r[--t]=63&o|128,r[--t]=o>>6|192):(r[--t]=63&o|128,r[--t]=o>>6&63|128,r[--t]=o>>12|224)}r[--t]=0;for(var i=new ue,s=[];t>2;){for(s[0]=0;0==s[0];)i.nextBytes(s);r[--t]=s[0]}return r[--t]=2,r[--t]=0,new J(r)}class le{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(e){return e.modPowInt(this.e,this.n)}doPrivate(e){if(null==this.p||null==this.q)return e.modPow(this.d,this.n);for(var t=e.mod(this.p).modPow(this.dmp1,this.p),r=e.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(r)<0;)t=t.add(this.p);return t.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(e,t){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=Z(e,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")}encrypt(e){var t=ce(e,this.n.bitLength()+7>>3);if(null==t)return null;var r=this.doPublic(t);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n}encryptLong(e){var t=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return e.length>r?(e.match(/.{1,117}/g).forEach(function(e){var r=t.encrypt(e);n+=r}),F(n)):F(this.encrypt(e))}catch(e){return!1}}decryptLong(e){var t=this,r=this.n.bitLength()+7>>3;e=G(e);try{if(e.length>r){var n="";return e.match(/.{1,256}/g).forEach(function(e){var r=t.decrypt(e);n+=r}),n}return this.decrypt(e)}catch(e){return!1}}setPrivate(e,t,r){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=Z(e,16),this.e=parseInt(t,16),this.d=Z(r,16)):console.error("Invalid RSA private key")}setPrivateEx(e,t,r,n,o,i,s,a){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=Z(e,16),this.e=parseInt(t,16),this.d=Z(r,16),this.p=Z(n,16),this.q=Z(o,16),this.dmp1=Z(i,16),this.dmq1=Z(s,16),this.coeff=Z(a,16)):console.error("Invalid RSA private key")}generate(e,t){var r=new ue,n=e>>1;this.e=parseInt(t,16);for(var o=new J(t,16);;){for(;this.p=new J(e-n,1,r),0!=this.p.subtract(J.ONE).gcd(o).compareTo(J.ONE)||!this.p.isProbablePrime(10););for(;this.q=new J(n,1,r),0!=this.q.subtract(J.ONE).gcd(o).compareTo(J.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var i=this.p;this.p=this.q,this.q=i}var s=this.p.subtract(J.ONE),a=this.q.subtract(J.ONE),u=s.multiply(a);if(0==u.gcd(o).compareTo(J.ONE)){this.n=this.p.multiply(this.q),this.d=o.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(e){var t=Z(e,16),r=this.doPrivate(t);return null==r?null:he(r,this.n.bitLength()+7>>3)}generateAsync(e,t,r){var n=new ue,o=e>>1;this.e=parseInt(t,16);var i=new J(t,16),s=this,a=()=>{var t=()=>{if(s.p.compareTo(s.q)<=0){var e=s.p;s.p=s.q,s.q=e}var t=s.p.subtract(J.ONE),n=s.q.subtract(J.ONE),o=t.multiply(n);0==o.gcd(i).compareTo(J.ONE)?(s.n=s.p.multiply(s.q),s.d=i.modInverse(o),s.dmp1=s.d.mod(t),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout(function(){r()},0)):setTimeout(a,0)},u=()=>{s.q=X(),s.q.fromNumberAsync(o,1,n,function(){s.q.subtract(J.ONE).gcda(i,function(e){0==e.compareTo(J.ONE)&&s.q.isProbablePrime(10)?setTimeout(t,0):setTimeout(u,0)})})},c=()=>{s.p=X(),s.p.fromNumberAsync(e-o,1,n,function(){s.p.subtract(J.ONE).gcda(i,function(e){0==e.compareTo(J.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)})})};setTimeout(c,0)};setTimeout(a,0)}}function he(e,t){for(var r=e.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=t-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var o="";++n<r.length;){var i=255&r[n];i<128?o+=String.fromCharCode(i):i>191&&i<224?(o+=String.fromCharCode((31&i)<<6|63&r[n+1]),++n):(o+=String.fromCharCode((15&i)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return o}class de extends le{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),e&&("string"==typeof e?this.parseKey(e):(this.hasPrivateKeyProperty(e)||this.hasPublicKeyProperty(e))&&this.parsePropertiesFrom(e))}parseKey(e){try{var t=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(e)?u.decode(e):c.unarmor(e),o=$.decode(n);if(3===o.sub.length&&(o=o.sub[2].sub[0]),9===o.sub.length){t=o.sub[1].getHexStringValue(),this.n=Z(t,16),r=o.sub[2].getHexStringValue(),this.e=parseInt(r,16);var i=o.sub[3].getHexStringValue();this.d=Z(i,16);var s=o.sub[4].getHexStringValue();this.p=Z(s,16);var a=o.sub[5].getHexStringValue();this.q=Z(a,16);var l=o.sub[6].getHexStringValue();this.dmp1=Z(l,16);var h=o.sub[7].getHexStringValue();this.dmq1=Z(h,16);var d=o.sub[8].getHexStringValue();this.coeff=Z(d,16)}else{if(2!==o.sub.length)return!1;var f=o.sub[1].sub[0];t=f.sub[0].getHexStringValue(),this.n=Z(t,16),r=f.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(e){return!1}}hasPublicKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")}hasPrivateKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")}parsePropertiesFrom(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)}}(n=function(e){e=e||{},this.default_key_size=parseInt(e.default_key_size,10)||1024,this.default_public_exponent=e.default_public_exponent||"010001",this.log=e.log||!1,this.key=null}).prototype.setKey=function(e){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new de(e)},n.prototype.setPrivateKey=function(e){this.setKey(e)},n.prototype.setPublicKey=function(e){this.setKey(e)},n.prototype.decrypt=function(e){try{return this.getKey().decrypt(G(e))}catch(e){return!1}},n.prototype.encrypt=function(e){try{return F(this.getKey().encrypt(e))}catch(e){return!1}},n.prototype.encryptLong=function(e){try{for(var t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",n=0,o=/null$/g;o.test(r)&&(n++,t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",!(n>10)););return t}catch(e){return!1}},n.prototype.getKey=function(e){if(!this.key){if(this.key=new de,e&&"[object Function]"==={}.toString.call(e))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}const x=n},182:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(274)),c=r(616);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,o=(0,c.isArray)(e)?e:[e];r<o.length;r++){var i=o[r],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:n({isMatch:s},a(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},274:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(829),c=r(616),l=r(946),h=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,s=e.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(t).forEach(function(e){c.append(e,t[e])}),c.append("key",n),c.append("file",r),this.request(i(i({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,function(){var t,r,n,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise(function(t){t({statusCode:200,tempFilePath:e.url})})]}})})},t.prototype.fetch=function(e){var t;return s(this,void 0,void 0,function(){var r,n,o,u,c,l,h,d,f,p,v,_,m,y=this;return a(this,function(g){switch(g.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,u=void 0!==o&&o,c=e.stream,l=void 0!==c&&c,h=e.signal,d=e.timeout,f=e.shouldThrowOnError,p=void 0===f||f,v=null!=d?d:this.timeout,h&&(h.aborted&&r.abort(),h.addEventListener("abort",function(){return r.abort()})),_=null,u&&v&&(_=setTimeout(function(){console.warn(y.timeoutMsg),r.abort(new Error(y.timeoutMsg))},v)),[4,fetch(n,i(i({},e),{signal:r.signal})).then(function(e){return s(y,void 0,void 0,function(){var t,r,n;return a(this,function(o){switch(o.label){case 0:return clearTimeout(_),p?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(_),Promise.reject(e)})];case 1:return m=g.sent(),[2,{data:l?m.body:(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers,response:m}]}})})},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise(function(o){var i=e.url,s=e.headers,a=void 0===s?{}:s,u=e.data,h=e.responseType,d=e.withCredentials,f=e.body,p=e.onUploadProgress,v=(0,c.formatUrl)((0,l.getProtocol)(),i,"get"===n?u:{}),_=new XMLHttpRequest;_.open(n,v),h&&(_.responseType=h);var m,y,g=e.signal;g&&(g.aborted?_.abort():g.addEventListener("abort",function(){return _.abort()},{once:!0})),Object.keys(a).forEach(function(e){_.setRequestHeader(e,a[e])}),p&&_.upload.addEventListener("progress",p),_.onreadystatechange=function(){var e={};if(4===_.readyState){var t=_.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach(function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o}),e.header=r,e.statusCode=_.status;try{e.data="blob"===h?_.response:JSON.parse(_.responseText)}catch(t){e.data="blob"===h?_.response:_.responseText}clearTimeout(m),o(e)}},t&&r.timeout&&(m=setTimeout(function(){console.warn(r.timeoutMsg),_.abort()},r.timeout)),y=(0,c.isFormData)(u)?u:"application/x-www-form-urlencoded"===a["content-type"]?(0,c.toQueryString)(u):f||(u?JSON.stringify(u):void 0),d&&(_.withCredentials=!0),_.send(y)})},t}(u.AbstractSDKRequest);t.WebRequest=h,t.genAdapter=function(){return{type:"default",root:window,reqClass:h,wsClass:WebSocket,localStorage}}},946:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var r="@cloudbase/js-sdk";t.setSdkName=function(e){r=e},t.getSdkName=function(){return r};var n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},205:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},794:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(r(946),t),o(r(205),t),t.OATUH_LOGINTYPE="constants"},718:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=r(616),s=r(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),h=s.findIndex(function(e){return u.test(e)});if(-1!==h){var d=s.filter(function(e,t){return t>h});d.unshift(s[h].replace(l,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,h=void 0===a?{}:a,d=e.title,f=e.messages,p=void 0===f?[]:f;return function(e,t,a){if(s.IS_DEBUG_MODE){var f=h.className||e.constructor.name,v=h.methodName||t,_=a.value,m=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex(function(e){return u.test(e)});if(-1!==r){var n=c.exec(t[r+1]||"");e=n?n[0]:""}return e}();a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=l({err:new Error,className:f,methodName:v,sourceLink:m});try{return _.apply(this,e)}catch(e){var n=e,o=e.message,s=e.error,a=e.error_description,u={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=p.map(function(e){return{type:"info",body:e}}))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,function(){var t,r,n,s,a,u,c,h;return o(this,function(o){switch(o.label){case 0:t=l({err:new Error,className:f,methodName:v,sourceLink:m}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,_.apply(this,e)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(h=JSON.parse(s),c.subtitle=h,h.code&&(t?(t.code=h.code,t.message=h.msg):(r.code=h.code,r.message=h.msg),n=t||r,c.content=p.map(function(e){return{type:"info",body:e}}))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(c),n;case 4:return[2]}})})}}}}},141:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(718),t)},197:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(829),u=r(616),c=r(794),l=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage),h=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(t.root));case"none":return new l(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return i(this,void 0,void 0,function(){var n;return s(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return i(this,void 0,void 0,function(){var n;return s(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}})})},e}();t.CloudbaseCache=h},689:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(616),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return o(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,c=this.listeners[n]?i([],this.listeners[n],!0):[];o<c.length;o++)c[o].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var l=new c;t.addEventListener=function(e,t){l.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),l.fire(e,t)},t.removeEventListener=function(e,t){l.off(e,t)}},616:function(e,t,r){var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=r(794);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)})},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach(function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))}),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise(function(t,r){e=function(e,n){return e?r(e):t(n)}});return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,u=void 0!==a&&a,c=e.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,h=s;l<h.length;l++){var d=h[l],f=d.type,p=d.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)}),t},t.parseCaptcha=function(e){var r={},o=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){e=o[1];var i=o[2];i&&(r=(0,t.parseQueryString)(i))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},254:(e,t,r)=>{function n(e){this.message=e}r.r(t),r.d(t,{InvalidTokenError:()=>s,default:()=>a}),n.prototype=new Error,n.prototype.name="InvalidCharacterError";var o="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,o,i=0,s=0,a="";o=t.charAt(s++);~o&&(r=i%4?64*r+o:o,i++%4)?a+=String.fromCharCode(255&r>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return a};function i(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(o(e).replace(/(.)/g,function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}(t)}catch(e){return o(t)}}function s(e){this.message=e}s.prototype=new Error,s.prototype.name="InvalidTokenError";const a=function(e,t){if("string"!=typeof e)throw new s("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(i(e.split(".")[r]))}catch(e){throw new s("Invalid token specified: "+e.message)}}}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e].call(i.exports,i,i.exports,o),i.exports}return t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var i=Object.create(null);o.r(i);var s={};e=e||[null,t({}),t([]),t(t)];for(var a=2&n&&r;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach(e=>s[e]=()=>r[e]);return s.default=()=>r,o.d(i,s),i},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o(304)})());
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_auth",[],t):"object"==typeof exports?exports.cloudbase_auth=t():e.cloudbase_auth=t()}("undefined"!=typeof window?window:this,()=>(()=>{"use strict";var e,t,r={829:(e,t,r)=>{var n;r.r(t),r.d(t,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>n,formatUrl:()=>s}),function(e){e.local="local",e.none="none",e.session="session"}(n||(n={}));var o=function(){},i=function(){};function s(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";for(var i in r)""===o?!n&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}},882:(e,t,r)=>{r.r(t),r.d(t,{WxMpWebSocket:()=>Mn,WxRequest:()=>kn,default:()=>qn,parseQueryString:()=>jn,wxMpStorage:()=>xn});var n=r(829);function o(){}function i(e){return"object"==typeof e&&null!==e||"function"==typeof e}const s=o;function a(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch(e){}}const u=Promise,c=Promise.resolve.bind(u),l=Promise.prototype.then,h=Promise.reject.bind(u),d=c;function f(e){return new u(e)}function p(e){return f(t=>t(e))}function v(e){return h(e)}function _(e,t,r){return l.call(e,t,r)}function m(e,t,r){_(_(e,t,r),void 0,s)}function y(e,t){m(e,t)}function g(e,t){m(e,void 0,t)}function b(e,t,r){return _(e,t,r)}function E(e){_(e,void 0,s)}let w=e=>{if("function"==typeof queueMicrotask)w=queueMicrotask;else{const e=p(void 0);w=t=>_(e,t)}return w(e)};function S(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function I(e,t,r){try{return p(S(e,t,r))}catch(e){return v(e)}}class A{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(e){const t=this._back;let r=t;16383===t._elements.length&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size}shift(){const e=this._front;let t=e;const r=this._cursor;let n=r+1;const o=e._elements,i=o[r];return 16384===n&&(t=e._next,n=0),--this._size,this._cursor=n,e!==t&&(this._front=t),o[r]=void 0,i}forEach(e){let t=this._cursor,r=this._front,n=r._elements;for(;!(t===n.length&&void 0===r._next||t===n.length&&(r=r._next,n=r._elements,t=0,0===n.length));)e(n[t]),++t}peek(){const e=this._front,t=this._cursor;return e._elements[t]}}const T=Symbol("[[AbortSteps]]"),P=Symbol("[[ErrorSteps]]"),O=Symbol("[[CancelSteps]]"),R=Symbol("[[PullSteps]]"),C=Symbol("[[CanPullSyncSteps]]"),N=Symbol("[[ReleaseSteps]]");function U(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?x(e):"closed"===t._state?function(e){x(e),q(e)}(e):M(e,t._storedError)}function D(e,t){return Xr(e._ownerReadableStream,t)}function L(e){const t=e._ownerReadableStream;"readable"===t._state?j(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e){M(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"))}(e),t._readableStreamController[N](),t._reader=void 0,e._ownerReadableStream=void 0}function k(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function x(e){e._closedPromise=f((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r})}function M(e,t){x(e),j(e,t)}function j(e,t){void 0!==e._closedPromise_reject&&(E(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function q(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const B=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},W=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function H(e,t){if(void 0!==e&&"object"!=typeof(r=e)&&"function"!=typeof r)throw new TypeError(`${t} is not an object.`);var r}function V(e,t){if("function"!=typeof e)throw new TypeError(`${t} is not a function.`)}function F(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(`${t} is not an object.`)}function G(e,t,r){if(void 0===e)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function Y(e,t,r){if(void 0===e)throw new TypeError(`${t} is required in '${r}'.`)}function z(e){return Number(e)}function K(e){return 0===e?0:e}function $(e,t){const r=Number.MAX_SAFE_INTEGER;let n=Number(e);if(n=K(n),!B(n))throw new TypeError(`${t} is not a finite number`);if(n=function(e){return K(W(e))}(n),n<0||n>r)throw new TypeError(`${t} is outside the accepted range of 0 to ${r}, inclusive`);return B(n)&&0!==n?n:0}function Q(e,t){if(!Qr(e))throw new TypeError(`${t} is not a ReadableStream.`)}function J(e){return new re(e)}function X(e,t){e._reader._readRequests.push(t)}function Z(e,t,r){const n=e._reader._readRequests.shift();r?n._closeSteps():n._chunkSteps(t)}function ee(e){return e._reader._readRequests.length}function te(e){const t=e._reader;return void 0!==t&&!!ie(t)}class re{constructor(e){if(G(e,1,"ReadableStreamDefaultReader"),Q(e,"First parameter"),Jr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");U(this,e),this._readRequests=new A}get closed(){return ie(this)?this._closedPromise:v(ce("closed"))}cancel(e=void 0){return ie(this)?void 0===this._ownerReadableStream?v(k("cancel")):D(this,e):v(ce("cancel"))}read(){if(!ie(this))return v(ce("read"));if(void 0===this._ownerReadableStream)return v(k("read from"));const e=ae(this)?new oe:new ne;return se(this,e),e._promise}releaseLock(){if(!ie(this))throw ce("releaseLock");void 0!==this._ownerReadableStream&&function(e){L(e),ue(e,new TypeError("Reader was released"))}(this)}}Object.defineProperties(re.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),a(re.prototype.cancel,"cancel"),a(re.prototype.read,"read"),a(re.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(re.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});class ne{constructor(){this._promise=f((e,t)=>{this._resolvePromise=e,this._rejectPromise=t})}_chunkSteps(e){this._resolvePromise({value:e,done:!1})}_closeSteps(){this._resolvePromise({value:void 0,done:!0})}_errorSteps(e){this._rejectPromise(e)}}class oe{constructor(){this._promise=void 0}_chunkSteps(e){this._promise=d({value:e,done:!1})}_closeSteps(){this._promise=d({value:void 0,done:!0})}_errorSteps(e){this._promise=v(e)}}function ie(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof re}function se(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[R](t)}function ae(e){const t=e._ownerReadableStream;return"closed"===t._state||"errored"===t._state||t._readableStreamController[C]()}function ue(e,t){const r=e._readRequests;e._readRequests=new A,r.forEach(e=>{e._errorSteps(t)})}function ce(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}var le,he,de;function fe(e){return e.slice()}function pe(e,t,r,n,o){new Uint8Array(e).set(new Uint8Array(r,n,o),t)}let ve=e=>(ve="function"==typeof e.transfer?e=>e.transfer():"function"==typeof structuredClone?e=>structuredClone(e,{transfer:[e]}):e=>e,ve(e)),_e=e=>(_e="boolean"==typeof e.detached?e=>e.detached:e=>0===e.byteLength,_e(e));function me(e,t,r){if(e.slice)return e.slice(t,r);const n=r-t,o=new ArrayBuffer(n);return pe(o,0,e,t,n),o}function ye(e,t){const r=e[t];if(null!=r){if("function"!=typeof r)throw new TypeError(`${String(t)} is not a function`);return r}}function ge(e){try{const t=e.done,r=e.value;return _(d(r),e=>({done:t,value:e}))}catch(e){return v(e)}}const be=null!==(de=null!==(le=Symbol.asyncIterator)&&void 0!==le?le:null===(he=Symbol.for)||void 0===he?void 0:he.call(Symbol,"Symbol.asyncIterator"))&&void 0!==de?de:"@@asyncIterator";function Ee(e,t="sync",r){if(void 0===r)if("async"===t){if(void 0===(r=ye(e,be)))return function(e){const t={next(){let t;try{t=we(e)}catch(e){return v(e)}return ge(t)},return(t){let r;try{const n=ye(e.iterator,"return");if(void 0===n)return p({done:!0,value:t});r=S(n,e.iterator,[t])}catch(e){return v(e)}return i(r)?ge(r):v(new TypeError("The iterator.return() method must return an object"))}};return{iterator:t,nextMethod:t.next,done:!1}}(Ee(e,"sync",ye(e,Symbol.iterator)))}else r=ye(e,Symbol.iterator);if(void 0===r)throw new TypeError("The object is not iterable");const n=S(r,e,[]);if(!i(n))throw new TypeError("The iterator method must return an object");return{iterator:n,nextMethod:n.next,done:!1}}function we(e){const t=S(e.nextMethod,e.iterator,[]);if(!i(t))throw new TypeError("The iterator.next() method must return an object");return t}class Se{constructor(e,t){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=e,this._preventCancel=t}next(){const e=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?b(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise=this._ongoingPromise?b(this._ongoingPromise,t,t):t(),this._ongoingPromise}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const e=this._reader,t=new Ie(this);return se(e,t),t._promise}_returnSteps(e){if(this._isFinished)return Promise.resolve({value:e,done:!0});this._isFinished=!0;const t=this._reader;if(!this._preventCancel){const r=D(t,e);return L(t),b(r,()=>({value:e,done:!0}))}return L(t),p({value:e,done:!0})}}class Ie{constructor(e){this._iterator=e,this._promise=f((e,t)=>{this._resolvePromise=e,this._rejectPromise=t})}_chunkSteps(e){this._iterator._ongoingPromise=void 0,w(()=>this._resolvePromise({value:e,done:!1}))}_closeSteps(){const e=this._iterator;e._ongoingPromise=void 0,e._isFinished=!0,L(e._reader),this._resolvePromise({value:void 0,done:!0})}_errorSteps(e){const t=this._iterator;t._ongoingPromise=void 0,t._isFinished=!0,L(t._reader),this._rejectPromise(e)}}const Ae={next(){return Te(this)?this._asyncIteratorImpl.next():v(Pe("next"))},return(e){return Te(this)?this._asyncIteratorImpl.return(e):v(Pe("return"))},[be](){return this}};function Te(e){if(!i(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof Se}catch(e){return!1}}function Pe(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}Object.defineProperty(Ae,be,{enumerable:!1});const Oe=Number.isNaN||function(e){return e!=e};function Re(e){const t=me(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function Ce(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function Ne(e,t,r){if("number"!=typeof(n=r)||Oe(n)||n<0||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");var n;e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function Ue(e){e._queue=new A,e._queueTotalSize=0}function De(e){return e===DataView}function Le(e){return De(e)?1:e.BYTES_PER_ELEMENT}class ke{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!je(this))throw lt("view");return this._view}respond(e){if(!je(this))throw lt("respond");if(G(e,1,"respond"),e=$(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(_e(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");at(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!je(this))throw lt("respondWithNewView");if(G(e,1,"respondWithNewView"),!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(_e(e.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");ut(this._associatedReadableByteStreamController,e)}}Object.defineProperties(ke.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),a(ke.prototype.respond,"respond"),a(ke.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ke.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class xe{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!Me(this))throw ht("byobRequest");return it(this)}get desiredSize(){if(!Me(this))throw ht("desiredSize");return st(this)}close(){if(!Me(this))throw ht("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);tt(this)}enqueue(e){if(!Me(this))throw ht("enqueue");if(G(e,1,"enqueue"),!ArrayBuffer.isView(e))throw new TypeError("chunk must be an array buffer view");if(0===e.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===e.buffer.byteLength)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");const t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be enqueued to`);rt(this,e)}error(e=void 0){if(!Me(this))throw ht("error");nt(this,e)}[O](e){Be(this),Ue(this);const t=this._cancelAlgorithm(e);return et(this),t}[R](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void ot(this,e);const r=this._autoAllocateChunkSize;if(void 0!==r){let n;try{n=new ArrayBuffer(r)}catch(t){return void e._errorSteps(t)}const o={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(o)}X(t,e),qe(this)}[C](){return this._queueTotalSize>0}[N](){if(this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek();e.readerType="none",this._pendingPullIntos=new A,this._pendingPullIntos.push(e)}}}function Me(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof xe}function je(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof ke}function qe(e){const t=function(e){const t=e._controlledReadableByteStream;return"readable"===t._state&&(!e._closeRequested&&(!!e._started&&(!!(te(t)&&ee(t)>0)||(!!(_t(t)&&vt(t)>0)||st(e)>0))))}(e);t&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,m(e._pullAlgorithm(),()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,qe(e)),null),t=>(nt(e,t),null))))}function Be(e){Qe(e),e._pendingPullIntos=new A}function We(e,t){let r=!1;"closed"===e._state&&(r=!0);const n=Ve(t);"default"===t.readerType?Z(e,n,r):function(e,t,r){const n=e._reader._readIntoRequests.shift();r?n._closeSteps(t):n._chunkSteps(t)}(e,n,r)}function He(e,t){for(let r=0;r<t.length;++r)We(e,t[r])}function Ve(e){const t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function Fe(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function Ge(e,t,r,n){let o;try{o=me(t,r,r+n)}catch(t){throw nt(e,t),t}Fe(e,o,0,n)}function Ye(e,t){t.bytesFilled>0&&Ge(e,t.buffer,t.byteOffset,t.bytesFilled),Ze(e)}function ze(e,t){const r=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),n=t.bytesFilled+r;let o=r,i=!1;const s=n-n%t.elementSize;s>=t.minimumFill&&(o=s-t.bytesFilled,i=!0);const a=e._queue;for(;o>0;){const r=a.peek(),n=Math.min(o,r.byteLength),i=t.byteOffset+t.bytesFilled;pe(t.buffer,i,r.buffer,r.byteOffset,n),r.byteLength===n?a.shift():(r.byteOffset+=n,r.byteLength-=n),e._queueTotalSize-=n,Ke(0,n,t),o-=n}return i}function Ke(e,t,r){r.bytesFilled+=t}function $e(e){0===e._queueTotalSize&&e._closeRequested?(et(e),Zr(e._controlledReadableByteStream)):qe(e)}function Qe(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function Je(e){const t=[];for(;e._pendingPullIntos.length>0&&0!==e._queueTotalSize;){const r=e._pendingPullIntos.peek();ze(e,r)&&(Ze(e),t.push(r))}return t}function Xe(e,t){const r=e._pendingPullIntos.peek();Qe(e),"closed"===e._controlledReadableByteStream._state?function(e,t){"none"===t.readerType&&Ze(e);const r=e._controlledReadableByteStream;if(_t(r)){const t=[];for(;t.length<vt(r);)t.push(Ze(e));He(r,t)}}(e,r):function(e,t,r){if(Ke(0,t,r),"none"===r.readerType){Ye(e,r);const t=Je(e);return void He(e._controlledReadableByteStream,t)}if(r.bytesFilled<r.minimumFill)return;Ze(e);const n=r.bytesFilled%r.elementSize;if(n>0){const t=r.byteOffset+r.bytesFilled;Ge(e,r.buffer,t-n,n)}r.bytesFilled-=n;const o=Je(e);We(e._controlledReadableByteStream,r),He(e._controlledReadableByteStream,o)}(e,t,r),qe(e)}function Ze(e){return e._pendingPullIntos.shift()}function et(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function tt(e){const t=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===t._state)if(e._queueTotalSize>0)e._closeRequested=!0;else{if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(t.bytesFilled%t.elementSize!==0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw nt(e,t),t}}et(e),Zr(t)}}function rt(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const{buffer:n,byteOffset:o,byteLength:i}=t;if(_e(n))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const s=ve(n);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(_e(t.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");Qe(e),t.buffer=ve(t.buffer),"none"===t.readerType&&Ye(e,t)}te(r)?(function(e){const t=e._controlledReadableByteStream._reader;for(;t._readRequests.length>0;){if(0===e._queueTotalSize)return;ot(e,t._readRequests.shift())}}(e),0===ee(r)?Fe(e,s,o,i):(e._pendingPullIntos.length>0&&Ze(e),Z(r,new Uint8Array(s,o,i),!1))):_t(r)?(Fe(e,s,o,i),He(r,Je(e))):Fe(e,s,o,i),qe(e)}function nt(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(Be(e),Ue(e),et(e),en(r,t))}function ot(e,t){const r=e._queue.shift();e._queueTotalSize-=r.byteLength,$e(e);const n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(n)}function it(e){if(null===e._byobRequest&&e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek(),r=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),n=Object.create(ke.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(n,e,r),e._byobRequest=n}return e._byobRequest}function st(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function at(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(0===t)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=ve(r.buffer),Xe(e,t)}function ut(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t.byteLength)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(0===t.byteLength)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+t.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");const n=t.byteLength;r.buffer=ve(t.buffer),Xe(e,n)}function ct(e,t,r,n,o,i,s){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,Ue(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,t._autoAllocateChunkSize=s,t._pendingPullIntos=new A,e._readableStreamController=t,m(p(r()),()=>(t._started=!0,qe(t),null),e=>(nt(t,e),null))}function lt(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function ht(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function dt(e,t){if("byob"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function ft(e){return new mt(e)}function pt(e,t){e._reader._readIntoRequests.push(t)}function vt(e){return e._reader._readIntoRequests.length}function _t(e){const t=e._reader;return void 0!==t&&!!bt(t)}Object.defineProperties(xe.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),a(xe.prototype.close,"close"),a(xe.prototype.enqueue,"enqueue"),a(xe.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(xe.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class mt{constructor(e){if(G(e,1,"ReadableStreamBYOBReader"),Q(e,"First parameter"),Jr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!Me(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");U(this,e),this._readIntoRequests=new A}get closed(){return bt(this)?this._closedPromise:v(St("closed"))}cancel(e=void 0){return bt(this)?void 0===this._ownerReadableStream?v(k("cancel")):D(this,e):v(St("cancel"))}read(e,t={}){if(!bt(this))return v(St("read"));if(!ArrayBuffer.isView(e))return v(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return v(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return v(new TypeError("view's buffer must have non-zero byteLength"));if(_e(e.buffer))return v(new TypeError("view's buffer has been detached"));let r;try{r=function(e,t){var r;return H(e,t),{min:$(null!==(r=null==e?void 0:e.min)&&void 0!==r?r:1,`${t} has member 'min' that`)}}(t,"options")}catch(e){return v(e)}const n=r.min;if(0===n)return v(new TypeError("options.min must be greater than 0"));if(function(e){return De(e.constructor)}(e)){if(n>e.byteLength)return v(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(n>e.length)return v(new RangeError("options.min must be less than or equal to view's length"));if(void 0===this._ownerReadableStream)return v(k("read from"));const o=function(e,t,r){const n=e._ownerReadableStream;return"errored"===n._state||function(e,t,r){const n=e._controlledReadableByteStream,o=Le(t.constructor),{byteLength:i}=t,s=r*o;return!(e._pendingPullIntos.length>0)&&("closed"===n._state||e._queueTotalSize>=s)}(n._readableStreamController,t,r)}(this,e,n)?new gt:new yt;return Et(this,e,n,o),o._promise}releaseLock(){if(!bt(this))throw St("releaseLock");void 0!==this._ownerReadableStream&&function(e){L(e),wt(e,new TypeError("Reader was released"))}(this)}}Object.defineProperties(mt.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),a(mt.prototype.cancel,"cancel"),a(mt.prototype.read,"read"),a(mt.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(mt.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});class yt{constructor(){this._promise=f((e,t)=>{this._resolvePromise=e,this._rejectPromise=t})}_chunkSteps(e){this._resolvePromise({value:e,done:!1})}_closeSteps(e){this._resolvePromise({value:e,done:!0})}_errorSteps(e){this._rejectPromise(e)}}class gt{constructor(){this._promise=void 0}_chunkSteps(e){this._promise=d({value:e,done:!1})}_closeSteps(e){this._promise=d({value:e,done:!0})}_errorSteps(e){this._promise=v(e)}}function bt(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof mt}function Et(e,t,r,n){const o=e._ownerReadableStream;o._disturbed=!0,"errored"===o._state?n._errorSteps(o._storedError):function(e,t,r,n){const o=e._controlledReadableByteStream,i=t.constructor,s=Le(i),{byteOffset:a,byteLength:u}=t,c=r*s;let l;try{l=ve(t.buffer)}catch(e){return void n._errorSteps(e)}const h={buffer:l,bufferByteLength:l.byteLength,byteOffset:a,byteLength:u,bytesFilled:0,minimumFill:c,elementSize:s,viewConstructor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(h),void pt(o,n);if("closed"===o._state){const e=new i(h.buffer,h.byteOffset,0);return void n._closeSteps(e)}if(e._queueTotalSize>0){if(ze(e,h)){const t=Ve(h);return $e(e),void n._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return nt(e,t),void n._errorSteps(t)}}e._pendingPullIntos.push(h),pt(o,n),qe(e)}(o._readableStreamController,t,r,n)}function wt(e,t){const r=e._readIntoRequests;e._readIntoRequests=new A,r.forEach(e=>{e._errorSteps(t)})}function St(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function It(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(Oe(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function At(e){const{size:t}=e;return t||(()=>1)}function Tt(e,t){H(e,t);const r=null==e?void 0:e.highWaterMark,n=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:z(r),size:void 0===n?void 0:Pt(n,`${t} has member 'size' that`)}}function Pt(e,t){return V(e,t),t=>z(e(t))}function Ot(e,t,r){return V(e,r),r=>I(e,t,[r])}function Rt(e,t,r){return V(e,r),()=>I(e,t,[])}function Ct(e,t,r){return V(e,r),r=>S(e,t,[r])}function Nt(e,t,r){return V(e,r),(r,n)=>I(e,t,[r,n])}function Ut(e,t){if(!xt(e))throw new TypeError(`${t} is not a WritableStream.`)}class Dt{constructor(e={},t={}){void 0===e?e=null:F(e,"First parameter");const r=Tt(t,"Second parameter"),n=function(e,t){H(e,t);const r=null==e?void 0:e.abort,n=null==e?void 0:e.close,o=null==e?void 0:e.start,i=null==e?void 0:e.type,s=null==e?void 0:e.write;return{abort:void 0===r?void 0:Ot(r,e,`${t} has member 'abort' that`),close:void 0===n?void 0:Rt(n,e,`${t} has member 'close' that`),start:void 0===o?void 0:Ct(o,e,`${t} has member 'start' that`),write:void 0===s?void 0:Nt(s,e,`${t} has member 'write' that`),type:i}}(e,"First parameter");if(kt(this),void 0!==n.type)throw new RangeError("Invalid type is specified");const o=At(r);!function(e,t,r,n){const o=Object.create(Zt.prototype);let i,s,a,u;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.write?e=>t.write(e,o):()=>p(void 0),a=void 0!==t.close?()=>t.close():()=>p(void 0),u=void 0!==t.abort?e=>t.abort(e):()=>p(void 0),tr(e,o,i,s,a,u,r,n)}(this,n,It(r,1),o)}get locked(){if(!xt(this))throw ur("locked");return Mt(this)}abort(e=void 0){return xt(this)?Mt(this)?v(new TypeError("Cannot abort a stream that already has a writer")):jt(this,e):v(ur("abort"))}close(){return xt(this)?Mt(this)?v(new TypeError("Cannot close a stream that already has a writer")):Vt(this)?v(new TypeError("Cannot close an already-closing stream")):qt(this):v(ur("close"))}getWriter(){if(!xt(this))throw ur("getWriter");return Lt(this)}}function Lt(e){return new Yt(e)}function kt(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new A,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function xt(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof Dt}function Mt(e){return void 0!==e._writer}function jt(e,t){var r;if("closed"===e._state||"errored"===e._state)return p(void 0);e._writableStreamController._abortReason=t,null===(r=e._writableStreamController._abortController)||void 0===r||r.abort(t);const n=e._state;if("closed"===n||"errored"===n)return p(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===n&&(o=!0,t=void 0);const i=f((r,n)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=i,o||Wt(e,t),i}function qt(e){const t=e._state;if("closed"===t||"errored"===t)return v(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=f((t,r)=>{const n={_resolve:t,_reject:r};e._closeRequest=n}),n=e._writer;var o;return void 0!==n&&e._backpressure&&"writable"===t&&br(n),Ne(o=e._writableStreamController,Xt,0),or(o),r}function Bt(e,t){"writable"!==e._state?Ht(e):Wt(e,t)}function Wt(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const n=e._writer;void 0!==n&&$t(n,t),!function(e){return void 0!==e._inFlightWriteRequest||void 0!==e._inFlightCloseRequest}(e)&&r._started&&Ht(e)}function Ht(e){e._state="errored",e._writableStreamController[P]();const t=e._storedError;if(e._writeRequests.forEach(e=>{e._reject(t)}),e._writeRequests=new A,void 0===e._pendingAbortRequest)return void Ft(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void Ft(e);m(e._writableStreamController[T](r._reason),()=>(r._resolve(),Ft(e),null),t=>(r._reject(t),Ft(e),null))}function Vt(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function Ft(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&pr(t,e._storedError)}function Gt(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){_r(e)}(r):br(r)),e._backpressure=t}Object.defineProperties(Dt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),a(Dt.prototype.abort,"abort"),a(Dt.prototype.close,"close"),a(Dt.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Dt.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class Yt{constructor(e){if(G(e,1,"WritableStreamDefaultWriter"),Ut(e,"First parameter"),Mt(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;const t=e._state;if("writable"===t)!Vt(e)&&e._backpressure?_r(this):yr(this),dr(this);else if("erroring"===t)mr(this,e._storedError),dr(this);else if("closed"===t)yr(this),dr(this),vr(this);else{const t=e._storedError;mr(this,t),fr(this,t)}}get closed(){return zt(this)?this._closedPromise:v(lr("closed"))}get desiredSize(){if(!zt(this))throw lr("desiredSize");if(void 0===this._ownerWritableStream)throw hr("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:nr(t._writableStreamController)}(this)}get ready(){return zt(this)?this._readyPromise:v(lr("ready"))}abort(e=void 0){return zt(this)?void 0===this._ownerWritableStream?v(hr("abort")):function(e,t){return jt(e._ownerWritableStream,t)}(this,e):v(lr("abort"))}close(){if(!zt(this))return v(lr("close"));const e=this._ownerWritableStream;return void 0===e?v(hr("close")):Vt(e)?v(new TypeError("Cannot close an already-closing stream")):Kt(this)}releaseLock(){if(!zt(this))throw lr("releaseLock");void 0!==this._ownerWritableStream&&Qt(this)}write(e=void 0){return zt(this)?void 0===this._ownerWritableStream?v(hr("write to")):Jt(this,e):v(lr("write"))}}function zt(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof Yt}function Kt(e){return qt(e._ownerWritableStream)}function $t(e,t){"pending"===e._readyPromiseState?gr(e,t):function(e,t){mr(e,t)}(e,t)}function Qt(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");$t(e,r),function(e,t){"pending"===e._closedPromiseState?pr(e,t):function(e,t){fr(e,t)}(e,t)}(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function Jt(e,t){const r=e._ownerWritableStream,n=r._writableStreamController,o=function(e,t){if(void 0===e._strategySizeAlgorithm)return 1;try{return e._strategySizeAlgorithm(t)}catch(t){return ir(e,t),1}}(n,t);if(r!==e._ownerWritableStream)return v(hr("write to"));const i=r._state;if("errored"===i)return v(r._storedError);if(Vt(r)||"closed"===i)return v(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return v(r._storedError);const s=function(e){return f((t,r)=>{const n={_resolve:t,_reject:r};e._writeRequests.push(n)})}(r);return function(e,t,r){try{Ne(e,t,r)}catch(t){return void ir(e,t)}const n=e._controlledWritableStream;Vt(n)||"writable"!==n._state||Gt(n,sr(e)),or(e)}(n,t,o),s}Object.defineProperties(Yt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),a(Yt.prototype.abort,"abort"),a(Yt.prototype.close,"close"),a(Yt.prototype.releaseLock,"releaseLock"),a(Yt.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Yt.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Xt={};class Zt{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!er(this))throw cr("abortReason");return this._abortReason}get signal(){if(!er(this))throw cr("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(e=void 0){if(!er(this))throw cr("error");"writable"===this._controlledWritableStream._state&&ar(this,e)}[T](e){const t=this._abortAlgorithm(e);return rr(this),t}[P](){Ue(this)}}function er(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof Zt}function tr(e,t,r,n,o,i,s,a){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,Ue(t),t._abortReason=void 0,t._abortController=function(){if("function"==typeof AbortController)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=a,t._strategyHWM=s,t._writeAlgorithm=n,t._closeAlgorithm=o,t._abortAlgorithm=i;const u=sr(t);Gt(e,u),m(p(r()),()=>(t._started=!0,or(t),null),r=>(t._started=!0,Bt(e,r),null))}function rr(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function nr(e){return e._strategyHWM-e._queueTotalSize}function or(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void Ht(t);if(0===e._queue.length)return;const r=e._queue.peek().value;r===Xt?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),Ce(e);const r=e._closeAlgorithm();rr(e),m(r,()=>(function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const t=e._writer;void 0!==t&&vr(t)}(t),null),e=>(function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),Bt(e,t)}(t,e),null))}(e):function(e,t){const r=e._controlledWritableStream;!function(e){e._inFlightWriteRequest=e._writeRequests.shift()}(r),m(e._writeAlgorithm(t),()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(Ce(e),!Vt(r)&&"writable"===t){const t=sr(e);Gt(r,t)}return or(e),null},t=>("writable"===r._state&&rr(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,Bt(e,t)}(r,t),null))}(e,r)}function ir(e,t){"writable"===e._controlledWritableStream._state&&ar(e,t)}function sr(e){return nr(e)<=0}function ar(e,t){const r=e._controlledWritableStream;rr(e),Wt(r,t)}function ur(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function cr(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function lr(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function hr(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function dr(e){e._closedPromise=f((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"})}function fr(e,t){dr(e),pr(e,t)}function pr(e,t){void 0!==e._closedPromise_reject&&(E(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function vr(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function _r(e){e._readyPromise=f((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r}),e._readyPromiseState="pending"}function mr(e,t){_r(e),gr(e,t)}function yr(e){_r(e),br(e)}function gr(e,t){void 0!==e._readyPromise_reject&&(E(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function br(e){void 0!==e._readyPromise_resolve&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}Object.defineProperties(Zt.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Zt.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const Er="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0,wr=function(){const e=null==Er?void 0:Er.DOMException;return function(e){if("function"!=typeof e&&"object"!=typeof e)return!1;if("DOMException"!==e.name)return!1;try{return new e,!0}catch(e){return!1}}(e)?e:void 0}()||function(){const e=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return a(e,"DOMException"),e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}();function Sr(e,t,r,n,o,i){const s=J(e),a=Lt(t);e._disturbed=!0;const u=new Ir(a),c=new Tr(u);return f((l,h)=>{let d;if(void 0!==i){if(d=()=>{const r=void 0!==i.reason?i.reason:new wr("Aborted","AbortError"),s=[];n||s.push(()=>"writable"===t._state?jt(t,r):p(void 0)),o||s.push(()=>"readable"===e._state?Xr(e,r):p(void 0)),I(()=>Promise.all(s.map(e=>e())),!0,r)},i.aborted)return void d();i.addEventListener("abort",d)}function g(){for(;!u._shuttingDown&&!t._backpressure&&"writable"===t._state&&!Vt(t)&&"readable"===e._state&&ae(s);)se(s,c);if(u._shuttingDown)return p(!0);if(t._backpressure)return _(a._readyPromise,g);const r=new Ar(u);return se(s,r),r._promise}var b,w,S;if(Pr(e,s._closedPromise,e=>(n?A(!0,e):I(()=>jt(t,e),!0,e),null)),Pr(t,a._closedPromise,t=>(o?A(!0,t):I(()=>Xr(e,t),!0,t),null)),b=e,w=s._closedPromise,S=()=>(r?A():I(()=>function(e){const t=e._ownerWritableStream,r=t._state;return Vt(t)||"closed"===r?p(void 0):"errored"===r?v(t._storedError):Kt(e)}(a)),null),"closed"===b._state?S():y(w,S),Vt(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");o?A(!0,t):I(()=>Xr(e,t),!0,t)}function I(e,r,n){function o(){return m(e(),()=>T(r,n),e=>T(!0,e)),null}u._shuttingDown||(u._shuttingDown=!0,"writable"!==t._state||Vt(t)?o():y(u._waitForWritesToFinish(),o))}function A(e,r){u._shuttingDown||(u._shuttingDown=!0,"writable"!==t._state||Vt(t)?T(e,r):y(u._waitForWritesToFinish(),()=>T(e,r)))}function T(e,t){return Qt(a),L(s),void 0!==i&&i.removeEventListener("abort",d),e?h(t):l(void 0),null}E(f((e,t)=>{!function r(n){n?e():_(g(),r,t)}(!1)}))})}class Ir{constructor(e){this._writer=e,this._shuttingDown=!1,this._currentWrite=p(void 0)}_waitForWritesToFinish(){const e=this._currentWrite;return _(this._currentWrite,()=>e!==this._currentWrite?this._waitForWritesToFinish():void 0)}}class Ar{constructor(e){this._state=e,this._promise=f((e,t)=>{this._resolvePromise=e,this._rejectPromise=t})}_chunkSteps(e){this._state._currentWrite=_(Jt(this._state._writer,e),void 0,o),this._resolvePromise(!1)}_closeSteps(){this._resolvePromise(!0)}_errorSteps(e){this._rejectPromise(e)}}class Tr{constructor(e){this._state=e}_chunkSteps(e){this._state._currentWrite=_(Jt(this._state._writer,e),void 0,o)}_closeSteps(){}_errorSteps(e){}}function Pr(e,t,r){"errored"===e._state?r(e._storedError):g(t,r)}class Or{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!Rr(this))throw qr("desiredSize");return xr(this)}close(){if(!Rr(this))throw qr("close");if(!Mr(this))throw new TypeError("The stream is not in a state that permits close");Dr(this)}enqueue(e=void 0){if(!Rr(this))throw qr("enqueue");if(!Mr(this))throw new TypeError("The stream is not in a state that permits enqueue");return Lr(this,e)}error(e=void 0){if(!Rr(this))throw qr("error");kr(this,e)}[O](e){Ue(this);const t=this._cancelAlgorithm(e);return Ur(this),t}[R](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=Ce(this);this._closeRequested&&0===this._queue.length?(Ur(this),Zr(t)):Cr(this),e._chunkSteps(r)}else X(t,e),Cr(this)}[C](){return this._queue.length>0}[N](){}}function Rr(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")&&e instanceof Or}function Cr(e){Nr(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,m(e._pullAlgorithm(),()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,Cr(e)),null),t=>(kr(e,t),null))))}function Nr(e){const t=e._controlledReadableStream;return!!Mr(e)&&!!e._started&&(!!(Jr(t)&&ee(t)>0)||xr(e)>0)}function Ur(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Dr(e){if(!Mr(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Ur(e),Zr(t))}function Lr(e,t){if(!Mr(e))return;const r=e._controlledReadableStream;if(Jr(r)&&ee(r)>0)Z(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw kr(e,t),t}try{Ne(e,t,r)}catch(t){throw kr(e,t),t}}Cr(e)}function kr(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(Ue(e),Ur(e),en(r,t))}function xr(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Mr(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function jr(e,t,r,n,o,i,s){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,Ue(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=s,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,e._readableStreamController=t,m(p(r()),()=>(t._started=!0,Cr(t),null),e=>(kr(t,e),null))}function qr(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function Br(e){return i(t=e)&&void 0!==t.getReader?function(e){let t;return t=zr(o,function(){let r;try{r=e.read()}catch(r){return v(r)}return b(r,e=>{if(!i(e))throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");if(e.done)Dr(t._readableStreamController);else{const r=e.value;Lr(t._readableStreamController,r)}})},function(t){try{return p(e.cancel(t))}catch(t){return v(t)}},0),t}(e.getReader()):function(e){let t;const r=Ee(e,"async");return t=zr(o,function(){let e;try{e=we(r)}catch(e){return v(e)}return b(p(e),e=>{if(!i(e))throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");if(e.done)Dr(t._readableStreamController);else{const r=e.value;Lr(t._readableStreamController,r)}})},function(e){const t=r.iterator;let n;try{n=ye(t,"return")}catch(e){return v(e)}return void 0===n?p(void 0):b(I(n,t,[e]),e=>{if(!i(e))throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")})},0),t}(e);var t}function Wr(e,t,r){return V(e,r),r=>I(e,t,[r])}function Hr(e,t,r){return V(e,r),r=>I(e,t,[r])}function Vr(e,t,r){return V(e,r),r=>S(e,t,[r])}function Fr(e,t){if("bytes"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function Gr(e,t){H(e,t);const r=null==e?void 0:e.preventAbort,n=null==e?void 0:e.preventCancel,o=null==e?void 0:e.preventClose,i=null==e?void 0:e.signal;return void 0!==i&&function(e,t){if(!function(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}(e))throw new TypeError(`${t} is not an AbortSignal.`)}(i,`${t} has member 'signal' that`),{preventAbort:Boolean(r),preventCancel:Boolean(n),preventClose:Boolean(o),signal:i}}Object.defineProperties(Or.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),a(Or.prototype.close,"close"),a(Or.prototype.enqueue,"enqueue"),a(Or.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Or.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class Yr{constructor(e={},t={}){void 0===e?e=null:F(e,"First parameter");const r=Tt(t,"Second parameter"),n=function(e,t){H(e,t);const r=e,n=null==r?void 0:r.autoAllocateChunkSize,o=null==r?void 0:r.cancel,i=null==r?void 0:r.pull,s=null==r?void 0:r.start,a=null==r?void 0:r.type;return{autoAllocateChunkSize:void 0===n?void 0:$(n,`${t} has member 'autoAllocateChunkSize' that`),cancel:void 0===o?void 0:Wr(o,r,`${t} has member 'cancel' that`),pull:void 0===i?void 0:Hr(i,r,`${t} has member 'pull' that`),start:void 0===s?void 0:Vr(s,r,`${t} has member 'start' that`),type:void 0===a?void 0:Fr(a,`${t} has member 'type' that`)}}(e,"First parameter");if($r(this),"bytes"===n.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");!function(e,t,r){const n=Object.create(xe.prototype);let o,i,s;o=void 0!==t.start?()=>t.start(n):()=>{},i=void 0!==t.pull?()=>t.pull(n):()=>p(void 0),s=void 0!==t.cancel?e=>t.cancel(e):()=>p(void 0);const a=t.autoAllocateChunkSize;if(0===a)throw new TypeError("autoAllocateChunkSize must be greater than 0");ct(e,n,o,i,s,r,a)}(this,n,It(r,0))}else{const e=At(r);!function(e,t,r,n){const o=Object.create(Or.prototype);let i,s,a;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.pull?()=>t.pull(o):()=>p(void 0),a=void 0!==t.cancel?e=>t.cancel(e):()=>p(void 0),jr(e,o,i,s,a,r,n)}(this,n,It(r,1),e)}}get locked(){if(!Qr(this))throw tn("locked");return Jr(this)}cancel(e=void 0){return Qr(this)?Jr(this)?v(new TypeError("Cannot cancel a stream that already has a reader")):Xr(this,e):v(tn("cancel"))}getReader(e=void 0){if(!Qr(this))throw tn("getReader");return void 0===function(e,t){H(e,t);const r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:dt(r,`${t} has member 'mode' that`)}}(e,"First parameter").mode?J(this):ft(this)}pipeThrough(e,t={}){if(!Qr(this))throw tn("pipeThrough");G(e,1,"pipeThrough");const r=function(e,t){H(e,t);const r=null==e?void 0:e.readable;Y(r,"readable","ReadableWritablePair"),Q(r,`${t} has member 'readable' that`);const n=null==e?void 0:e.writable;return Y(n,"writable","ReadableWritablePair"),Ut(n,`${t} has member 'writable' that`),{readable:r,writable:n}}(e,"First parameter"),n=Gr(t,"Second parameter");if(Jr(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Mt(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return E(Sr(this,r.writable,n.preventClose,n.preventAbort,n.preventCancel,n.signal)),r.readable}pipeTo(e,t={}){if(!Qr(this))return v(tn("pipeTo"));if(void 0===e)return v("Parameter 1 is required in 'pipeTo'.");if(!xt(e))return v(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let r;try{r=Gr(t,"Second parameter")}catch(e){return v(e)}return Jr(this)?v(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Mt(e)?v(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Sr(this,e,r.preventClose,r.preventAbort,r.preventCancel,r.signal)}tee(){if(!Qr(this))throw tn("tee");return fe(function(e){return Me(e._readableStreamController)?function(e){let t,r,n,o,i,s=J(e),a=!1,u=!1,c=!1,l=!1,h=!1;const d=f(e=>{i=e});function v(e){g(e._closedPromise,t=>(e!==s||(nt(n._readableStreamController,t),nt(o._readableStreamController,t),l&&h||i(void 0)),null))}function _(){bt(s)&&(L(s),s=J(e),v(s)),se(s,{_chunkSteps:t=>{w(()=>{u=!1,c=!1;const r=t;let s=t;if(!l&&!h)try{s=Re(t)}catch(t){return nt(n._readableStreamController,t),nt(o._readableStreamController,t),void i(Xr(e,t))}l||rt(n._readableStreamController,r),h||rt(o._readableStreamController,s),a=!1,u?y():c&&b()})},_closeSteps:()=>{a=!1,l||tt(n._readableStreamController),h||tt(o._readableStreamController),n._readableStreamController._pendingPullIntos.length>0&&at(n._readableStreamController,0),o._readableStreamController._pendingPullIntos.length>0&&at(o._readableStreamController,0),l&&h||i(void 0)},_errorSteps:()=>{a=!1}})}function m(t,r){ie(s)&&(L(s),s=ft(e),v(s));const d=r?o:n,f=r?n:o;Et(s,t,1,{_chunkSteps:t=>{w(()=>{u=!1,c=!1;const n=r?h:l;if(r?l:h)n||ut(d._readableStreamController,t);else{let r;try{r=Re(t)}catch(t){return nt(d._readableStreamController,t),nt(f._readableStreamController,t),void i(Xr(e,t))}n||ut(d._readableStreamController,t),rt(f._readableStreamController,r)}a=!1,u?y():c&&b()})},_closeSteps:e=>{a=!1;const t=r?h:l,n=r?l:h;t||tt(d._readableStreamController),n||tt(f._readableStreamController),void 0!==e&&(t||ut(d._readableStreamController,e),!n&&f._readableStreamController._pendingPullIntos.length>0&&at(f._readableStreamController,0)),t&&n||i(void 0)},_errorSteps:()=>{a=!1}})}function y(){if(a)return u=!0,p(void 0);a=!0;const e=it(n._readableStreamController);return null===e?_():m(e._view,!1),p(void 0)}function b(){if(a)return c=!0,p(void 0);a=!0;const e=it(o._readableStreamController);return null===e?_():m(e._view,!0),p(void 0)}function E(){}return n=Kr(E,y,function(n){if(l=!0,t=n,h){const n=fe([t,r]),o=Xr(e,n);i(o)}return d}),o=Kr(E,b,function(n){if(h=!0,r=n,l){const n=fe([t,r]),o=Xr(e,n);i(o)}return d}),v(s),[n,o]}(e):function(e){const t=J(e);let r,n,o,i,s,a=!1,u=!1,c=!1,l=!1;const h=f(e=>{s=e});function d(){return a?(u=!0,p(void 0)):(a=!0,se(t,{_chunkSteps:e=>{w(()=>{u=!1;const t=e,r=e;c||Lr(o._readableStreamController,t),l||Lr(i._readableStreamController,r),a=!1,u&&d()})},_closeSteps:()=>{a=!1,c||Dr(o._readableStreamController),l||Dr(i._readableStreamController),c&&l||s(void 0)},_errorSteps:()=>{a=!1}}),p(void 0))}function v(){}return o=zr(v,d,function(t){if(c=!0,r=t,l){const t=fe([r,n]),o=Xr(e,t);s(o)}return h}),i=zr(v,d,function(t){if(l=!0,n=t,c){const t=fe([r,n]),o=Xr(e,t);s(o)}return h}),g(t._closedPromise,e=>(kr(o._readableStreamController,e),kr(i._readableStreamController,e),c&&l||s(void 0),null)),[o,i]}(e)}(this))}values(e=void 0){if(!Qr(this))throw tn("values");return function(e,t){const r=J(e),n=new Se(r,t),o=Object.create(Ae);return o._asyncIteratorImpl=n,o}(this,function(e){H(e,"First parameter");const t=null==e?void 0:e.preventCancel;return{preventCancel:Boolean(t)}}(e).preventCancel)}[be](e){return this.values(e)}static from(e){return Br(e)}}function zr(e,t,r,n=1,o=()=>1){const i=Object.create(Yr.prototype);return $r(i),jr(i,Object.create(Or.prototype),e,t,r,n,o),i}function Kr(e,t,r){const n=Object.create(Yr.prototype);return $r(n),ct(n,Object.create(xe.prototype),e,t,r,0,void 0),n}function $r(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function Qr(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")&&e instanceof Yr}function Jr(e){return void 0!==e._reader}function Xr(e,t){if(e._disturbed=!0,"closed"===e._state)return p(void 0);if("errored"===e._state)return v(e._storedError);Zr(e);const r=e._reader;if(void 0!==r&&bt(r)){const e=r._readIntoRequests;r._readIntoRequests=new A,e.forEach(e=>{e._closeSteps(void 0)})}return b(e._readableStreamController[O](t),o)}function Zr(e){e._state="closed";const t=e._reader;if(void 0!==t&&(q(t),ie(t))){const e=t._readRequests;t._readRequests=new A,e.forEach(e=>{e._closeSteps()})}}function en(e,t){e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(j(r,t),ie(r)?ue(r,t):wt(r,t))}function tn(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function rn(e,t){H(e,t);const r=null==e?void 0:e.highWaterMark;return Y(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:z(r)}}Object.defineProperties(Yr,{from:{enumerable:!0}}),Object.defineProperties(Yr.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),a(Yr.from,"from"),a(Yr.prototype.cancel,"cancel"),a(Yr.prototype.getReader,"getReader"),a(Yr.prototype.pipeThrough,"pipeThrough"),a(Yr.prototype.pipeTo,"pipeTo"),a(Yr.prototype.tee,"tee"),a(Yr.prototype.values,"values"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Yr.prototype,Symbol.toStringTag,{value:"ReadableStream",configurable:!0}),Object.defineProperty(Yr.prototype,be,{value:Yr.prototype.values,writable:!0,configurable:!0});const nn=e=>e.byteLength;a(nn,"size");class on{constructor(e){G(e,1,"ByteLengthQueuingStrategy"),e=rn(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!an(this))throw sn("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!an(this))throw sn("size");return nn}}function sn(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function an(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")&&e instanceof on}Object.defineProperties(on.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(on.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const un=()=>1;a(un,"size");class cn{constructor(e){G(e,1,"CountQueuingStrategy"),e=rn(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!hn(this))throw ln("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!hn(this))throw ln("size");return un}}function ln(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function hn(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")&&e instanceof cn}function dn(e,t,r){return V(e,r),r=>I(e,t,[r])}function fn(e,t,r){return V(e,r),r=>S(e,t,[r])}function pn(e,t,r){return V(e,r),(r,n)=>I(e,t,[r,n])}function vn(e,t,r){return V(e,r),r=>I(e,t,[r])}Object.defineProperties(cn.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(cn.prototype,Symbol.toStringTag,{value:"CountQueuingStrategy",configurable:!0});class _n{constructor(e={},t={},r={}){void 0===e&&(e=null);const n=Tt(t,"Second parameter"),o=Tt(r,"Third parameter"),i=function(e,t){H(e,t);const r=null==e?void 0:e.cancel,n=null==e?void 0:e.flush,o=null==e?void 0:e.readableType,i=null==e?void 0:e.start,s=null==e?void 0:e.transform,a=null==e?void 0:e.writableType;return{cancel:void 0===r?void 0:vn(r,e,`${t} has member 'cancel' that`),flush:void 0===n?void 0:dn(n,e,`${t} has member 'flush' that`),readableType:o,start:void 0===i?void 0:fn(i,e,`${t} has member 'start' that`),transform:void 0===s?void 0:pn(s,e,`${t} has member 'transform' that`),writableType:a}}(e,"First parameter");if(void 0!==i.readableType)throw new RangeError("Invalid readableType specified");if(void 0!==i.writableType)throw new RangeError("Invalid writableType specified");const s=It(o,0),a=At(o),u=It(n,1),c=At(n);let l;!function(e,t,r,n,o,i){function s(){return t}e._writable=function(e,t,r,n,o=1,i=()=>1){const s=Object.create(Dt.prototype);return kt(s),tr(s,Object.create(Zt.prototype),e,t,r,n,o,i),s}(s,function(t){return function(e,t){const r=e._transformStreamController;return e._backpressure?b(e._backpressureChangePromise,()=>{const n=e._writable;if("erroring"===n._state)throw n._storedError;return Tn(r,t)}):Tn(r,t)}(e,t)},function(){return function(e){const t=e._transformStreamController;if(void 0!==t._finishPromise)return t._finishPromise;const r=e._readable;t._finishPromise=f((e,r)=>{t._finishPromise_resolve=e,t._finishPromise_reject=r});const n=t._flushAlgorithm();return In(t),m(n,()=>("errored"===r._state?Rn(t,r._storedError):(Dr(r._readableStreamController),On(t)),null),e=>(kr(r._readableStreamController,e),Rn(t,e),null)),t._finishPromise}(e)},function(t){return function(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=e._readable;r._finishPromise=f((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t});const o=r._cancelAlgorithm(t);return In(r),m(o,()=>("errored"===n._state?Rn(r,n._storedError):(kr(n._readableStreamController,t),On(r)),null),e=>(kr(n._readableStreamController,e),Rn(r,e),null)),r._finishPromise}(e,t)},r,n),e._readable=zr(s,function(){return function(e){return En(e,!1),e._backpressureChangePromise}(e)},function(t){return function(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=e._writable;r._finishPromise=f((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t});const o=r._cancelAlgorithm(t);return In(r),m(o,()=>("errored"===n._state?Rn(r,n._storedError):(ir(n._writableStreamController,t),bn(e),On(r)),null),t=>(ir(n._writableStreamController,t),bn(e),Rn(r,t),null)),r._finishPromise}(e,t)},o,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,En(e,!0),e._transformStreamController=void 0}(this,f(e=>{l=e}),u,c,s,a),function(e,t){const r=Object.create(wn.prototype);let n,o,i;n=void 0!==t.transform?e=>t.transform(e,r):e=>{try{return An(r,e),p(void 0)}catch(e){return v(e)}},o=void 0!==t.flush?()=>t.flush(r):()=>p(void 0),i=void 0!==t.cancel?e=>t.cancel(e):()=>p(void 0),function(e,t,r,n,o){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=n,t._cancelAlgorithm=o,t._finishPromise=void 0,t._finishPromise_resolve=void 0,t._finishPromise_reject=void 0}(e,r,n,o,i)}(this,i),void 0!==i.start?l(i.start(this._transformStreamController)):l(void 0)}get readable(){if(!mn(this))throw Cn("readable");return this._readable}get writable(){if(!mn(this))throw Cn("writable");return this._writable}}function mn(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")&&e instanceof _n}function yn(e,t){kr(e._readable._readableStreamController,t),gn(e,t)}function gn(e,t){In(e._transformStreamController),ir(e._writable._writableStreamController,t),bn(e)}function bn(e){e._backpressure&&En(e,!1)}function En(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=f(t=>{e._backpressureChangePromise_resolve=t}),e._backpressure=t}Object.defineProperties(_n.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(_n.prototype,Symbol.toStringTag,{value:"TransformStream",configurable:!0});class wn{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!Sn(this))throw Pn("desiredSize");return xr(this._controlledTransformStream._readable._readableStreamController)}enqueue(e=void 0){if(!Sn(this))throw Pn("enqueue");An(this,e)}error(e=void 0){if(!Sn(this))throw Pn("error");var t;t=e,yn(this._controlledTransformStream,t)}terminate(){if(!Sn(this))throw Pn("terminate");!function(e){const t=e._controlledTransformStream;Dr(t._readable._readableStreamController),gn(t,new TypeError("TransformStream terminated"))}(this)}}function Sn(e){return!!i(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")&&e instanceof wn}function In(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0,e._cancelAlgorithm=void 0}function An(e,t){const r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!Mr(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{Lr(n,t)}catch(e){throw gn(r,e),r._readable._storedError}const o=function(e){return!Nr(e)}(n);o!==r._backpressure&&En(r,!0)}function Tn(e,t){return b(e._transformAlgorithm(t),void 0,t=>{throw yn(e._controlledTransformStream,t),t})}function Pn(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function On(e){void 0!==e._finishPromise_resolve&&(e._finishPromise_resolve(),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function Rn(e,t){void 0!==e._finishPromise_reject&&(E(e._finishPromise),e._finishPromise_reject(t),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function Cn(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}Object.defineProperties(wn.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),a(wn.prototype.enqueue,"enqueue"),a(wn.prototype.error,"error"),a(wn.prototype.terminate,"terminate"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(wn.prototype,Symbol.toStringTag,{value:"TransformStreamDefaultController",configurable:!0});var Nn,Un=(Nn=function(e,t){return Nn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},Nn(e,t)},function(e,t){function r(){this.constructor=e}Nn(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),Dn=function(){return Dn=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Dn.apply(this,arguments)},Ln="Error when aborting requestTask",kn=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=o||"请求超时",r._restrictedMethods=i||["get","post","upload","download"],r}return Un(t,e),t.prototype.post=function(e){var t=this;return new Promise(function(r,o){var i=e.url,s=e.data,a=e.headers,u=wx.request({url:(0,n.formatUrl)("https:",i),data:s,timeout:t._timeout,method:"POST",header:a,success:function(e){e.statusCode>=200&&e.statusCode<300?r({statusCode:e.statusCode,status:e.statusCode,data:e.data}):o(e)},fail:function(e){o(e)},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("post")&&"request:fail timeout"===e.errMsg){console.warn(t._timeoutMsg);try{u.abort()}catch(e){}}}})})},t.prototype.get=function(e){var t=this;return new Promise(function(r,o){var i=e.url,s=e.body,a=e.headers,u=(0,n.formatUrl)("https:",i),c=wx.request({url:u,data:s,timeout:t._timeout,method:"GET",header:a,success:function(e){e.statusCode>=200&&e.statusCode<300?r({statusCode:e.statusCode,status:e.statusCode,data:e.data}):o(e)},fail:function(e){o(e)},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("get")&&e.errMsg.includes("timeout")){console.warn(t._timeoutMsg);try{c.abort()}catch(e){console.warn(Ln,e)}}}})})},t.prototype.upload=function(e){var t=this,r=this;return new Promise(function(n){return function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})}(t,void 0,void 0,function(){var t,o,i,s,a,u;return function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,function(c){return t=e.url,o=e.file,i=e.data,s=e.headers,a=e.onUploadProgress,u=wx.uploadFile({url:t,filePath:o,name:"file",formData:Dn({},i),header:s,timeout:this._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(t.statusCode=parseInt(i.success_action_status,10)),n(t)},fail:function(e){n(e)},complete:function(e){if(e&&e.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{u.abort()}catch(e){}}}}),a&&u.onProgressUpdate(function(e){a(e)}),[2]})})})},t.prototype.download=function(e){var t=this,r=this;return new Promise(function(o,i){var s=e.url,a=e.headers,u=wx.downloadFile({url:(0,n.formatUrl)("https:",s),header:a,timeout:t._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?o({statusCode:200,tempFilePath:e.tempFilePath}):o(e)},fail:function(e){i(e)},complete:function(e){if(e&&e.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("download")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{u.abort()}catch(e){}}}})})},t.prototype.fetch=function(e){var t=e.url,r=e.body,o=e.enableAbort,i=e.headers,s=e.method,a=e.stream,u=void 0!==a&&a,c=e.signal,l=e.timeout,h=this,d=null!=l?l:this._timeout,f=null,p=new Yr({start:function(e){f=e},cancel:function(){f=null}});return new Promise(function(e,a){u&&e({data:p});var l=wx.request({url:(0,n.formatUrl)("https:",t),data:r,timeout:d,method:s.toUpperCase(),header:i,success:function(t){null==f||f.close(),!u&&e(t)},fail:function(e){if(null==f||f.close(),a(e),u)throw e},complete:function(e){if(e&&e.errMsg&&d&&-1!==h._restrictedMethods.indexOf("post")&&o&&"request:fail timeout"===e.errMsg){console.warn(h._timeoutMsg);try{l.abort()}catch(e){console.warn(Ln,e)}}},enableChunked:u});if(l.onChunkReceived(function(e){null==f||f.enqueue(new Uint8Array(e.data))}),c){var v=function(){try{l.abort()}catch(e){console.warn(Ln,e)}};c.aborted?v():c.addEventListener("abort",function(){return v()})}})},t.prototype.patch=function(e){var t=e.method,r=e.headers,n=JSON.parse(JSON.stringify(r||{}));return"PATCH"===t.toUpperCase()&&(n["X-HTTP-Method-Override"]="PATCH",t="POST"),this.post(Dn(Dn({},e),{method:t,headers:n}))},t}(n.AbstractSDKRequest),xn={setItem:function(e,t){wx.setStorageSync(e,t)},getItem:function(e){return wx.getStorageSync(e)},removeItem:function(e){wx.removeStorageSync(e)},clear:function(){wx.clearStorageSync()}},Mn=function(e,t){void 0===t&&(t={});var r=wx.connectSocket(Dn({url:e},t));return{set onopen(e){r.onOpen(e)},set onmessage(e){r.onMessage(e)},set onclose(e){r.onClose(e)},set onerror(e){r.onError(e)},send:function(e){return r.send({data:e})},close:function(e,t){return r.close({code:e,reason:t})},get readyState(){return r.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};function jn(e){var t={},r=e.replace(/^[?#]/,"");return r?(r.split("&").forEach(function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)}),t):t}const qn={genAdapter:function(e){return{root:{globalThis:{}},reqClass:kn,wsClass:Mn,captchaOptions:{openURIWithCallback:function(t){var r=e.EventBus,n={},o=t;console.log("openURIWithCallback",t);var i=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){o=i[1],console.log("openURIWithCallback url",o);var s=i[2];s&&(n=jn(s))}console.log("openURIWithCallback queryObj",n);var a=n.token,u=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(n,["token"]);return/^data:/.test(o)&&!a?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: "+t}):a?new Promise(function(e){console.log("wait for captcha..."),r.$emit("CAPTCHA_DATA_CHANGE",Dn(Dn({},u),{token:a,url:o})),r.$once("RESOLVE_CAPTCHA_DATA",function(t){e(t)})}):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:xn,primaryStorage:n.StorageType.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(e){return!1}return!0},runtime:"wx_mp"}},548:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.useAuthAdapter=void 0;var s=r(19),a=function(){function e(e){var t,r;try{this.localStorage=(null==e?void 0:e.localStorage)||((null===(r=null===(t=null==e?void 0:e.adapter)||void 0===t?void 0:t.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(t){this.localStorage=(null==e?void 0:e.localStorage)||{}}}return e.prototype.getItem=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.localStorage.getItem(e)]})})},e.prototype.removeItem=function(e){return o(this,void 0,void 0,function(){return i(this,function(t){return this.localStorage.removeItem(e),[2]})})},e.prototype.setItem=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(r){return this.localStorage.setItem(e,t),[2]})})},e.prototype.getItemSync=function(e){return this.localStorage.getItem(e)},e.prototype.setItemSync=function(e,t){this.localStorage.setItem(e,t)},e.prototype.removeItemSync=function(e){this.localStorage.removeItem(e)},e}(),u=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,c=function(e,t){var r,n,o,i,s=null===(r=null==t?void 0:t.headers)||void 0===r?void 0:r["x-request-id"];return e||(e={}),((null==e?void 0:e.code)||(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.error_code))&&(e={error:e.code||e.data.error,error_description:e.data.error_description||e.message||e.code||e.data.error_code,request_id:e.requestId,error_code:null===(o=e.data)||void 0===o?void 0:o.error_code}),(null==e?void 0:e.request_id)||(e.request_id=e.request_id||s),(null==e?void 0:e.error)?(e.error_uri=(i=null==t?void 0:t.url,u.test(i)?RegExp.$1:i),e):(null==e?void 0:e.data)||{}};t.useAuthAdapter=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var r=n({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(r.storage=new a({localStorage:t.localStorage,adapter:t})),!e.captchaOptions&&(null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!e.baseRequest&&!e.request&&(null==t?void 0:t.reqClass)){var s={timeout:1e4,restrictedMethods:["get","post","upload","download","request"],auth:e.auth},u=new t.reqClass(s);r.baseRequest=function(e,t){var r,s,a,l,h;return o(this,void 0,void 0,function(){var o,d,f,p;return i(this,function(i){switch(i.label){case 0:if(o={},d=(null===(r=t.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(f=null===(a=null===(s=null==u?void 0:u[d])||void 0===s?void 0:s.bind)||void 0===a?void 0:a.call(s,u)))throw new Error("invalid 【".concat(d,"】 request method"));i.label=1;case 1:return i.trys.push([1,3,,4]),(null===(l=t.headers)||void 0===l?void 0:l["content-type"])&&!(null===(h=t.headers)||void 0===h?void 0:h["content-type"].includes("application/json"))||["string","undefined"].includes(typeof t.body)||(t.data=t.data||t.body,t.body=JSON.stringify(t.body)),[4,f(n({url:e},t))];case 2:return o=i.sent(),o=c(o,n(n({},t),{url:e})),[3,4];case 3:throw p=i.sent(),o=n(n({},null==p?void 0:p.data),p);case 4:if(null==o?void 0:o.error)throw o;return[2,o]}})})}}}catch(e){console.error("user adapter generate fail:",e)}return r}(e,e.adapter):function(e,t){var r=n({},e),u={};if((null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!s.adapterForWxMp.isMatch()||e.storage&&e.baseRequest)return r;try{var l=s.adapterForWxMp.genAdapter({}),h=l.localStorage,d=l.reqClass;if(h&&(u.storage=new a({localStorage:h,adapter:t})),d){var f=new d({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});u.request=function(e){return function(t,r){return o(this,void 0,void 0,function(){return i(this,function(o){return[2,new Promise(function(o,i){var s=Object.assign({},r);s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));var a=wx.request({url:t,data:s.body,timeout:e._timeout,method:s.method||"GET",header:s.headers,success:function(e){(e=c(e,n(n({},r),{url:t}))).error&&i(e),o(e)},fail:function(e){i({error:"unreachable",error_description:e.message})},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("request")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{a.abort()}catch(e){}}}})})]})})}}(f)}return r.captchaOptions&&(u.baseRequest=u.request,u.request=void 0),n(n({},r),u)}catch(e){console.error("adapter generate fail:",e)}return r}(e,e.adapter)}},895:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},u=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},c=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},l=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=t.AuthError=t.AuthErrorCode=t.AuthErrorCategory=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=t.Auth=t.generateAuthInstance=t.LoginState=t.User=void 0;var h=r(722),d=r(548),f=r(19),p=r(266),v=r(916);Object.defineProperty(t,"WeixinAuthProvider",{enumerable:!0,get:function(){return v.WeixinAuthProvider}}),Object.defineProperty(t,"CustomAuthProvider",{enumerable:!0,get:function(){return v.CustomAuthProvider}}),Object.defineProperty(t,"AnonymousAuthProvider",{enumerable:!0,get:function(){return v.AnonymousAuthProvider}});var _=r(683),m=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},y=t.User=function(){function e(e){var t=e.cache,r=e.oauthInstance;this.cache=t,this.oauthInstance=r,this.setUserInfo()}var t,r,n;return e.prototype.checkLocalInfo=function(){return u(this,void 0,void 0,function(){return c(this,function(e){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]})})},e.prototype.checkLocalInfoAsync=function(){return u(this,void 0,void 0,function(){var e,t,r,n;return c(this,function(o){switch(o.label){case 0:return e=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return e.uid=o.sent(),t=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return t.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),r=this,[4,this.getLocalUserInfoAsync("email")];case 3:return r.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),n=this,[4,this.getLocalUserInfoAsync("username")];case 4:return n.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}})})},e.prototype.update=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(i({},e))];case 1:return t=r.sent(),this.setLocalUserInfo(t),[2]}})})},e.prototype.updateUserBasicInfo=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(i({},e))];case 1:return t.sent(),[4,this.refresh()];case 2:return t.sent(),[2]}})})},e.prototype.updatePassword=function(e,t){return this.oauthInstance.authApi.updatePasswordByOld({old_password:t,new_password:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(e)];case 1:if("INVALID_ACCESS_TOKEN"===(t=r.sent()).code)throw this.setLocalUserInfo({}),t;return this.setLocalUserInfo(t),[2,t]}})})},e.prototype.getLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);return e?r[e]:r||{}},e.prototype.setLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey;this.cache.setStore(t,e),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(t)];case 1:return[2,r.sent()[e]]}})})},e.prototype.setUserInfo=function(){var e=this,t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at","open_id"].forEach(function(t){e[t]=r[t]})},s([(0,f.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(t=void 0!==h.authModels&&h.authModels.UserProfile)?t:Object]),a("design:returntype","function"==typeof(r="undefined"!=typeof Promise&&Promise)?r:Object)],e.prototype,"update",null),s([(0,f.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String,String]),a("design:returntype",void 0)],e.prototype,"updatePassword",null),s([(0,f.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype",void 0)],e.prototype,"updateUsername",null),s([(0,f.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(n="undefined"!=typeof Promise&&Promise)?n:Object)],e.prototype,"refresh",null),e}();(0,v.applyUserV1Compat)(y);var g=function(){function e(e){var t=e.envId,r=e.cache,n=e.oauthInstance;t||(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new y({cache:this.cache,oauthInstance:n})}return e.prototype.checkLocalState=function(){var e;this.oauthLoginState=null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},e.prototype.checkLocalStateAsync=function(){var e;return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.getLoginState()];case 1:return t.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return t.sent(),[2]}})})},e}();t.LoginState=g;var b=function(e){function t(t){var r=e.call(this)||this;return r.listeners=new Map,r.hasListenerSetUp=!1,r.config=t,r.oauthInstance=t.oauthInstance,r.cache=t.cache,r.init(),r.setAccessKey(),r}var r,n,d,v,y,b,E,w,S,I,A,T,P,O,R,C,N,U,D,L,k;return o(t,e),t.prototype.signInAnonymously=function(e){return u(this,void 0,Promise,function(){var t,r,n,o,s;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];case 1:return a.sent(),[4,this.createLoginState()];case 2:return t=a.sent(),[4,this.getSession()];case 3:return r=a.sent().data,n=(void 0===r?{}:r).session,[2,i(i({},t),{data:{user:n.user,session:n},error:null})];case 4:return o=a.sent(),(s=new h.AuthError(o,{method:"signInAnonymously"})).category===h.AuthErrorCategory.PROVIDER_NOT_ENABLED?(console.error(s.helpMessage),console.error("[CloudBase Auth] 提示:匿名登录需要在控制台开启「匿名登录」。\n 如果您需要使用用户名密码登录,请改用 auth.signInWithPassword({ username, password })。\n 不要在匿名登录失败后自动回退到密码登录,这两种方式的使用场景不同。")):(console.warn("[CloudBase Auth] signInAnonymously 失败 [".concat(s.category,"]: ").concat(s.message)),s.loginMethodHint&&console.warn(s.loginMethodHint)),[2,{data:{user:null,session:null},error:s}];case 5:return[2]}})})},t.prototype.signUp=function(e){return u(this,void 0,Promise,function(){var t,r,n=this;return c(this,function(o){switch(o.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?(e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[4,this.oauthInstance.authApi.signUp(e)]):[3,2];case 1:return o.sent(),[2,this.createLoginState()];case 2:return o.trys.push([2,4,,5]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)})];case 3:return t=o.sent(),[2,{data:{verifyOtp:function(r){var o=r.token,s=r.messageId,a=void 0===s?t.verification_id:s;return u(n,void 0,Promise,function(){var r,n,s,u,l;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.verify({verification_id:a||t.verification_id,verification_code:String(o)})];case 1:return r=c.sent(),t.is_user?[4,this.signIn({username:e.email||this.formatPhone(e.phone),verification_token:r.verification_token})]:[3,3];case 2:return c.sent(),[3,6];case 3:return delete(n=JSON.parse(JSON.stringify(e))).email,delete n.phone,[4,this.oauthInstance.authApi.signUp(i(i(i({},n),e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}),{verification_token:r.verification_token,verification_code:o}))];case 4:return c.sent(),[4,this.createLoginState()];case 5:c.sent(),c.label=6;case 6:return[4,this.getSession()];case 7:return s=c.sent().data,[2,{data:{user:(u=(void 0===s?{}:s).session).user,session:u},error:null}];case 8:return l=c.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(l,{method:"signUp"})}];case 9:return[2]}})})}},error:null}];case 4:return r=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(r,{method:"signUp"})}];case 5:return[2]}})})},t.prototype.signOut=function(e){var t,r;return u(this,void 0,Promise,function(){var n,o,s;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),n=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return o=a.sent(),[4,this.cache.removeStoreAsync(n)];case 2:return a.sent(),this.setAccessKey(),null===(t=this.config.eventBus)||void 0===t||t.fire(h.EVENTS.LOGIN_STATE_CHANGED,{eventType:h.LOGIN_STATE_CHANGED_TYPE.SIGN_OUT}),null===(r=this.config.eventBus)||void 0===r||r.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT}),[2,i(i({},o),{data:{},error:null})];case 3:return s=a.sent(),[2,{data:{},error:new h.AuthError(s,{method:"signOut"})}];case 4:return[2]}})})},t.prototype.onAuthStateChange=function(e){var t=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var r=Math.random().toString(36);return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(e),{data:{subscription:{id:r,callback:e,unsubscribe:function(){var n=t.listeners.get(r);n&&(n.delete(e),0===n.size&&t.listeners.delete(r))}}}}},t.prototype.signInWithPassword=function(e){var t;return u(this,void 0,Promise,function(){var r,n,o,s,a,u,l;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),this.validateAtLeastOne(e,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),r="username"in e?e.username:void 0,n="email"in e?e.email:void 0,o="phone"in e?e.phone:void 0,[4,this.signIn(i({username:r||n||this.formatPhone(o),password:e.password},(null===(t=e.options)||void 0===t?void 0:t.is_encrypt)?{isEncrypt:!0,version:"v2"}:{}))];case 1:return c.sent(),[4,this.getSession()];case 2:return s=c.sent().data,[2,{data:{user:(a=(void 0===s?{}:s).session).user,session:a},error:null}];case 3:return u=c.sent(),(l=new h.AuthError(u,{method:"signInWithPassword"})).category===h.AuthErrorCategory.PROVIDER_NOT_ENABLED?console.error(l.helpMessage):l.category===h.AuthErrorCategory.INVALID_CREDENTIALS||l.category===h.AuthErrorCategory.USER_NOT_FOUND?console.warn(l.helpMessage):console.warn("[CloudBase Auth] signInWithPassword 失败 [".concat(l.category,"]: ").concat(l.message)),l.loginMethodHint&&console.info(l.loginMethodHint),[2,{data:{user:null,session:null},error:l}];case 4:return[2]}})})},t.prototype.signInWithIdToken=function(e){return u(this,void 0,Promise,function(){var t,r,n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:e.token})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(n,{method:"signInWithIdToken"})}];case 4:return[2]}})})},t.prototype.signInWithOtp=function(e){return u(this,void 0,Promise,function(){var t,r,n,o,s,a=this;return c(this,function(l){switch(l.label){case 0:if(t=e.options,r="email"in e?e.email:void 0,n="phone"in e?e.phone:void 0,!(null==t?void 0:t.emailRedirectTo)&&(void 0===(null==t?void 0:t.shouldCreateUser)||(null==t?void 0:t.shouldCreateUser)))return[2,this.signUp(r?{email:r}:{phone:n})];l.label=1;case 1:return l.trys.push([1,3,,4]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(i(i({email_redirect_to:null==t?void 0:t.emailRedirectTo},r?{email:r}:{phone_number:this.formatPhone(n)}),{target:"USER"}))];case 2:return o=l.sent(),[2,{data:{user:null,session:null,verifyOtp:function(e){var t=e.token,i=e.messageId,s=void 0===i?o.verification_id:i;return u(a,void 0,Promise,function(){return c(this,function(e){return[2,this.verifyOtp(r?{email:r,token:String(t),messageId:s}:{phone:n,token:String(t),messageId:s})]})})}},error:null}];case 3:return s=l.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(s,{method:"signInWithOtp"})}];case 4:return[2]}})})},t.prototype.verifyOAuth=function(e){return u(this,void 0,Promise,function(){var t,r,n,o,s,a,u,l,d;return c(this,function(c){switch(c.label){case 0:t={},c.label=1;case 1:return c.trys.push([1,7,,8]),r=(null==e?void 0:e.code)||_.utils.getQuery("code"),n=(null==e?void 0:e.state)||_.utils.getQuery("state"),r?n?(o=(0,p.getBrowserSession)(n),t.type=null==o?void 0:o.type,(s=(null==e?void 0:e.provider)||(null==o?void 0:o.provider)||_.utils.getQuery("provider"))?[4,this.grantProviderToken({provider_id:s,provider_redirect_uri:location.origin+location.pathname,provider_code:r})]:[2,{data:i(i({},t),{user:null,session:null,redirectUrl:null}),error:new h.AuthError({message:"Provider is required"})}]):[2,{data:{user:null,session:null,redirectUrl:null},error:new h.AuthError({message:"State is required"})}]:[2,{data:{user:null,session:null,redirectUrl:null},error:new h.AuthError({message:"Code is required"})}];case 2:return a=c.sent().provider_token,u=void 0,o.type!==h.OAUTH_TYPE.BIND_IDENTITY?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:a,provider:s,fireEvent:!0})];case 3:return u=c.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:a})];case 5:(u=c.sent()).data=i(i({},t),u.data),c.label=6;case 6:return(l=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),l.delete("state"),u.data.redirectUrl=(0,p.addUrlSearch)(void 0===(null==o?void 0:o.search)?"?".concat(l.toString()):null==o?void 0:o.search,(null==o?void 0:o.hash)||location.hash),(0,p.removeBrowserSession)(n),[2,u];case 7:return d=c.sent(),[2,{data:i(i({},t),{user:null,session:null,redirectUrl:null}),error:new h.AuthError(d,{method:"verifyOAuth"})}];case 8:return[2]}})})},t.prototype.signInWithOAuth=function(e){var t,r,n,o,i;return u(this,void 0,Promise,function(){var s,a,u,l,d,f,v,_,y;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),s=(null===(t=e.options)||void 0===t?void 0:t.redirectTo)||location.href,a=new URL(s),u=a.origin+a.pathname,l=(null===(r=e.options)||void 0===r?void 0:r.state)||"prd-".concat(e.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:e.provider,provider_redirect_uri:u,state:l})];case 1:return d=c.sent().uri,f=decodeURIComponent(d),v=f,(null===(n=e.options)||void 0===n?void 0:n.queryParams)&&(_=new URL(f),Object.entries(e.options.queryParams).forEach(function(e){var t=e[0],r=e[1];_.searchParams.set(t,r)}),v=_.toString()),(0,p.saveToBrowserSession)(l,{provider:e.provider,search:a.search,hash:a.hash,type:(null===(o=e.options)||void 0===o?void 0:o.type)||h.OAUTH_TYPE.SIGN_IN}),m()&&!(null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect)&&window.location.assign(v),[2,{data:{url:v,provider:e.provider},error:null}];case 2:return y=c.sent(),[2,{data:{url:null,provider:null},error:new h.AuthError(y,{method:"signInWithOAuth"})}];case 3:return[2]}})})},t.prototype.getClaims=function(){return u(this,void 0,Promise,function(){var e,t;return c(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return e=r.sent().accessToken,[2,{data:(0,h.weAppJwtDecodeAll)(e),error:null}];case 2:return t=r.sent(),[2,{data:{claims:null,header:null,signature:null},error:new h.AuthError(t,{method:"getClaims"})}];case 3:return[2]}})})},t.prototype.resetPasswordForEmail=function(e,t){return u(this,void 0,Promise,function(){var r,n,o,s,a,l,d=this;return c(this,function(f){switch(f.label){case 0:return f.trys.push([0,2,,3]),this.validateParams({emailOrPhone:e},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),r=(t||{}).redirectTo,n=e.includes("@"),o=void 0,n?o={email:e}:(s=this.formatPhone(e),o={phone_number:s}),[4,this.getVerification(i(i({},o),{target:"USER"}))];case 1:return a=f.sent(),[2,{data:{updateUser:function(t){return u(d,void 0,Promise,function(){var o,i,s,u;return c(this,function(c){switch(c.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.verify({verification_id:a.verification_id,verification_code:t.nonce})];case 2:return o=c.sent(),[4,this.oauthInstance.authApi.resetPassword({email:n?e:void 0,phone_number:n?void 0:e,new_password:t.password,verification_token:o.verification_token})];case 3:return c.sent(),null===(u=this.config.eventBus)||void 0===u||u.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:n?e:void 0,phone:n?void 0:e,password:t.password})];case 4:return i=c.sent(),r&&m()&&window.location.assign(r),[2,i];case 5:return s=c.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(s,{method:"resetPasswordForEmail"})}];case 6:return[2]}})})}},error:null}];case 2:return l=f.sent(),[2,{data:{updateUser:null},error:new h.AuthError(l,{method:"resetPasswordForEmail"})}];case 3:return[2]}})})},t.prototype.resetPasswordForOld=function(e){return u(this,void 0,Promise,function(){var t,r,n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:e.old_password,new_password:e.new_password})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(n,{method:"resetPasswordForOld"})}];case 4:return[2]}})})},t.prototype.verifyOtp=function(e){return u(this,void 0,Promise,function(){var t,r,n,o,i,s,a;return c(this,function(u){switch(u.label){case 0:return u.trys.push([0,6,,7]),t=e.type,r=String(e.token),n="email"in e?e.email:void 0,o="phone"in e?e.phone:void 0,this.validateParams(e,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(t)?[4,this.verify({verification_id:e.messageId,verification_code:r})]:[3,2];case 1:return u.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:e.messageId,is_user:!0},verificationCode:r,username:n||this.formatPhone(o)||"",loginType:n?"email":"phone"})];case 3:u.sent(),u.label=4;case 4:return[4,this.getSession()];case 5:return i=u.sent().data,[2,{data:{user:(s=(void 0===i?{}:i).session).user,session:s},error:null}];case 6:return a=u.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(a,{method:"verifyOtp"})}];case 7:return[2]}})})},t.prototype.getSession=function(){return u(this,void 0,Promise,function(){var e,t,r,n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=o.sent())&&"accessKey"!==e.scope?[4,this.getUser(!1)]:[2,{data:{session:null,user:null},error:null}];case 2:return t=o.sent().data,r=(void 0===t?{}:t).user,[2,{data:{session:i(i({},e),{user:r}),user:r},error:null}];case 3:return n=o.sent(),[2,{data:{session:null,user:null},error:new h.AuthError(n,{method:"getSession"})}];case 4:return[2]}})})},t.prototype.refreshSession=function(e){return u(this,void 0,Promise,function(){var t,r,n,o,s;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(t=a.sent()).refresh_token=e||t.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(t)];case 2:return r=a.sent(),[4,this.getUser(!1)];case 3:return n=a.sent().data,[2,{data:{user:o=(void 0===n?{}:n).user,session:i(i({},r),{user:o})},error:null}];case 4:return s=a.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(s,{method:"refreshSession"})}];case 5:return[2]}})})},t.prototype.getUser=function(e){return void 0===e&&(e=!0),u(this,void 0,Promise,function(){var t,r,n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(t=o.sent())&&"accessKey"!==t.scope?(r=this.convertToUser,[4,this.getCurrentUser(e)]):[2,{data:{user:null},error:null}];case 2:return[2,{data:{user:r.apply(this,[o.sent()])},error:null}];case 3:return n=o.sent(),[2,{data:{user:null},error:new h.AuthError(n,{method:"getUser"})}];case 4:return[2]}})})},t.prototype.refreshUser=function(){return u(this,void 0,Promise,function(){var e,t,r;return c(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return n.sent(),[4,this.getSession()];case 2:return e=n.sent().data,[2,{data:{user:(t=(void 0===e?{}:e).session).user,session:t},error:null}];case 3:return r=n.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(r,{method:"refreshUser"})}];case 4:return[2]}})})},t.prototype.updateUser=function(e){var t;return u(this,void 0,Promise,function(){var r,n,o,s,a,d,f,p,v,_,m,y,g=this;return c(this,function(b){switch(b.label){case 0:if(b.trys.push([0,8,,9]),!Object.keys(e).some(function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]}))throw new h.AuthError({message:"At least one field must be provided for update"});return r=e.email,n=e.phone,o=l(e,["email","phone"]),a=void 0!==n,d={},(s=void 0!==r)||a?(f=void 0,s?(f={email:e.email},p="email_change"):(v=this.formatPhone(e.phone),f={phone_number:v},p="phone_change"),[4,this.getVerification(i({},f))]):[3,4];case 1:return _=b.sent(),Object.keys(o).length>0?[4,this.updateUserBasicInfo(o)]:[3,3];case 2:b.sent(),b.label=3;case 3:return d={messageId:_.verification_id,verifyOtp:function(t){return u(g,void 0,Promise,function(){var r,n,o,i;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,11,,12]),t.email&&e.email===t.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:t.token,messageId:_.verification_id})]:[3,3];case 1:return(r=a.sent()).error?[2,r]:[4,this.updateUserBasicInfo({email:e.email})];case 2:return a.sent(),[3,9];case 3:return t.phone&&e.phone===t.phone?[4,this.verifyOtp({type:"phone_change",phone:e.phone,token:t.token,messageId:_.verification_id})]:[3,6];case 4:return(r=a.sent()).error?[2,r]:[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return a.sent(),[3,9];case 6:return[4,this.verifyOtp(s?{type:p,email:e.email,token:t.token,messageId:_.verification_id}:{type:p,phone:e.phone,token:t.token,messageId:_.verification_id})];case 7:return(r=a.sent()).error?[2,r]:[4,this.updateUserBasicInfo(e)];case 8:a.sent(),a.label=9;case 9:return[4,this.getUser(!1)];case 10:return n=a.sent().data.user,null===(i=this.config.eventBus)||void 0===i||i.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:{user:n},error:null}];case 11:return o=a.sent(),[2,{data:{user:null},error:new h.AuthError(o,{method:"updateUser"})}];case 12:return[2]}})})}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:b.sent(),b.label=6;case 6:return[4,this.getUser(!1)];case 7:return m=b.sent().data.user,Object.keys(o).length>0&&(null===(t=this.config.eventBus)||void 0===t||t.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.USER_UPDATED})),[2,{data:i({user:m},d),error:null}];case 8:return y=b.sent(),[2,{data:{user:null},error:new h.AuthError(y,{method:"updateUser"})}];case 9:return[2]}})})},t.prototype.getUserIdentities=function(){var e;return u(this,void 0,Promise,function(){var t,r;return c(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return t=n.sent(),[2,{data:{identities:null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.filter(function(e){return!!e.bind})},error:null}];case 2:return r=n.sent(),[2,{data:{identities:null},error:new h.AuthError(r,{method:"getUserIdentities"})}];case 3:return[2]}})})},t.prototype.linkIdentity=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:e.provider,options:{type:h.OAUTH_TYPE.BIND_IDENTITY}})];case 1:return r.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return t=r.sent(),[2,{data:{provider:null},error:new h.AuthError(t,{method:"linkIdentity"})}];case 3:return[2]}})})},t.prototype.unlinkIdentity=function(e){return u(this,void 0,Promise,function(){var t;return c(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:e.provider})];case 1:return r.sent(),[2,{data:{},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new h.AuthError(t,{method:"unlinkIdentity"})}];case 3:return[2]}})})},t.prototype.reauthenticate=function(){return u(this,void 0,Promise,function(){var e,t,r,n,o=this;return c(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.getUser(!1)];case 1:return e=s.sent().data.user,this.validateAtLeastOne(e,[["email","phone"]],"You must provide either an email or phone number"),t=e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)},[4,this.getVerification(t)];case 2:return r=s.sent(),[2,{data:{updateUser:function(e){return u(o,void 0,Promise,function(){var n,o,s,a,u;return c(this,function(c){switch(c.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"}}),c.label=1;case 1:return c.trys.push([1,9,,10]),e.password?[4,this.verify({verification_id:r.verification_id,verification_code:e.nonce})]:[3,5];case 2:return n=c.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:n.verification_token})];case 3:return o=c.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:e.password,sudo_token:o.sudo_token})];case 4:return c.sent(),[3,7];case 5:return[4,this.signInWithUsername(i(i({verificationInfo:r,verificationCode:e.nonce},t),{loginType:t.email?"email":"phone"}))];case 6:c.sent(),c.label=7;case 7:return[4,this.getSession()];case 8:return s=c.sent().data,[2,{data:{user:(a=(void 0===s?{}:s).session).user,session:a},error:null}];case 9:return u=c.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(u,{method:"reauthenticate"})}];case 10:return[2]}})})}},error:null}];case 3:return n=s.sent(),[2,{data:{updateUser:null},error:new h.AuthError(n,{method:"reauthenticate"})}];case 4:return[2]}})})},t.prototype.resend=function(e){return u(this,void 0,Promise,function(){var t,r,n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),t="signup"===e.type?"ANY":"USER",r={target:t},"email"in e&&(r.email=e.email),"phone"in e&&(r.phone_number=this.formatPhone(e.phone)),[4,this.oauthInstance.authApi.getVerification(r)];case 1:return[2,{data:{messageId:o.sent().verification_id},error:null}];case 2:return n=o.sent(),[2,{data:{messageId:null},error:new h.AuthError(n,{method:"resend"})}];case 3:return[2]}})})},t.prototype.setSession=function(e){var t;return u(this,void 0,Promise,function(){var r,n,o;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(e,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(e,{throwError:!0})];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,n=(void 0===r?{}:r).session,null===(t=this.config.eventBus)||void 0===t||t.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,{data:{user:n.user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(o,{method:"setSession"})}];case 4:return[2]}})})},t.prototype.exchangeCodeForSession=function(){return u(this,void 0,void 0,function(){return c(this,function(e){return[2]})})},t.prototype.deleteUser=function(e){return u(this,void 0,Promise,function(){var t,r;return c(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(e)];case 1:return t=n.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:t})];case 2:return n.sent(),[2,{data:{},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new h.AuthError(r,{method:"deleteUser"})}];case 4:return[2]}})})},t.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),u(this,void 0,Promise,function(){var t,r,n,o,i;return c(this,function(s){try{return t=e.config_version||"env",r=Object.keys(e.query||{}).map(function(t){return"".concat(t,"=").concat(e.query[t])}).join("&"),f.adapterForWxMp.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(r?"?".concat(r):"")}):(n=e.redirect_uri||window.location.href,o=new URL(n),i="".concat(o.origin,"/__auth/?app_id=").concat(e.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(t,"&redirect_uri=").concat(encodeURIComponent(n)).concat(r?"&".concat(r):""),window.location.href=i),[2,{data:{},error:null}]}catch(e){return[2,{data:{},error:new h.AuthError(e,{method:"toDefaultLoginPage"})}]}return[2]})})},t.prototype.signInWithCustomTicket=function(e){return u(this,void 0,Promise,function(){var t,r,n,o;return c(this,function(s){switch(s.label){case 0:e&&this.setCustomSignFunc(e),s.label=1;case 1:return s.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return s.sent(),[4,this.createLoginState()];case 3:return t=s.sent(),[4,this.getSession()];case 4:return r=s.sent().data,n=(void 0===r?{}:r).session,[2,i(i({},t),{data:{user:n.user,session:n},error:null})];case 5:return o=s.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(o,{method:"signInWithCustomTicket"})}];case 6:return[2]}})})},t.prototype.signInWithOpenId=function(e){var t=(void 0===e?{}:e).useWxCloud,r=void 0===t||t;return u(this,void 0,Promise,function(){var e,t,n,o,s,a,l=this;return c(this,function(d){switch(d.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,t=function(t){return u(l,void 0,void 0,function(){var n,o;return c(this,function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},r)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:n.provider_token},r)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}})})},d.label=1;case 1:return d.trys.push([1,5,,6]),[4,new Promise(function(e,r){wx.login({success:function(n){return u(l,void 0,void 0,function(){var o;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(n.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return o=i.sent(),r(o),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})})];case 2:return d.sent(),[4,this.createLoginState()];case 3:return n=d.sent(),[4,this.getSession()];case 4:return o=d.sent().data,s=(void 0===o?{}:o).session,[2,i(i({},n),{data:{user:s.user,session:s},error:null})];case 5:return a=d.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(a,{method:"signInWithOpenId"})}];case 6:return[2]}})})},t.prototype.signInWithPhoneAuth=function(e){var t=e.phoneCode,r=void 0===t?"":t,n=e.useWxCloud,o=void 0!==n&&n;return u(this,void 0,Promise,function(){var e,t,n,s,a,u,l,d,p;return c(this,function(c){switch(c.label){case 0:return f.adapterForWxMp.isMatch()?(e=wx.getAccountInfoSync().miniProgram,t={provider_params:{provider_code_type:"phone",code:r,appid:e.appId},provider_id:e.appId},[4,wx.login()]):[2,{data:{user:null,session:null},error:new h.AuthError({message:"wx api undefined"})}];case 1:n=c.sent().code,t.provider_code=n,c.label=2;case 2:return c.trys.push([2,5,,6]),[4,this.oauthInstance.authApi.grantProviderToken(t,o)];case 3:if((s=c.sent()).error_code)throw s;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:s.provider_token},o)];case 4:if(null==(a=c.sent())?void 0:a.error_code)throw a;return[3,6];case 5:return u=c.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(u,{method:"signInWithPhoneAuth"})}];case 6:return[4,this.createLoginState()];case 7:return l=c.sent(),[4,this.getSession()];case 8:return d=c.sent().data,p=(void 0===d?{}:d).session,[2,i(i({},l),{data:{user:p.user,session:p},error:null})]}})})},t.prototype.bindPhoneNumber=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.editContact(e)]})})},t.prototype.unbindProvider=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.unbindProvider(e)]})})},t.prototype.bindEmail=function(e){return this.oauthInstance.authApi.editContact(e)},t.prototype.verify=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.verify(e)]})})},t.prototype.getVerification=function(e,t){return u(this,void 0,Promise,function(){return c(this,function(r){return e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[2,this.oauthInstance.authApi.getVerification(e,t)]})})},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var e=this.hasLoginState();return e&&e.user||null}(0,f.printWarn)(f.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(e){return void 0===e&&(e=!0),u(this,void 0,Promise,function(){var t,r,n;return c(this,function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),e?[4,this.getLoginState()]:[3,3];case 1:return(t=o.sent())?[4,t.user.refresh()]:[3,3];case 2:o.sent(),o.label=3;case 3:return[3,5];case 4:return o.sent(),[3,5];case 5:return[4,this.getLoginState()];case 6:return(r=o.sent())?(n=r.user.getLocalUserInfo(),[4,r.user.checkLocalInfoAsync()]):[3,8];case 7:return o.sent(),[2,i(i({},r.user),n)];case 8:return[2,null]}})})},t.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return u(this,void 0,Promise,function(){var e,r,n=this;return c(this,function(o){switch(o.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,r=function(r){return u(n,void 0,void 0,function(){var n,o;return c(this,function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},t)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:n.provider_token},t)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[2]}})})},[4,new Promise(function(e,t){wx.login({success:function(o){return u(n,void 0,void 0,function(){var n;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return n=i.sent(),t(n),[3,3];case 3:return[2]}})})},fail:function(e){var r=new Error(null==e?void 0:e.errMsg);r.code=null==e?void 0:e.errno,t(r)}})})];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}})})},t.prototype.bindOpenId=function(){return u(this,void 0,Promise,function(){var e,t,r=this;return c(this,function(n){switch(n.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return u(r,void 0,void 0,function(){var r;return c(this,function(n){switch(n.label){case 0:r=void 0,n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}})];case 2:if((null==(r=n.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:r.provider_token})];case 3:return n.sent(),[3,5];case 4:throw n.sent();case 5:return[2]}})})},[4,new Promise(function(e,n){wx.login({success:function(o){return u(r,void 0,void 0,function(){var r;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})})];case 1:return n.sent(),[2]}})})},t.prototype.signInWithUnionId=function(){return u(this,void 0,Promise,function(){var e=this;return c(this,function(t){switch(t.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise(function(t,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return u(e,void 0,void 0,function(){var e,i,s,a,u;return c(this,function(c){switch(c.label){case 0:e=null==n?void 0:n.appId,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:o.code,provider_id:e,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return i=c.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:e,provider_token:s})]:(r(i),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(t(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})})];case 2:return t.sent(),[3,4];case 3:throw t.sent();case 4:return[2,this.createLoginState()]}})})},t.prototype.signInWithSms=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.phoneNum,s=void 0===i?"":i,a=e.bindInfo,l=void 0===a?void 0:a;return u(this,void 0,Promise,function(){return c(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:l,username:s,loginType:"sms"})]}catch(e){throw e}return[2]})})},t.prototype.signInWithEmail=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.bindInfo,s=void 0===i?void 0:i,a=e.email,l=void 0===a?"":a;return u(this,void 0,Promise,function(){return c(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:s,username:l,loginType:"email"})]}catch(e){throw e}return[2]})})},t.prototype.setCustomSignFunc=function(e){this.oauthInstance.authApi.setCustomSignFunc(e)},t.prototype.signIn=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signIn(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.setPassword=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.setPassword(e)]})})},t.prototype.isUsernameRegistered=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:e})];case 1:return[2,t.sent().exist]}})})},t.prototype.hasLoginState=function(){var e;if("async"!==this.cache.mode)return(null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync())?new g({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,f.printWarn)(f.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},t.prototype.getLoginState=function(){return u(this,void 0,Promise,function(){var e;return c(this,function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,null];case 4:return e?[2,new g({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}})})},t.prototype.getUserInfo=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.getCurrentUser()]})})},t.prototype.getWedaUserInfo=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]})})},t.prototype.updateUserBasicInfo=function(e){return u(this,void 0,void 0,function(){var t;return c(this,function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(t=r.sent())?[4,t.user.updateUserBasicInfo(e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}})})},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]})})},t.prototype.queryUser=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]})})},t.prototype.getAccessToken=function(){return u(this,void 0,Promise,function(){return c(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:e.sent(),env:this.config.env}]}})})},t.prototype.grantProviderToken=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]})})},t.prototype.patchProviderToken=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]})})},t.prototype.signInWithProvider=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.grantToken=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.grantToken(e)];case 1:return t.sent(),[2,this.createLoginState()]}})})},t.prototype.genProviderRedirectUri=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]})})},t.prototype.resetPassword=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]})})},t.prototype.deviceAuthorize=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]})})},t.prototype.sudo=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.sudo(e)]})})},t.prototype.deleteMe=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]})})},t.prototype.getProviders=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getProviders()]})})},t.prototype.loginScope=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.loginScope()]})})},t.prototype.loginGroups=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.loginGroups()]})})},t.prototype.onLoginStateChanged=function(e){var t;return u(this,void 0,void 0,function(){var r,n=this;return c(this,function(o){switch(o.label){case 0:return null===(t=this.config.eventBus)||void 0===t||t.on(h.EVENTS.LOGIN_STATE_CHANGED,function(t){return u(n,void 0,void 0,function(){var r,n,o;return c(this,function(s){switch(s.label){case 0:return(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.eventType)===h.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR?[3,2]:[4,this.getLoginState()];case 1:return n=s.sent(),[3,3];case 2:n={},s.label=3;case 3:return r=n,e.call(this,i(i({},t),r)),[2]}})})}),[4,this.getLoginState()];case 1:return r=o.sent(),e.call(this,r),[2]}})})},t.prototype.refreshTokenForce=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]})})},t.prototype.getCredentials=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getCredentials()]})})},t.prototype.setCredentials=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(e)];case 1:return t.sent(),[2]}})})},t.prototype.getProviderSubType=function(){return u(this,void 0,Promise,function(){return c(this,function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]})})},t.prototype.createCaptchaData=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]})})},t.prototype.verifyCaptchaData=function(e){return u(this,void 0,void 0,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]})})},t.prototype.getMiniProgramQrCode=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]})})},t.prototype.getMiniProgramQrCodeStatus=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]})})},t.prototype.modifyPassword=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]})})},t.prototype.modifyPasswordWithoutLogin=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]})})},t.prototype.getUserBehaviorLog=function(e){return u(this,void 0,Promise,function(){return c(this,function(t){return[2,this.oauthInstance.authApi.getUserBehaviorLog(e)]})})},t.prototype.signInWithUsername=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,s=e.username,a=void 0===s?"":s,l=e.bindInfo,h=void 0===l?void 0:l,d=e.loginType,f=void 0===d?"":d;return u(this,void 0,Promise,function(){var e,t,n,s,u,l,d;return c(this,function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:o})];case 1:if(null==(e=c.sent())?void 0:e.error_code)throw e;return t=e.verification_token,n=this.formatPhone(a),s={phone_number:n},"email"===f&&(s={email:n=a}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:t})]:[3,5];case 2:if(null==(u=c.sent())?void 0:u.error_code)throw u;return h?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==h?void 0:h.providerToken})]:[3,4];case 3:if(null==(l=c.sent())?void 0:l.error_code)throw l;c.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(i(i({},s),{verification_token:t,provider_token:null==h?void 0:h.providerId}))];case 6:if(null==(d=c.sent())?void 0:d.error_code)throw d;c.label=7;case 7:return[2,this.createLoginState()];case 8:throw c.sent();case 9:return[2]}})})},t.prototype.createLoginState=function(e,t){var r,n;return u(this,void 0,Promise,function(){var o;return c(this,function(i){switch(i.label){case 0:return[4,(o=new g({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return i.sent(),(null==t?void 0:t.userInfo)?(o.user.setLocalUserInfo(t.userInfo),[3,5]):[3,2];case 2:return(null==t?void 0:t.asyncRefreshUser)?(o.user.refresh(e),[3,5]):[3,3];case 3:return[4,o.user.refresh(e)];case 4:i.sent(),i.label=5;case 5:return null===(r=this.config.eventBus)||void 0===r||r.fire(h.EVENTS.LOGIN_STATE_CHANGED,{eventType:h.LOGIN_STATE_CHANGED_TYPE.SIGN_IN}),null===(n=this.config.eventBus)||void 0===n||n.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,o]}})})},t.prototype.setAccessKey=function(){var e,t;return u(this,void 0,void 0,function(){var r,n;return c(this,function(o){if(r="",n="",this.config.accessKey?(r=this.config.accessKey,n="accessKey"):(null===(e=this.config.auth)||void 0===e?void 0:e.secretId)&&(null===(t=this.config.auth)||void 0===t?void 0:t.secretKey)&&(r="",n=h.DEFAULT_NODE_ACCESS_SCOPE),!n)return[2];try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:r,token_type:"Bearer",scope:n,expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]})})},t.prototype.formatPhone=function(e){return!/\s+/.test(e)&&/^\+\d{1,3}\d+/.test(e)?e.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(e)?e:"+86 ".concat(e)},t.prototype.notifyListeners=function(e,t,r){this.listeners.forEach(function(n){n.forEach(function(n){try{n(e,t,r)}catch(e){console.error("Error in auth state change callback:",e)}})})},t.prototype.setupListeners=function(){var e,t=this;null===(e=this.config.eventBus)||void 0===e||e.on(h.EVENTS.AUTH_STATE_CHANGED,function(e){return u(t,void 0,void 0,function(){var t,r,n,o,i;return c(this,function(s){switch(s.label){case 0:return t=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.event,r=null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(t,n,r),[2]}})})})},t.prototype.convertToUser=function(e){var t,r,n,o,i,s;if(!e)return null;var a=(null==e?void 0:e.email)||"",u=(null==e?void 0:e.phone_number)||"",c=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:c,aud:"authenticated",role:null===(r=null===(t=e.groups)||void 0===t?void 0:t.map)||void 0===r?void 0:r.call(t,function(e){return"string"==typeof e?e:e.id}),email:a||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:u,phone_confirmed_at:u?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(n=e.loginType)||void 0===n?void 0:n.toLowerCase())||"cloudbase",providers:[(null===(o=e.loginType)||void 0===o?void 0:o.toLowerCase())||"cloudbase"]},user_metadata:{name:null==e?void 0:e.name,picture:null==e?void 0:e.picture,username:null==e?void 0:e.username,gender:null==e?void 0:e.gender,locale:null==e?void 0:e.locale,uid:e.uid,nickName:e.nickName||(null==e?void 0:e.name),avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:null!==(i=e.hasPassword)&&void 0!==i?i:"SET"===e.password,open_id:null==e?void 0:e.open_id},identities:(null===(s=null==e?void 0:e.providers)||void 0===s?void 0:s.map(function(t){return{id:t.id||"",identity_id:t.id||"",user_id:c,identity_data:{provider_id:t.id,provider_user_id:t.provider_user_id,name:t.name},provider:t.id||"cloudbase",created_at:e.created_at,updated_at:e.updated_at,last_sign_in_at:e.last_sign_in_at}}))||[],created_at:e.created_at,updated_at:e.updated_at,is_anonymous:"anonymous"===e.name}},t.prototype.validateParams=function(e,t){for(var r=0,n=Object.entries(t);r<n.length;r++){var o=n[r],i=o[0],s=o[1];if(s.required&&(void 0===(null==e?void 0:e[i])||null===(null==e?void 0:e[i])||""===(null==e?void 0:e[i])))throw new h.AuthError({message:s.message})}},t.prototype.validateAtLeastOne=function(e,t,r){if(!t.some(function(t){return t.some(function(t){return void 0!==(null==e?void 0:e[t])&&null!==(null==e?void 0:e[t])&&""!==(null==e?void 0:e[t])})}))throw new h.AuthError({message:r})},t.prototype.init=function(){var e;return u(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return t.sent()&&(null===(e=this.config.eventBus)||void 0===e||e.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION})),[3,3];case 2:return t.sent(),[3,3];case 3:return[2,{error:null}]}})})},s([(0,f.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(r=void 0!==h.authModels&&h.authModels.BindPhoneRequest)?r:Object]),a("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),s([(0,f.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(n=void 0!==h.authModels&&h.authModels.UnbindProviderRequest)?n:Object]),a("design:returntype","function"==typeof(d="undefined"!=typeof Promise&&Promise)?d:Object)],t.prototype,"unbindProvider",null),s([(0,f.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(v=void 0!==h.authModels&&h.authModels.BindEmailRequest)?v:Object]),a("design:returntype",void 0)],t.prototype,"bindEmail",null),s([(0,f.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(y=void 0!==h.authModels&&h.authModels.VerifyRequest)?y:Object]),a("design:returntype","function"==typeof(b="undefined"!=typeof Promise&&Promise)?b:Object)],t.prototype,"verify",null),s([(0,f.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(E=void 0!==h.authModels&&h.authModels.GetVerificationRequest)?E:Object,Object]),a("design:returntype","function"==typeof(w="undefined"!=typeof Promise&&Promise)?w:Object)],t.prototype,"getVerification",null),s([(0,f.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(S="undefined"!=typeof Promise&&Promise)?S:Object)],t.prototype,"getCurrentUser",null),s([(0,f.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(I="undefined"!=typeof Promise&&Promise)?I:Object)],t.prototype,"signInAnonymouslyInWx",null),s([(0,f.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(A="undefined"!=typeof Promise&&Promise)?A:Object)],t.prototype,"bindOpenId",null),s([(0,f.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],t.prototype,"signInWithUnionId",null),s([(0,f.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(P="undefined"!=typeof Promise&&Promise)?P:Object)],t.prototype,"signInWithSms",null),s([(0,f.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(O="undefined"!=typeof Promise&&Promise)?O:Object)],t.prototype,"signInWithEmail",null),s([(0,f.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype","function"==typeof(R="undefined"!=typeof Promise&&Promise)?R:Object)],t.prototype,"isUsernameRegistered",null),s([(0,f.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(C="undefined"!=typeof Promise&&Promise)?C:Object)],t.prototype,"getLoginState",null),s([(0,f.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(N="undefined"!=typeof Promise&&Promise)?N:Object)],t.prototype,"getUserInfo",null),s([(0,f.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(U="undefined"!=typeof Promise&&Promise)?U:Object)],t.prototype,"getWedaUserInfo",null),s([(0,f.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(D=void 0!==h.authModels&&h.authModels.BindWithProviderRequest)?D:Object]),a("design:returntype","function"==typeof(L="undefined"!=typeof Promise&&Promise)?L:Object)],t.prototype,"bindWithProvider",null),s([(0,f.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(k="undefined"!=typeof Promise&&Promise)?k:Object)],t.prototype,"getProviderSubType",null),t}(v.AuthV1Compat);function E(e,t){var r,n,o,s,a=this,l=e.region,p=void 0===l?"ap-shanghai":l,v=e.i18n,_=e.accessKey,m=e.useWxCloud,y=(null==t?void 0:t.platform)||f.useDefaultAdapter.bind(t)(),g=y.runtime,E=y.adapter,w=t||{},S=w.env,I=w.clientId,A=w.debug,T=w.cache,P=w.app,O=w.getApiOrigin,R=(t||{}).apiOrigin;R||(R="https://".concat(S,".").concat(p,".tcb-api.tencentcloudapi.com"));var C,N={env:S,clientId:I,i18n:v,accessKey:_,useWxCloud:m,eventBus:new f.CloudbaseEventEmitter},U=new h.CloudbaseOAuth((0,d.useAuthAdapter)(i(i({},N),{apiOrigin:R,getApiOrigin:O,apiPath:(null==e?void 0:e.apiPath)||h.AUTH_API_PREFIX,storage:null==e?void 0:e.storage,baseRequest:null==e?void 0:e.baseRequest,request:null==e?void 0:e.request,anonymousSignInFunc:null==e?void 0:e.anonymousSignInFunc,captchaOptions:null==e?void 0:e.captchaOptions,wxCloud:null==e?void 0:e.wxCloud,adapter:E,onCredentialsError:(C=N.eventBus,function(e){C.fire(h.EVENTS.LOGIN_STATE_CHANGED,i(i({},e),{eventType:h.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR}))}),headers:i({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:A,auth:null===(n=null===(r=t.app)||void 0===r?void 0:r.config)||void 0===n?void 0:n.auth}))),D=new b(i(i({},N),{region:p,persistence:e.persistence,debug:A,cache:T||new f.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(S)},platformInfo:y}),runtime:g||"web",_fromApp:P,oauthInstance:U,auth:null===(s=null===(o=t.app)||void 0===o?void 0:o.config)||void 0===s?void 0:s.auth}));return U.initializeSession(function(e,t){return u(a,void 0,void 0,function(){return c(this,function(r){return e?(e.type===h.OAUTH_TYPE.SIGN_IN?t?N.eventBus.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.SIGNED_IN,info:i(i({},e),{error:t})}):e.user&&D.createLoginState({},{userInfo:e.user}):e.type===h.OAUTH_TYPE.BIND_IDENTITY&&N.eventBus.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:i(i({},e),{error:t})}),[2]):[2]})})}),{authInstance:D,oauthInstance:U}}t.Auth=b,t.generateAuthInstance=E;var w="auth";function S(e,t){for(var r=[],n=0;n<=e.length;n++)r[n]=[n];for(var o=0;o<=t.length;o++)r[0][o]=o;for(n=1;n<=e.length;n++)for(o=1;o<=t.length;o++){var i=e[n-1].toLowerCase()===t[o-1].toLowerCase()?0:1;r[n][o]=Math.min(r[n-1][o]+1,r[n][o-1]+1,r[n-1][o-1]+i)}return r[e.length][t.length]}var I={name:"auth",namespace:w,entity:function(e){var t=function(e){var t,r=this;if(this.authInstance&&!e)return this.authInstance;e=e||{region:"",persistence:"local",apiPath:h.AUTH_API_PREFIX};var n=this.platform.adapter,o=e.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var s=E(i(i({wxCloud:this.config.wxCloud,storage:this.config.storage},e),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(t=this.config.auth)||void 0===t?void 0:t.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,getApiOrigin:function(){return r.request.getBaseEndPoint(r.config.endPointMode||"CLOUD_API")},platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),a=s.authInstance,u=s.oauthInstance;return this.oauthInstance=u,this.authInstance=a,this.authInstance},r=t.call(this,e);Object.assign(t,r),Object.setPrototypeOf(t,Object.getPrototypeOf(r));var n="undefined"!=typeof Proxy?new Proxy(t,{get:function(e,t,r){var n=Reflect.get(e,t,r);if(void 0!==n||"string"!=typeof t)return n;var o=function(e,t){for(var r=null,n=1/0,o=0,i=t;o<i.length;o++){var s=i[o];if(!s.startsWith("_")&&"constructor"!==s){var a=S(e,s);a<n&&(n=a,r=s)}}return r}(t,Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)).filter(function(t){return"function"==typeof e[t]}));return o&&console.warn("[CloudBase Auth] auth.".concat(t," is not a function. Did you mean: auth.").concat(o,"() ?")),n}}):t;return this[w]=n,n}};try{cloudbase.registerComponent(I)}catch(e){}var A=r(722);Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return A.AuthErrorCategory}}),Object.defineProperty(t,"AuthErrorCode",{enumerable:!0,get:function(){return A.AuthErrorCode}}),Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return A.AuthError}}),t.registerAuth=function(e){try{e.registerComponent(I)}catch(e){console.warn(e)}}},19:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.adapterForWxMp=t.CloudbaseCache=t.CloudbaseEventEmitter=t.catchErrorsDecorator=t.COMMUNITY_SITE_URL=t.ERRORS=t.throwError=t.printWarn=void 0;var o=r(616);Object.defineProperty(t,"printWarn",{enumerable:!0,get:function(){return o.printWarn}}),Object.defineProperty(t,"throwError",{enumerable:!0,get:function(){return o.throwError}});var i=r(794);Object.defineProperty(t,"ERRORS",{enumerable:!0,get:function(){return i.ERRORS}}),Object.defineProperty(t,"COMMUNITY_SITE_URL",{enumerable:!0,get:function(){return i.COMMUNITY_SITE_URL}});var s=r(141);Object.defineProperty(t,"catchErrorsDecorator",{enumerable:!0,get:function(){return s.catchErrorsDecorator}});var a=r(689);Object.defineProperty(t,"CloudbaseEventEmitter",{enumerable:!0,get:function(){return a.CloudbaseEventEmitter}});var u=r(197);Object.defineProperty(t,"CloudbaseCache",{enumerable:!0,get:function(){return u.CloudbaseCache}});var c=r(882);Object.defineProperty(t,"adapterForWxMp",{enumerable:!0,get:function(){return n(c).default}});var l=r(182);Object.defineProperty(t,"useDefaultAdapter",{enumerable:!0,get:function(){return l.useDefaultAdapter}})},266:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.removeUrlParams=t.addUrlSearch=t.removeBrowserSession=t.getBrowserSession=t.saveToBrowserSession=void 0,t.saveToBrowserSession=function(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch(e){console.error("Failed to save to browser session:",e)}},t.getBrowserSession=function(e){try{return JSON.parse(sessionStorage.getItem(e))}catch(e){return console.error("Failed to get browser session:",e),null}},t.removeBrowserSession=function(e){try{return sessionStorage.removeItem(e),!0}catch(e){return console.error("Failed to remove browser session:",e),null}},t.addUrlSearch=function(e,t){if(void 0!==e){var r=new URL(window.location.href);return r.search=e,r.hash=t||r.hash,window.history.replaceState({},"",r.href),r.href}},t.removeUrlParams=function(e){if("undefined"!=typeof window)try{var t=new URL(window.location.href);e.forEach(function(e){t.searchParams.delete(e)}),window.history.replaceState({},"",t.href)}catch(e){console.error("Failed to remove URL params:",e)}}},916:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.applyUserV1Compat=t.AuthV1Compat=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=void 0;var s=r(722),a=r(19),u=function(){function e(e){}return e.prototype.signInWithRedirect=function(){throw new Error("[v1 兼容] WeixinAuthProvider.signInWithRedirect() 在当前版本中无法实现。 建议使用 auth.signInWithOAuth({ provider: 'providerId' }) 替代。")},e.prototype.getRedirectResult=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getRedirectResult() 在当前版本中无法实现。 建议使用 auth.verifyOAuth({ code, state, provider }) 替代。")})})},e.prototype.getLinkRedirectResult=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getLinkRedirectResult() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")})})},e}();t.WeixinAuthProvider=u;var c=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.authInstance.signInWithCustomTicket(function(){return Promise.resolve(e)})];case 1:return t.sent(),[2]}})})},e}();t.CustomAuthProvider=c;var l=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.authInstance.signInAnonymously({})];case 1:return e.sent(),[2]}})})},e}();t.AnonymousAuthProvider=l;var h=function(){function e(){}return e.prototype.weixinAuthProvider=function(e){return new u({authInstance:this,appid:e.appid,scope:e.scope})},e.prototype.customAuthProvider=function(){return new c({authInstance:this})},e.prototype.anonymousAuthProvider=function(){return new l({authInstance:this})},e.prototype.signUpWithEmailAndPassword=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signUp({email:e,password:t})];case 1:return[2,r.sent()]}})})},e.prototype.signInWithEmailAndPassword=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}})})},e.prototype.sendPasswordResetEmail=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),[4,this.getVerification({email:e})];case 1:return t.sent(),[2]}})})},e.prototype.signInWithUsernameAndPassword=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"username must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}})})},e.prototype.sendPhoneCode=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),t=this.formatPhone(e),[4,this.getVerification({phone_number:t})];case 1:return r.sent(),[2,!0]}})})},e.prototype.signUpWithPhoneCode=function(e,t,r){return o(this,void 0,Promise,function(){var o;return i(this,function(i){switch(i.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),o=this.formatPhone(e),[4,this.signUp(n({phone_number:o,verification_code:t},r?{password:r}:{}))];case 1:return i.sent(),[2,this.createLoginState()]}})})},e.prototype.signInWithPhoneCodeOrPassword=function(e){return o(this,void 0,Promise,function(){var t,r,n,o;return i(this,function(i){switch(i.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),o=this.formatPhone(t),n?[4,this.signIn({username:o,password:n})]:[3,2];case 1:return i.sent(),[3,5];case 2:return r?[4,this.signIn({username:o,verification_token:r})]:[3,4];case 3:return i.sent(),[3,5];case 4:(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode or password must be provided"),i.label=5;case 5:return[2,this.createLoginState()]}})})},e.prototype.forceResetPwdByPhoneCode=function(e){return o(this,void 0,Promise,function(){var t,r,n,o;return i(this,function(i){switch(i.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof r&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),"string"!=typeof n&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),o=this.formatPhone(t),[4,this.resetPassword({phone_number:o,new_password:n,verification_token:r})];case 1:return i.sent(),[4,this.signIn({username:o,password:n})];case 2:return i.sent(),[2,this.createLoginState()]}})})},e.prototype.shouldRefreshAccessToken=function(e){throw new Error("[v1 兼容] shouldRefreshAccessToken() 在当前版本中无法实现。 建议使用 auth.onAuthStateChange(callback) 来监听 TOKEN_REFRESHED 事件替代。")},e.prototype.onLoginStateExpired=function(e){var t=this;this.onLoginStateChanged(function(r){(null==r?void 0:r.eventType)===s.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR&&e.call(t)})},e.prototype.onAccessTokenRefreshed=function(e){var t=this;this.onAuthStateChange(function(r){r===s.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED&&e.call(t)})},e.prototype.onAnonymousConverted=function(e){var t=this;this.onAuthStateChange(function(r){r===s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&e.call(t)})},e.prototype.onLoginTypeChanged=function(e){var t=this;this.onAuthStateChange(function(r){r!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&r!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT||e.call(t)})},e}();t.AuthV1Compat=h,t.applyUserV1Compat=function(e){e.prototype.linkWithTicket=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.linkWithTicket() 在当前版本中无法实现。 建议使用 auth.signInWithCustomTicket(() => Promise.resolve(ticket)) 替代。")})})},e.prototype.linkWithRedirect=function(e){throw new Error("[v1 兼容] User.linkWithRedirect() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")},e.prototype.updateEmail=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"newEmail must be a string"),[4,this.updateUserBasicInfo({email:e})];case 1:return t.sent(),[2]}})})},e.prototype.linkWithPhoneNumber=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.linkWithPhoneNumber() 在当前版本中无法实现。 建议使用 auth.bindPhoneNumber({ phone_number, verification_token, sudo_token }) 替代。")})})},e.prototype.updatePhoneNumber=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.updatePhoneNumber() 在当前版本中无法实现。 建议使用 auth.updateUser({ phone: newPhoneNumber }) 替代。")})})},e.prototype.unlink=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.unlink() 在当前版本中无法实现。 建议使用 auth.unlinkIdentity({ provider: loginType }) 替代。")})})}}},304:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=void 0;var n=r(895);t.registerAuth=n.registerAuth;try{window.registerAuth=t.registerAuth}catch(e){}},413:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Auth=void 0;var u=r(949),c=r(257),l=r(462),h=r(631),d=a(r(639)),f=r(308);function p(e,t){var n;return o(this,void 0,void 0,function(){var s,a=this;return i(this,function(u){s=function(){return o(a,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,1,,6]),[2,r(814)];case 1:e.sent(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,Promise.resolve().then(r.t.bind(r,814,23))];case 3:return[2,e.sent()];case 4:return e.sent(),[2];case 5:return[3,6];case 6:return[2]}})})};try{if(((null===(n=null==t?void 0:t.root)||void 0===n?void 0:n.globalThis)||globalThis).IS_MP_BUILD)return[2]}catch(t){if(e)return[2,s()]}return[2]})})}var v=function(){function e(e){var t=e.request,r=e.credentialsClient;if(!r){var o={apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,storage:e.storage,env:e.env,baseRequest:e.baseRequest,anonymousSignInFunc:e.anonymousSignInFunc,wxCloud:e.wxCloud,onCredentialsError:e.onCredentialsError,headers:e.headers||{},i18n:e.i18n,debug:e.debug};r=new c.OAuth2Client(o)}if(!t){var i=r.request.bind(r),s=new l.Captcha(n({env:e.env,clientId:e.clientId,request:i,storage:e.storage,adapter:e.adapter,oauthInstance:this},e.captchaOptions));t=s.request.bind(s)}this.config={env:e.env,apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,request:t,credentialsClient:r,storage:e.storage||c.defaultStorage,adapter:e.adapter}}return e.parseParamsToSearch=function(e){return Object.keys(e).forEach(function(t){e[t]||delete e[t]}),new d.default(e).toString()},e.prototype.getParamsByVersion=function(e,t){var r,n=(0,h.deepClone)(e),o=(null===(r={v2:u.ApiUrlsV2}[null==n?void 0:n.version])||void 0===r?void 0:r[t])||u.ApiUrls[t];return n&&delete n.version,{params:n,url:o}},e.prototype.signIn=function(e){return o(this,void 0,Promise,function(){var t,r,o,s;return i(this,function(i){switch(i.label){case 0:return t=e.version||"v1",(r=this.getParamsByVersion(e,"AUTH_SIGN_IN_URL")).params.query&&delete r.params.query,[4,this.getEncryptParams(r.params)];case 1:return o=i.sent(),[4,this.config.request(r.url,{method:"POST",body:o})];case 2:return s=i.sent(),[4,this.config.credentialsClient.setCredentials(n(n({},s),{version:t}))];case 3:return i.sent(),[2,Promise.resolve(s)]}})})},e.prototype.signInAnonymously=function(e,t){return void 0===e&&(e={}),void 0===t&&(t=!1),o(this,void 0,Promise,function(){var r;return i(this,function(n){switch(n.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:e,useWxCloud:t})];case 1:return r=n.sent(),[4,this.config.credentialsClient.setCredentials(r)];case 2:return n.sent(),[2,Promise.resolve(r)]}})})},e.prototype.signUp=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_UP_URL,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}})})},e.prototype.signOut=function(e){return o(this,void 0,Promise,function(){var t,r,n,o;return i(this,function(i){switch(i.label){case 0:if(t={},!e)return[3,6];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.config.request(u.ApiUrls.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:e})];case 2:return t=i.sent(),[3,4];case 3:return(r=i.sent()).error!==u.ErrorType.UNAUTHENTICATED&&console.log("sign_out_error",r),[3,4];case 4:return[4,this.config.credentialsClient.setCredentials()];case 5:return i.sent(),[2,t];case 6:return[4,this.config.credentialsClient.getAccessToken()];case 7:return n=i.sent(),[4,this.config.request(u.ApiUrls.AUTH_REVOKE_URL,{method:"POST",body:{token:n}})];case 8:return o=i.sent(),[4,this.config.credentialsClient.setCredentials()];case 9:return i.sent(),[2,Promise.resolve(o)]}})})},e.prototype.revokeAllDevices=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})];case 1:return e.sent(),[2]}})})},e.prototype.revokeDevice=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.config.request(u.ApiUrls.AUTHORIZED_DEVICES_DELETE_URL+e.device_id,{method:"DELETE",withCredentials:!0})];case 1:return t.sent(),[2]}})})},e.prototype.getVerification=function(e,t){return o(this,void 0,Promise,function(){var r,n;return i(this,function(o){switch(o.label){case 0:return r=!1,"CUR_USER"!==e.target?[3,1]:(r=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:o.sent()&&(r=!0),o.label=3;case 3:return(n=(0,h.deepClone)(e)).phone_number&&!/^\+\d{1,3}\s+\d+/.test(n.phone_number)&&(n.phone_number="+86 ".concat(n.phone_number)),[2,this.config.request(u.ApiUrls.VERIFICATION_URL,{method:"POST",body:n,withCaptcha:(null==t?void 0:t.withCaptcha)||!1,withCredentials:r})]}})})},e.prototype.verify=function(e){return o(this,void 0,Promise,function(){var t,r;return i(this,function(o){switch(o.label){case 0:return t=this.getParamsByVersion(e,"VERIFY_URL"),[4,this.config.request(t.url,{method:"POST",body:t.params})];case 1:return r=o.sent(),"v2"!==(null==e?void 0:e.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(n(n({},r),{version:"v2"}))];case 2:o.sent(),o.label=3;case 3:return[2,r]}})})},e.prototype.genProviderRedirectUri=function(t){return o(this,void 0,Promise,function(){var r,n,o,a,c;return i(this,function(i){return r=t.provider_redirect_uri,n=t.other_params,o=void 0===n?{}:n,a=s(t,["provider_redirect_uri","other_params"]),r&&!a.redirect_uri&&(a.redirect_uri=r),c="".concat(u.ApiUrls.PROVIDER_URI_URL,"?").concat(e.parseParamsToSearch(a)),Object.keys(o).forEach(function(e){var t=o[e];("sign_out_uri"!==e||(null==t?void 0:t.length)>0)&&(c+="&other_params[".concat(e,"]=").concat(encodeURIComponent(t)))}),[2,this.config.request(c,{method:"GET"})]})})},e.prototype.grantProviderToken=function(e,t){return void 0===t&&(t=!1),o(this,void 0,Promise,function(){return i(this,function(r){return[2,this.config.request(u.ApiUrls.PROVIDER_TOKEN_URL,{method:"POST",body:e,useWxCloud:t})]})})},e.prototype.patchProviderToken=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})]})})},e.prototype.signInWithProvider=function(e,t){return void 0===t&&(t=!1),o(this,void 0,Promise,function(){var r,o;return i(this,function(i){switch(i.label){case 0:return r=this.getParamsByVersion(e,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:t})];case 1:return o=i.sent(),[4,this.config.credentialsClient.setCredentials(n(n({},o),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return i.sent(),[2,Promise.resolve(o)]}})})},e.prototype.toBindIdentity=function(e){var t,r;return o(this,void 0,void 0,function(){var n,o,s,a;return i(this,function(i){switch(i.label){case 0:return(o=e.credentials)?[3,2]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 1:o=i.sent(),i.label=2;case 2:n=o,i.label=3;case 3:return i.trys.push([3,5,,6]),[4,this.bindWithProvider({provider_token:e.provider_token},n)];case 4:return i.sent(),s={data:{type:u.OAUTH_TYPE.BIND_IDENTITY,provider:e.provider},error:null},[3,6];case 5:return a=i.sent(),s={data:{type:u.OAUTH_TYPE.BIND_IDENTITY},error:new f.AuthError(a)},[3,6];case 6:return e.fireEvent&&(null===(r=null===(t=this.config.eventBus)||void 0===t?void 0:t.fire)||void 0===r||r.call(t,u.EVENTS.AUTH_STATE_CHANGED,{event:u.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:s})),[2,s]}})})},e.prototype.getInitialSession=function(){return o(this,void 0,Promise,function(){var e,t,r,o,s,a,c,l,h,d,p,v,_,m,y;return i(this,function(i){switch(i.label){case 0:e={},i.label=1;case 1:if(i.trys.push([1,12,,13]),"undefined"==typeof window||"undefined"==typeof document)return[2,{data:null,error:null}];if(t=new URLSearchParams(null===location||void 0===location?void 0:location.search),r=t.get("code"),o=t.get("state"),!r||!o)return[2,{data:null,error:null}];s=null;try{s=JSON.parse(sessionStorage.getItem(o)||"null")}catch(e){}return e={type:null==s?void 0:s.type},a=t.get("error"),c=t.get("error_description"),a||c?[2,{data:e,error:new f.AuthError({message:c||a||"Unknown error from OAuth provider"})}]:(l=(null==s?void 0:s.provider)||t.get("provider"))?(h=location.origin+location.pathname,[4,this.grantProviderToken({provider_id:l,provider_redirect_uri:h,provider_code:r})]):[2,{data:e,error:new f.AuthError({message:"Provider is required for OAuth verification"})}];case 2:return d=i.sent().provider_token,p=void 0,v=null,_=void 0,s.type!==u.OAUTH_TYPE.BIND_IDENTITY?[3,5]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 3:return p=i.sent(),[4,this.toBindIdentity({provider:l,provider_token:d,credentials:p})];case 4:return _=i.sent(),[3,11];case 5:return s.type!==u.OAUTH_TYPE.SIGN_IN?[3,11]:(_=this.getParamsByVersion({provider:l},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(_.url,{method:"POST",body:{provider_token:d}})]);case 6:p=i.sent(),i.label=7;case 7:return i.trys.push([7,9,,10]),[4,this.getUserInfo({credentials:p})];case 8:return v=i.sent(),[3,10];case 9:return m=i.sent(),console.error("get user info error",m),[3,10];case 10:_={data:n(n({},e),{session:p,user:v}),error:null},i.label=11;case 11:t.delete("code"),t.delete("state"),t.delete("provider"),this.restoreUrlState(void 0===(null==s?void 0:s.search)?"?".concat(t.toString()):s.search,(null==s?void 0:s.hash)||location.hash);try{sessionStorage.removeItem(o)}catch(e){}return[2,_];case 12:return y=i.sent(),[2,{data:e,error:new f.AuthError(y)}];case 13:return[2]}})})},e.prototype.signInCustom=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}})})},e.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),o(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}})})},e.prototype.bindWithProvider=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(r){return[2,this.config.request(u.ApiUrls.PROVIDER_BIND_URL,{method:"POST",body:e,withCredentials:!0,getCredentials:t?function(){return t}:void 0})]})})},e.prototype.getUserProfile=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.getUserInfo(e)]})})},e.prototype.getUserInfo=function(e){var t,r,n;return void 0===e&&(e={}),o(this,void 0,Promise,function(){var o,s,a,u,c;return i(this,function(i){switch(i.label){case 0:return o=this.getParamsByVersion(e,"USER_ME_URL"),(null===(t=o.params)||void 0===t?void 0:t.query)&&(s=new d.default(o.params.query),o.url+="?".concat(s.toString())),[4,this.config.request(o.url,{method:"GET",withCredentials:!0,getCredentials:e.credentials?function(){return e.credentials}:void 0})];case 1:if((a=i.sent()).sub&&(a.uid=a.sub),null===(r=a.providers)||void 0===r?void 0:r.length)try{"undefined"!=typeof wx&&wx.getAccountInfoSync&&(u=null===(n=wx.getAccountInfoSync().miniProgram)||void 0===n?void 0:n.appId,(null==(c=a.providers.find(function(e){return e.id===u}))?void 0:c.provider_user_id)&&(a.open_id=c.provider_user_id))}catch(e){}return[2,a]}})})},e.prototype.getWedaUserInfo=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.config.request(u.ApiUrls.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,e.sent()]}})})},e.prototype.deleteMe=function(t){return o(this,void 0,Promise,function(){var r,n;return i(this,function(o){return r=this.getParamsByVersion(t,"USER_ME_URL"),n="".concat(r.url,"?").concat(e.parseParamsToSearch(r.params)),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]})})},e.prototype.hasLoginState=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}})})},e.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},e.prototype.getLoginState=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.credentialsClient.getCredentialsAsync()]})})},e.prototype.transByProvider=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})]})})},e.prototype.grantToken=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){return t=this.getParamsByVersion(e,"AUTH_TOKEN_URL"),[2,this.config.request(t.url,{method:"POST",body:t.params})]})})},e.prototype.getProviders=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.request(u.ApiUrls.PROVIDER_LIST,{method:"GET",withCredentials:!0})]})})},e.prototype.unbindProvider=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})]})})},e.prototype.checkPassword=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.editContact=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})]})})},e.prototype.setPassword=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})]})})},e.prototype.updatePasswordByOld=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return[4,this.sudo({password:e.old_password})];case 1:return t=r.sent(),[2,this.setPassword({sudo_token:t.sudo_token,new_password:e.new_password})]}})})},e.prototype.sudo=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.SUDO_URL),{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.sendVerificationCodeToCurrentUser=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return e.target="CUR_USER",[2,this.config.request(u.ApiUrls.VERIFICATION_URL,{method:"POST",body:e,withCredentials:!0,withCaptcha:!0})]})})},e.prototype.changeBoundProvider=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(u.ApiUrls.PROVIDER_LIST,"/").concat(e.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:e.trans_token},withCredentials:!0})]})})},e.prototype.setUserProfile=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})]})})},e.prototype.updateUserBasicInfo=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.queryUserProfile=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){return t=new d.default(e),[2,this.config.request("".concat(u.ApiUrls.USER_QUERY_URL,"?").concat(t.toString()),{method:"GET",withCredentials:!0})]})})},e.prototype.setCustomSignFunc=function(e){this.getCustomSignTicketFn=e},e.prototype.signInWithCustomTicket=function(){return o(this,void 0,Promise,function(){var e,t;return i(this,function(r){switch(r.label){case 0:return(e=this.getCustomSignTicketFn)?[4,e()]:[2,Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"})];case 1:return t=r.sent(),[2,this.signInCustom({provider_id:"custom",ticket:t})]}})})},e.prototype.resetPassword=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.AUTH_RESET_PASSWORD,{method:"POST",body:e})]})})},e.prototype.authorize=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.authorizeDevice=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.deviceAuthorize=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.AUTH_GET_DEVICE_CODE,{method:"POST",body:e})]})})},e.prototype.authorizeInfo=function(t){return o(this,void 0,Promise,function(){var r,n,o;return i(this,function(i){switch(i.label){case 0:return r="".concat(u.ApiUrls.AUTHORIZE_INFO_URL,"?").concat(e.parseParamsToSearch(t)),n=!0,o=!1,[4,this.hasLoginState()];case 1:return i.sent()&&(o=!0,n=!1),[2,this.config.request(r,{method:"GET",withBasicAuth:n,withCredentials:o})]}})})},e.prototype.checkUsername=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})]})})},e.prototype.checkIfUserExist=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){return t=new d.default(e),[2,this.config.request("".concat(u.ApiUrls.CHECK_IF_USER_EXIST,"?").concat(t.toString()),{method:"GET"})]})})},e.prototype.loginScope=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.credentialsClient.getScope()]})})},e.prototype.loginGroups=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.credentialsClient.getGroups()]})})},e.prototype.refreshTokenForce=function(e){return o(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return t=r.sent(),[4,this.config.credentialsClient.refreshToken(n(n({},t),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return[2,r.sent()]}})})},e.prototype.getCredentials=function(){return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.config.credentialsClient.getCredentials()]})})},e.prototype.getPublicKey=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.request(u.ApiUrlsV2.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]})})},e.prototype.getEncryptParams=function(e){return o(this,void 0,Promise,function(){var t,r,n,o,s,a;return i(this,function(i){switch(i.label){case 0:return t=e.isEncrypt,delete e.isEncrypt,r=(0,h.deepClone)(e),[4,p(t,this.config.adapter)];case 1:if(!(n=i.sent()))return[2,e];o="",s="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(a=i.sent(),o=a.public_key,s=a.public_key_thumbprint,!o||!s)throw a;return[3,5];case 4:throw i.sent();case 5:return[2,{params:n.getEncryptInfo({publicKey:o,payload:r}),public_key_thumbprint:s}]}})})},e.prototype.getProviderSubType=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.request(u.ApiUrls.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})]})})},e.prototype.verifyCaptchaData=function(e){var t=e.token,r=e.key;return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.config.request(u.ApiUrls.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:r},withCredentials:!1})]})})},e.prototype.createCaptchaData=function(e){var t=e.state,r=e.redirect_uri,n=void 0===r?void 0:r;return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.config.request(u.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:n},withCredentials:!1})]})})},e.prototype.getMiniProgramCode=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.GET_MINIPROGRAM_QRCODE,{method:"POST",body:e})]})})},e.prototype.getMiniProgramQrCodeStatus=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(u.ApiUrls.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:e})]})})},e.prototype.getUserBehaviorLog=function(e){return o(this,void 0,Promise,function(){var t,r;return i(this,function(n){return t={LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"},r="".concat(u.ApiUrls.GET_USER_BEHAVIOR_LOG,"?").concat(t[e.type],"&limit=").concat(e.limit).concat(e.page_token?"&page_token=".concat(e.page_token):""),[2,this.config.request(r,{method:"GET",withCredentials:!0})]})})},e.prototype.modifyPassword=function(e){return o(this,void 0,Promise,function(){var t,r,n,o,s,a;return i(this,function(i){switch(i.label){case 0:return t="",r="",[4,p(!0,this.config.adapter)];case 1:if(!(n=i.sent()))throw new Error("do not support encrypt, a encrypt util required.");i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=i.sent(),t=o.public_key,r=o.public_key_thumbprint,!t||!r)throw o;return[3,5];case 4:throw i.sent();case 5:return s=e.password?n.getEncryptInfo({publicKey:t,payload:e.password}):"",a=n.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(u.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:e.user_id,encrypt_password:s,encrypt_new_password:a,public_key_thumbprint:r}})]}})})},e.prototype.modifyPasswordWithoutLogin=function(e){return o(this,void 0,Promise,function(){var t,r,n,o,s,a;return i(this,function(i){switch(i.label){case 0:return t="",r="",[4,p(!0,this.config.adapter)];case 1:if(!(n=i.sent()))throw new Error("do not support encrypt, a encrypt util required.");i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=i.sent(),t=o.public_key,r=o.public_key_thumbprint,!t||!r)throw o;return[3,5];case 4:throw i.sent();case 5:return s=e.password?n.getEncryptInfo({publicKey:t,payload:e.password}):"",a=n.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(u.ApiUrlsV2.AUTH_RESET_PASSWORD,{method:"POST",body:{username:e.username,password:s,new_password:a,public_key_thumbprint:r}})]}})})},e.prototype.restoreUrlState=function(e,t){if(void 0!==e)try{var r=new URL(window.location.href);r.search=e,r.hash=t||"",window.history.replaceState(null,"",r.toString()),window.location.replace(r.toString())}catch(e){}},e}();t.Auth=v},308:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.isAuthError=t.AuthError=t.AuthErrorCategory=void 0;var i,s=r(949);!function(e){e.PROVIDER_NOT_ENABLED="PROVIDER_NOT_ENABLED",e.INVALID_CREDENTIALS="INVALID_CREDENTIALS",e.USER_NOT_FOUND="USER_NOT_FOUND",e.USER_STATUS_ABNORMAL="USER_STATUS_ABNORMAL",e.SERVICE_ERROR="SERVICE_ERROR",e.INVALID_PARAMS="INVALID_PARAMS",e.AUTH_METHOD_MISMATCH="AUTH_METHOD_MISMATCH",e.RATE_LIMITED="RATE_LIMITED",e.CAPTCHA_REQUIRED="CAPTCHA_REQUIRED",e.CAPTCHA_INVALID="CAPTCHA_INVALID",e.MFA_REQUIRED="MFA_REQUIRED",e.PRECONDITION_FAILED="PRECONDITION_FAILED",e.VERIFICATION_FAILED="VERIFICATION_FAILED",e.UNKNOWN="UNKNOWN"}(i=t.AuthErrorCategory||(t.AuthErrorCategory={}));var a="https://tcb.cloud.tencent.com/dev?envId=#/identity/login-manage",u="https://docs.cloudbase.net/api-reference/webv3-next/initialization",c=function(e){function t(t,r){var n,o=this,c=t.error_description||t.message;return(o=e.call(this,c)||this).__isAuthError=!0,o.name="AuthError",o.status=t.error,o.code=String(t.error||t.error_code||"unknown").toLowerCase(),o.errorCode="number"==typeof t.error_code?t.error_code:"string"==typeof t.error_code&&parseInt(t.error_code,10)||void 0,o.requestId=t.requestId,o.category=function(e,t,r){if(!e&&!t&&!r)return i.UNKNOWN;try{var n=(e||"").toLowerCase(),o="string"==typeof r?parseInt(r,10):r;return o===s.AuthErrorCode.CAPTCHA_REQUIRED||t===s.ErrorType.CAPTCHA_REQUIRED?i.CAPTCHA_REQUIRED:o===s.AuthErrorCode.CAPTCHA_INVALID||t===s.ErrorType.CAPTCHA_INVALID?i.CAPTCHA_INVALID:o===s.AuthErrorCode.MFA_PHONE_REQUIRED||t===s.ErrorType.MFA_PHONE_REQUIRED?i.MFA_REQUIRED:o===s.AuthErrorCode.LOGIN_TYPE_DISABLED||t===s.ErrorType.LOGIN_TYPE_DISABLED?i.PROVIDER_NOT_ENABLED:o===s.AuthErrorCode.RESOURCE_EXHAUSTED||t===s.ErrorType.RESOURCE_EXHAUSTED?i.RATE_LIMITED:o===s.AuthErrorCode.INTERNAL||o===s.AuthErrorCode.UNAVAILABLE||o===s.AuthErrorCode.UNIMPLEMENTED||o===s.AuthErrorCode.ABORTED?i.SERVICE_ERROR:o===s.AuthErrorCode.NOT_FOUND?i.USER_NOT_FOUND:o===s.AuthErrorCode.UNAUTHENTICATED?i.INVALID_CREDENTIALS:o===s.AuthErrorCode.INVALID_ARGUMENT&&(n.includes("验证码")||n.includes("verification")||n.includes("verification_code")||n.includes("verification_id")||n.includes("does not match")||n.includes("token expired")||n.includes("token error")||n.includes("过期"))?i.VERIFICATION_FAILED:t===s.ErrorType.PROVIDER_NOT_ENABLED||t===s.ErrorType.LOGIN_METHOD_DISABLED||n.includes("身份源")||n.includes("开启")||n.includes("identity provider")||n.includes("provider not enabled")||n.includes("login method")||n.includes("登录方式")||n.includes("not enabled")||n.includes("未开启")||n.includes("未启用")||n.includes("请联系开发者")||n.includes("anonymous login is not enabled")||n.includes("匿名登录未开启")?i.PROVIDER_NOT_ENABLED:t===s.ErrorType.FAILED_PRECONDITION||o===s.AuthErrorCode.FAILED_PRECONDITION&&!n.includes("请联系开发者")?n.includes("不存在")||n.includes("not found")||n.includes("未注册")?i.USER_NOT_FOUND:i.PRECONDITION_FAILED:t===s.ErrorType.INVALID_PASSWORD||t===s.ErrorType.INVALID_GRANT||t===s.ErrorType.INVALID_VERIFICATION_CODE||t===s.ErrorType.INVALID_USERNAME_OR_PASSWORD||t===s.ErrorType.INVALID_CREDENTIALS||t===s.ErrorType.WRONG_PASSWORD||t===s.ErrorType.UNAUTHENTICATED||t===s.ErrorType.INVALID_TWO_FACTOR||t===s.ErrorType.INVALID_TWO_FACTOR_RECOVERY||t===s.ErrorType.PASSWORD_NOT_SET||n.includes("密码不正确")||n.includes("password")||n.includes("invalid_password")||n.includes("凭据")||n.includes("credentials")||n.includes("验证码")||n.includes("verification")||n.includes("invalid_verification_code")||n.includes("invalid_username_or_password")||n.includes("username or password")||n.includes("用户名或密码")||n.includes("wrong password")||n.includes("incorrect password")?i.INVALID_CREDENTIALS:t===s.ErrorType.NOT_FOUND||t===s.ErrorType.USER_NOT_FOUND||n.includes("用户不存在")||n.includes("not found")||n.includes("user not found")||n.includes("no such user")||n.includes("user does not exist")?i.USER_NOT_FOUND:t===s.ErrorType.USER_BLOCKED||t===s.ErrorType.USER_PENDING||t===s.ErrorType.UNDER_REVIEW||t===s.ErrorType.INVALID_STATUS||n.includes("被封禁")||n.includes("blocked")||n.includes("pending")||n.includes("审核")||n.includes("review")||n.includes("locked")||n.includes("已锁定")?i.USER_STATUS_ABNORMAL:t===s.ErrorType.SERVER_ERROR||t===s.ErrorType.UNAVAILABLE||t===s.ErrorType.TEMPORARILY_UNAVAILABLE||t===s.ErrorType.INTERNAL||t===s.ErrorType.UNREACHABLE||t===s.ErrorType.DEADLINE_EXCEEDED||t===s.ErrorType.DATA_LOSS||t===s.ErrorType.ABORTED||n.includes("network")||n.includes("timeout")||n.includes("timed out")||n.includes("超时")||n.includes("smtp is not set")||n.includes("sms sender does not config")?i.SERVICE_ERROR:t===s.ErrorType.INVALID_ARGUMENT||t===s.ErrorType.INVALID_REQUEST||t===s.ErrorType.INVALID_SCOPE||t===s.ErrorType.INVALID_REQUEST_URI||t===s.ErrorType.INVALID_REQUEST_OBJECT||o===s.AuthErrorCode.INVALID_ARGUMENT?i.INVALID_PARAMS:t===s.ErrorType.PERMISSION_DENIED||t===s.ErrorType.ACCESS_DENIED||t===s.ErrorType.UNAUTHORIZED_CLIENT?i.PROVIDER_NOT_ENABLED:i.UNKNOWN}catch(e){return t}}(c,o.status,o.errorCode),o.helpMessage=function(e,t){var r=(null==t?void 0:t.method)||"signIn",n={signInWithPassword:"「用户名密码登录」",signInAnonymously:"「匿名登录」",signInWithOtp:"「短信验证码登录」或「邮箱验证码登录」",signUp:"「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"对应的第三方身份源",signInWithIdToken:"对应的第三方身份源",signInWithOpenId:"「微信小程序 OpenID 登录」",signInWithPhoneAuth:"「微信小程序手机号授权登录」",signInWithCustomTicket:"「自定义登录」",getVerification:"「短信验证码登录」或「邮箱验证码登录」",verify:"「短信验证码登录」或「邮箱验证码登录」",verifyOtp:"「短信验证码登录」或「邮箱验证码登录」",resetPasswordForEmail:"「邮箱验证码登录」",reauthenticate:"「短信验证码登录」或「邮箱验证码登录」"}[r]||"对应的登录方式";switch(e){case i.PROVIDER_NOT_ENABLED:return"[CloudBase Auth] 登录方式未开启\n\n"+" 当前调用的 ".concat(r,"() 所需的登录方式尚未在云开发控制台启用。\n")+" 需要开启的登录方式:".concat(n,"\n")+"\n 请按以下步骤开启:\n"+" 1. 打开云开发控制台:".concat(a,"\n")+" 2. 选择对应的云开发环境\n 3. 进入「登录授权」页面,在「登录方式」或「身份源列表」中开启所需的登录方式\n\n 各登录方法与所需登录方式的对应关系:\n - signInWithPassword → 「用户名密码登录」\n - signInAnonymously → 「匿名登录」\n - signInWithOtp/signUp → 「短信验证码登录」或「邮箱验证码登录」\n - signInWithOAuth/signInWithIdToken → 对应的第三方身份源\n\n 如使用 CLI/MCP 工具,可通过 auth 工具查询和配置身份源状态。\n"+" 更多帮助请参考文档:".concat(u);case i.INVALID_CREDENTIALS:return"[CloudBase Auth] 凭据验证失败\n\n"+" 调用 ".concat(r,"() 时凭据校验未通过。\n")+"\n 请按优先级逐项排查:\n 1. 确认用户名/邮箱/手机号是否拼写正确、格式完整\n 2. 确认密码是否正确(注意大小写、特殊字符、前后空格)\n 3. 确认用户账号确实存在(可通过 auth.isUsernameRegistered() 检查)\n 4. 确认凭据参数来源可靠(环境变量、配置文件中的值是否已正确设置)\n 5. 如使用加密登录(is_encrypt: true),请确认公钥版本正确\n\n 如忘记密码,可通过 auth.resetPasswordForEmail() 重置密码。\n\n 提示:如果是 AI agent / 自动化测试场景,请确认 ENV_ID、USERNAME、PASSWORD\n 等环境变量已正确传入,且对应用户已在目标环境中注册。";case i.USER_NOT_FOUND:return"[CloudBase Auth] 用户不存在\n\n 请检查以下项目:\n 1. 确认用户名/邮箱/手机号是否正确\n 2. 确认是在正确的云开发环境(envId)下操作\n 3. 如果是新用户,请先通过 auth.signUp() 注册\n"+" 4. 也可在云开发控制台手动创建用户:".concat(a,"\n")+"\n 提示:不同环境(开发/测试/生产)的用户库是隔离的,请确认 envId 正确。";case i.USER_STATUS_ABNORMAL:return"[CloudBase Auth] 用户状态异常\n\n 当前用户账号可能处于以下状态之一:\n - 账号已被封禁\n - 账号正在审核中\n - 账号已被锁定(多次密码错误)\n\n"+" 请联系管理员在云开发控制台检查用户状态:".concat(a);case i.SERVICE_ERROR:return"[CloudBase Auth] 服务异常\n\n 请检查以下项目:\n 1. 网络连接是否正常\n 2. 云开发环境是否正常运行\n 3. 稍后重试,如持续失败请联系技术支持\n\n 提示:如果是超时错误,请检查网络环境和请求频率。\n 常见服务端错误:smtp 未配置、短信服务未配置、wedaapis 未设置等。";case i.INVALID_PARAMS:return"[CloudBase Auth] 参数错误\n\n 请检查传入的参数是否符合要求:\n - 不能同时输入手机号和邮箱\n - 手机号格式需正确(如 +86 开头)\n - 必须提供手机号或邮箱\n\n"+" 参考 API 文档确认各参数的格式和约束:".concat(u);case i.AUTH_METHOD_MISMATCH:return"[CloudBase Auth] 登录方式不匹配\n\n"+" 调用 ".concat(r,"() 时遇到错误,可能原因:\n")+" - 匿名登录失败后尝试了用户名密码登录,但凭据不正确或用户不存在\n - 应使用匿名登录但传入了密码参数\n - 应使用密码登录但未传入正确的凭据\n\n 建议:\n 1. 明确当前场景需要的登录方式:\n - 无需用户注册 → auth.signInAnonymously()\n - 有用户名和密码 → auth.signInWithPassword({ username, password })\n - 第三方平台 → auth.signInWithOAuth({ provider })\n 2. 不要在同一流程中混合使用不同的登录方式\n 3. 每种登录方式需要在控制台开启对应的身份源\n"+" 4. 控制台地址:".concat(a);case i.RATE_LIMITED:return"[CloudBase Auth] 发送频率受限\n\n 验证码发送过于频繁,已触发频率限制。\n\n 限制规则:\n - 手机号:每分钟最多 1 条,每天有上限\n - 邮箱:每分钟有上限,每天有上限(默认 50 条)\n\n 建议:\n 1. 检查 error.retryAfter 获取建议等待时间\n 2. 在 UI 中显示倒计时,防止用户重复点击\n 3. 如业务需要更高频率,请联系技术支持调整限额";case i.CAPTCHA_REQUIRED:return"[CloudBase Auth] 需要滑块验证码\n\n 当前操作触发了风控策略,需要完成滑块验证。\n\n 处理方式:\n 1. 调用滑块验证码 SDK 展示验证组件\n 2. 用户完成验证后,将 captcha_token 附带到请求中重新发送\n 3. 可通过 getVerification 的 options.withCaptcha 参数自动携带验证码";case i.CAPTCHA_INVALID:return"[CloudBase Auth] 滑块验证码校验失败\n\n 提交的验证码 token 校验未通过(可能已过期或 client_id 不匹配)。\n\n 处理方式:\n 1. 刷新滑块验证码,让用户重新验证\n 2. 确认 captcha 组件初始化的 client_id 与认证配置一致";case i.MFA_REQUIRED:return"[CloudBase Auth] 需要 MFA 验证\n\n 当前操作要求用户绑定手机号进行多因素认证 (MFA)。\n\n 处理方式:\n 1. 引导用户进入手机号绑定流程\n 2. 绑定完成后重新执行原操作\n 3. error 中可能包含 MFA 详情信息";case i.PRECONDITION_FAILED:return"[CloudBase Auth] 前置条件不满足\n\n 当前操作的前置条件不满足,常见原因:\n - 该手机号/邮箱已被其他账号绑定\n - 目标用户不存在或已存在(与 target 参数冲突)\n - 当前邮箱/手机号未注册用户\n\n 请根据 error.message 中的具体描述处理。";case i.VERIFICATION_FAILED:return'[CloudBase Auth] 验证码校验失败\n\n 验证码验证未通过,常见原因:\n - 验证码已过期(通常有效期为几分钟)\n - 验证码输入不正确\n - verification_id 无效或已被使用\n - 验证码不属于当前项目(project id does not match)\n\n 处理方式:\n 1. 提示用户"验证码已过期或不正确,请重新获取"\n 2. 调用 getVerification() 重新发送验证码\n 3. 确保 verification_id 与最新发送的验证码对应\n\n 注意:每次重新发送验证码后,之前的 verification_id 即失效。';default:return"[CloudBase Auth] 操作失败\n\n 如果问题持续存在,建议:\n"+" 1. 检查云开发控制台的认证配置:".concat(a,"\n")+" 2. 到官方问答社区提问:https://cnb.cool/tencent/cloud/cloudbase/community/-/issues\n"+" 3. 查阅文档:".concat(u)}}(o.category,r),o.loginMethodHint=(n=null==r?void 0:r.method)&&{signInWithPassword:"当前使用「用户名密码登录」,需确保:\n ✓ 控制台已开启「用户名密码登录」\n ✓ 用户已注册且凭据正确\n 如果不需要用户系统,建议改用 auth.signInAnonymously()",signInAnonymously:"当前使用「匿名登录」,需确保:\n ✓ 控制台已开启「匿名登录」\n 注意:匿名用户无需用户名密码,适用于快速体验或临时访问场景",signInWithOtp:"当前使用「OTP 验证码登录」,需确保:\n ✓ 控制台已开启「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"当前使用「第三方 OAuth 登录」,需确保:\n ✓ 控制台已配置并开启对应的第三方身份源"}[n]||"",o.category===i.RATE_LIMITED&&(o.retryAfter=t.retry_after||t.retryAfter||void 0),o}return o(t,e),t.prototype.toJSON=function(){return{name:this.name,message:this.message,code:this.code,errorCode:this.errorCode,status:this.status,requestId:this.requestId,category:this.category,retryAfter:this.retryAfter}},t}(Error);t.AuthError=c,t.isAuthError=function(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}},949:(e,t)=>{var r,n,o,i,s;Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.EVENTS=t.AUTH_STATE_CHANGED_TYPE=t.LOGIN_STATE_CHANGED_TYPE=t.AuthErrorCode=t.ErrorType=t.VerificationUsages=t.ApiUrlsV2=t.ApiUrls=t.AUTH_API_PREFIX=void 0,t.AUTH_API_PREFIX="/auth",(s=t.ApiUrls||(t.ApiUrls={})).AUTH_SIGN_UP_URL="/v1/signup",s.AUTH_TOKEN_URL="/v1/token",s.AUTH_REVOKE_URL="/v1/revoke",s.WEDA_USER_URL="/v1/plugin/weda/userinfo",s.AUTH_RESET_PASSWORD="/v1/reset",s.AUTH_GET_DEVICE_CODE="/v1/device/code",s.CHECK_USERNAME="/v1/checkUsername",s.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",s.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",s.AUTH_SIGN_IN_URL="/v1/signin",s.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",s.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",s.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",s.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",s.PROVIDER_TOKEN_URL="/v1/provider/token",s.PROVIDER_URI_URL="/v1/provider/uri",s.USER_ME_URL="/v1/user/me",s.AUTH_SIGNOUT_URL="/v1/user/signout",s.USER_QUERY_URL="/v1/user/query",s.USER_PRIFILE_URL="/v1/user/profile",s.USER_BASIC_EDIT_URL="/v1/user/basic/edit",s.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",s.PROVIDER_LIST="/v1/user/provider",s.PROVIDER_BIND_URL="/v1/user/provider/bind",s.PROVIDER_UNBIND_URL="/v1/user/provider",s.CHECK_PWD_URL="/v1/user/sudo",s.SUDO_URL="/v1/user/sudo",s.BIND_CONTACT_URL="/v1/user/contact",s.AUTH_SET_PASSWORD="/v1/user/password",s.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",s.AUTHORIZE_URL="/v1/user/authorize",s.AUTHORIZE_INFO_URL="/v1/user/authorize/info",s.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",s.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",s.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",s.VERIFICATION_URL="/v1/verification",s.VERIFY_URL="/v1/verification/verify",s.CAPTCHA_DATA_URL="/v1/captcha/data",s.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",s.GET_CAPTCHA_URL="/v1/captcha/init",s.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",s.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status",(i=t.ApiUrlsV2||(t.ApiUrlsV2={})).AUTH_SIGN_IN_URL="/v2/signin/username",i.AUTH_TOKEN_URL="/v2/token",i.USER_ME_URL="/v2/user/me",i.VERIFY_URL="/v2/signin/verificationcode",i.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",i.AUTH_PUBLIC_KEY="/v2/signin/publichkey",i.AUTH_RESET_PASSWORD="/v2/signin/password/update",(o=t.VerificationUsages||(t.VerificationUsages={})).REGISTER="REGISTER",o.SIGN_IN="SIGN_IN",o.PASSWORD_RESET="PASSWORD_RESET",o.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",o.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE",(n=t.ErrorType||(t.ErrorType={})).UNREACHABLE="unreachable",n.LOCAL="local",n.CANCELLED="cancelled",n.UNKNOWN="unknown",n.UNAUTHENTICATED="unauthenticated",n.RESOURCE_EXHAUSTED="resource_exhausted",n.FAILED_PRECONDITION="failed_precondition",n.INVALID_ARGUMENT="invalid_argument",n.DEADLINE_EXCEEDED="deadline_exceeded",n.NOT_FOUND="not_found",n.ALREADY_EXISTS="already_exists",n.PERMISSION_DENIED="permission_denied",n.ABORTED="aborted",n.OUT_OF_RANGE="out_of_range",n.UNIMPLEMENTED="unimplemented",n.INTERNAL="internal",n.UNAVAILABLE="unavailable",n.DATA_LOSS="data_loss",n.INVALID_PASSWORD="invalid_password",n.PASSWORD_NOT_SET="password_not_set",n.INVALID_STATUS="invalid_status",n.USER_PENDING="user_pending",n.USER_BLOCKED="user_blocked",n.INVALID_VERIFICATION_CODE="invalid_verification_code",n.TWO_FACTOR_REQUIRED="two_factor_required",n.INVALID_TWO_FACTOR="invalid_two_factor",n.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",n.UNDER_REVIEW="under_review",n.INVALID_REQUEST="invalid_request",n.UNAUTHORIZED_CLIENT="unauthorized_client",n.ACCESS_DENIED="access_denied",n.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",n.INVALID_SCOPE="invalid_scope",n.INVALID_GRANT="invalid_grant",n.SERVER_ERROR="server_error",n.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",n.INTERACTION_REQUIRED="interaction_required",n.LOGIN_REQUIRED="login_required",n.ACCOUNT_SELECTION_REQUIRED="account_selection_required",n.CONSENT_REQUIRED="consent_required",n.INVALID_REQUEST_URI="invalid_request_uri",n.INVALID_REQUEST_OBJECT="invalid_request_object",n.REQUEST_NOT_SUPPORTED="request_not_supported",n.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",n.REGISTRATION_NOT_SUPPORTED="registration_not_supported",n.CAPTCHA_REQUIRED="captcha_required",n.CAPTCHA_INVALID="captcha_invalid",n.PROVIDER_NOT_ENABLED="provider_not_enabled",n.LOGIN_METHOD_DISABLED="login_method_disabled",n.INVALID_USERNAME_OR_PASSWORD="invalid_username_or_password",n.INVALID_CREDENTIALS="invalid_credentials",n.WRONG_PASSWORD="wrong_password",n.USER_NOT_FOUND="user_not_found",n.MFA_PHONE_REQUIRED="mfa_phone_required",n.LOGIN_TYPE_DISABLED="login_type_disabled",n.PROVIDER_ERROR="provider_error",(r=t.AuthErrorCode||(t.AuthErrorCode={}))[r.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",r[r.NOT_FOUND=5]="NOT_FOUND",r[r.PERMISSION_DENIED=7]="PERMISSION_DENIED",r[r.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",r[r.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",r[r.ABORTED=10]="ABORTED",r[r.UNIMPLEMENTED=12]="UNIMPLEMENTED",r[r.INTERNAL=13]="INTERNAL",r[r.UNAVAILABLE=14]="UNAVAILABLE",r[r.UNAUTHENTICATED=16]="UNAUTHENTICATED",r[r.CAPTCHA_REQUIRED=4001]="CAPTCHA_REQUIRED",r[r.CAPTCHA_INVALID=4002]="CAPTCHA_INVALID",r[r.PROVIDER_ERROR=4019]="PROVIDER_ERROR",r[r.UNAUTHORIZED_CLIENT=4022]="UNAUTHORIZED_CLIENT",r[r.MFA_PHONE_REQUIRED=4042]="MFA_PHONE_REQUIRED",r[r.LOGIN_TYPE_DISABLED=4045]="LOGIN_TYPE_DISABLED",t.LOGIN_STATE_CHANGED_TYPE={SIGN_OUT:"sign_out",SIGN_IN:"sign_in",CREDENTIALS_ERROR:"credentials_error"},t.AUTH_STATE_CHANGED_TYPE={SIGNED_OUT:"SIGNED_OUT",SIGNED_IN:"SIGNED_IN",INITIAL_SESSION:"INITIAL_SESSION",PASSWORD_RECOVERY:"PASSWORD_RECOVERY",TOKEN_REFRESHED:"TOKEN_REFRESHED",USER_UPDATED:"USER_UPDATED",BIND_IDENTITY:"BIND_IDENTITY"},t.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",AUTH_STATE_CHANGED:"authStateChanged"},t.OAUTH_TYPE={SIGN_IN:"sign_in",BIND_IDENTITY:"bind_identity"},t.DEFAULT_NODE_ACCESS_SCOPE="node-sdk-scope"},538:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},84:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.openURIWithCallback=void 0;var s=r(689),a=r(616),u=function(e,t){var r;return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout(function(){return e.apply(null,n)},t)}},c=new s.CloudbaseEventEmitter,l="resolveCaptchaData",h="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",d="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",f="background:#6c757d;cursor:not-allowed";t.openURIWithCallback=function(e,t){return o(void 0,void 0,Promise,function(){var r,s,p,v;return i(this,function(_){return r=(0,a.parseCaptcha)(e),s=r.captchaData,p=r.state,v=r.token,function(e){var t=e.oauthInstance,r=e.captchaState,s="captcha-image",a=function(){return o(void 0,void 0,void 0,function(){var e,o;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t.createCaptchaData({state:r.state})];case 1:return e=i.sent(),r=n(n({},r),{captchaData:e.data,token:e.token}),document.getElementById(s).src=e.data,[3,3];case 2:return o=i.sent(),console.error("刷新图形验证码失败",o),[3,3];case 3:return[2]}})})},p=function(e,t,r){var n=document.createElement(e);return t&&(n.style.cssText=t),r&&(n.textContent=r),n},v=p("div","position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999"),_=p("div","position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:320px;padding:20px;background:#fff;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.2);z-index:1000");_.appendChild(p("p","margin-bottom:15px","请输入你看到的字符:"));var m=p("div","display:flex;align-items:center;justify-content:space-between;margin-bottom:15px"),y=p("img","width:100%;height:auto;border:1px solid #eee");y.id=s,y.src=r.captchaData,m.appendChild(y);var g=p("button",h,"刷新");g.onclick=u(function(){return o(void 0,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:g.textContent="加载中...",g.disabled=!0,g.style.cssText="".concat(h,";").concat(f),e.label=1;case 1:return e.trys.push([1,,3,4]),[4,a()];case 2:return e.sent(),[3,4];case 3:return g.textContent="刷新",g.disabled=!1,g.style.cssText=h,[7];case 4:return[2]}})})},500),m.appendChild(g),_.appendChild(m);var b=p("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");b.type="text",b.placeholder="输入字符",b.maxLength=4,_.appendChild(b);var E=p("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");_.appendChild(E);var w=function(e){E.textContent=e,E.style.display="block"},S=p("button",d,"确定");S.onclick=u(function(){return o(void 0,void 0,void 0,function(){var e,n,o,s;return i(this,function(i){switch(i.label){case 0:if(!(e=b.value.trim()))return w("请输入字符"),[2];E.style.display="none",S.textContent="验证中...",S.disabled=!0,S.style.cssText="".concat(d,";").concat(f),i.label=1;case 1:return i.trys.push([1,3,5,6]),[4,t.verifyCaptchaData({token:r.token,key:e})];case 2:return n=i.sent(),c.fire(l,n),console.log("图形验证码校验成功"),document.body.removeChild(v),document.body.removeChild(_),[3,6];case 3:return o=i.sent(),console.error("图形验证码校验失败",o),s=o.error_description||"图形验证码校验失败",w(s),b.value="",b.focus(),[4,a()];case 4:return i.sent(),[3,6];case 5:return S.textContent="确定",S.disabled=!1,S.style.cssText=d,[7];case 6:return[2]}})})},500),_.appendChild(S),document.body.appendChild(v),document.body.appendChild(_)}({oauthInstance:t,captchaState:{captchaData:s,state:p,token:v}}),[2,new Promise(function(e){console.log("等待图形验证码校验结果..."),c.on(l,function(t){e(null==t?void 0:t.data)})})]})})}},462:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.Captcha=void 0;var i=r(949),s=r(257),a=r(425),u=r(84),c=function(){function e(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=s.defaultStorage),this.config=e,this.tokenSectionName="captcha_".concat(e.clientId||e.env)}return e.prototype.isMatch=function(){var e,t,r;return(null===(r=null===(t=null===(e=this.config)||void 0===e?void 0:e.adapter)||void 0===t?void 0:t.isMatch)||void 0===r?void 0:r.call(t))||(0,a.isMp)()},e.prototype.request=function(e,t){return n(this,void 0,Promise,function(){var r,n,s,a;return o(this,function(o){switch(o.label){case 0:return t||(t={}),t.method||(t.method="GET"),r="".concat(t.method,":").concat(e),n=e,t.withCaptcha?[4,this.appendCaptchaTokenToURL(e,r,!1)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return o.trys.push([2,4,,7]),[4,this.config.request(n,t)];case 3:return s=o.sent(),[3,7];case 4:return(a=o.sent()).error!==i.ErrorType.CAPTCHA_REQUIRED&&a.error!==i.ErrorType.CAPTCHA_INVALID?[3,6]:[4,this.appendCaptchaTokenToURL(e,r,a.error===i.ErrorType.CAPTCHA_INVALID)];case 5:return e=o.sent(),[2,this.config.request(e,t)];case 6:return[2,Promise.reject(a)];case 7:return[2,s]}})})},e.prototype.getDefaultOpenURIWithCallback=function(){var e=this;return function(t){return(0,u.openURIWithCallback)(t,e.config.oauthInstance)}},e.prototype.getCaptchaToken=function(e,t){return n(this,void 0,Promise,function(){var r,n,s,a;return o(this,function(o){switch(o.label){case 0:return e?[3,2]:[4,this.findCaptchaToken()];case 1:if(r=o.sent())return[2,r];o.label=2;case 2:return[4,this.config.request(i.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:""},withCredentials:!1})];case 3:return n=o.sent(),s="".concat(n.data,"?state=").concat(encodeURIComponent(t),"&token=").concat(encodeURIComponent(n.token)),[4,this.config.openURIWithCallback(s)];case 4:return a=o.sent(),this.saveCaptchaToken(a),[2,a.captcha_token]}})})},e.prototype.appendCaptchaTokenToURL=function(e,t,r){return n(this,void 0,Promise,function(){var n;return o(this,function(o){switch(o.label){case 0:return[4,this.getCaptchaToken(r,t)];case 1:return n=o.sent(),e.indexOf("?")>0?e+="&captcha_token=".concat(n):e+="?captcha_token=".concat(n),[2,e]}})})},e.prototype.saveCaptchaToken=function(e){return n(this,void 0,void 0,function(){var t;return o(this,function(r){switch(r.label){case 0:return e.expires_at=new Date(Date.now()+1e3*(e.expires_in-10)),t=JSON.stringify(e),[4,this.config.storage.setItem(this.tokenSectionName,t)];case 1:return r.sent(),[2]}})})},e.prototype.findCaptchaToken=function(){return n(this,void 0,Promise,function(){var e,t;return o(this,function(r){switch(r.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=r.sent()))return[3,5];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),t.expires_at<new Date?[2,null]:[2,t.captcha_token];case 3:return r.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),[2,null];case 5:return[2,null]}})})},e}();t.Captcha=c},722:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseOAuth=t.AuthErrorCode=t.AUTH_STATE_CHANGED_TYPE=t.EVENTS=t.LOGIN_STATE_CHANGED_TYPE=t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.AUTH_API_PREFIX=t.weAppJwtDecodeAll=t.authModels=t.isAuthError=t.AuthErrorCategory=t.AuthError=t.Auth=void 0;var a=r(257),u=r(413),c=r(949),l=r(413);Object.defineProperty(t,"Auth",{enumerable:!0,get:function(){return l.Auth}});var h=r(308);Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return h.AuthError}}),Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return h.AuthErrorCategory}}),Object.defineProperty(t,"isAuthError",{enumerable:!0,get:function(){return h.isAuthError}}),t.authModels=s(r(538));var d=r(344);Object.defineProperty(t,"weAppJwtDecodeAll",{enumerable:!0,get:function(){return d.weAppJwtDecodeAll}});var f=r(949);Object.defineProperty(t,"AUTH_API_PREFIX",{enumerable:!0,get:function(){return f.AUTH_API_PREFIX}}),Object.defineProperty(t,"OAUTH_TYPE",{enumerable:!0,get:function(){return f.OAUTH_TYPE}}),Object.defineProperty(t,"DEFAULT_NODE_ACCESS_SCOPE",{enumerable:!0,get:function(){return f.DEFAULT_NODE_ACCESS_SCOPE}}),Object.defineProperty(t,"LOGIN_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return f.LOGIN_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"EVENTS",{enumerable:!0,get:function(){return f.EVENTS}}),Object.defineProperty(t,"AUTH_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return f.AUTH_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"AuthErrorCode",{enumerable:!0,get:function(){return f.AuthErrorCode}});var p=function(){function e(e){var t=e.apiOrigin,r=e.getApiOrigin,o=e.apiPath,i=void 0===o?c.AUTH_API_PREFIX:o,s=e.clientId,l=e.env,h=e.storage,d=e.request,f=e.baseRequest,p=e.anonymousSignInFunc,v=e.wxCloud,_=e.adapter,m=e.onCredentialsError,y=e.headers,g=e.i18n,b=e.useWxCloud,E=e.eventBus,w=e.detectSessionInUrl,S=e.debug;if(this.detectSessionInUrl=null!=w&&w,this.oauth2client=new a.OAuth2Client({apiOrigin:t,getApiOrigin:r,apiPath:i,clientId:s,env:l,storage:h,baseRequest:f||d,anonymousSignInFunc:p,wxCloud:v,onCredentialsError:m,headers:y||{},i18n:g,useWxCloud:b,eventBus:E,debug:S}),this.authApi=new u.Auth(n(n({credentialsClient:this.oauth2client},e),{request:d?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:_})),w)this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));else try{var I=new URL(window.location.href),A=I.searchParams.get("code"),T=I.searchParams.get("state"),P=JSON.parse(sessionStorage.getItem(T)||"null");A&&T&&(null==P?void 0:P.hash)&&(I.hash=P.hash,window.history.replaceState(null,"",I.toString()),window.location.replace(I.toString()))}catch(e){}}return e.prototype.initializeSession=function(e){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(e),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))},e}();t.CloudbaseOAuth=p},877:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Syntax=t.ErrorType=void 0;var n,o=r(949);Object.defineProperty(t,"ErrorType",{enumerable:!0,get:function(){return o.ErrorType}}),(n=t.Syntax||(t.Syntax={})).CLIENT_ID="client_id",n.CLIENT_SECRET="client_secret",n.RESPONSE_TYPE="response_type",n.SCOPE="scope",n.STATE="state",n.REDIRECT_URI="redirect_uri",n.ERROR="error",n.ERROR_DESCRIPTION="error_description",n.ERROR_URI="error_uri",n.GRANT_TYPE="grant_type",n.CODE="code",n.ACCESS_TOKEN="access_token",n.TOKEN_TYPE="token_type",n.EXPIRES_IN="expires_in",n.USERNAME="username",n.PASSWORD="password",n.REFRESH_TOKEN="refresh_token"},257:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.OAuth2Client=t.defaultStorage=t.generateRequestId=t.toResponseError=t.defaultRequest=void 0;var a=r(877),u=r(949),c=r(873),l=r(631),h=r(547),d=r(344),f=r(425),p=r(683),v="x-request-id",_="x-device-id",m="device_id";function y(){return(0,c.uuidv4)()}t.defaultRequest=function(e,t){return o(this,void 0,Promise,function(){var r,n,o,s,u;return i(this,function(i){switch(i.label){case 0:r=null,n=null,i.label=1;case 1:return i.trys.push([1,4,,5]),(o=Object.assign({},t)).method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body)),[4,fetch(e,o)];case 2:return[4,i.sent().json()];case 3:return(null==(s=i.sent())?void 0:s.error)?(n=s).error_uri=new URL(e).pathname:r=s,[3,5];case 4:return u=i.sent(),n={error:a.ErrorType.UNREACHABLE,error_description:u.message,error_uri:new URL(e).pathname},[3,5];case 5:if(n)throw n;return[2,r]}})})},t.toResponseError=function(e,t){var r,n=t||{};if(e instanceof Error)r={error:n.error||a.ErrorType.LOCAL,error_description:n.error_description||e.message,error_uri:n.error_uri,details:n.details||e.stack};else{var o=e||{};r={error:n.error||o.error||a.ErrorType.LOCAL,error_description:n.error_description||o.error_description,error_uri:n.error_uri||o.error_uri,details:n.details||o.details}}return r},t.generateRequestId=y;var g=function(){function e(e){this._env=(null==e?void 0:e.env)||""}return e.prototype.getItem=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,window.localStorage.getItem("".concat(e).concat(this._env))]})})},e.prototype.removeItem=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return window.localStorage.removeItem("".concat(e).concat(this._env)),[2]})})},e.prototype.setItem=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(r){return window.localStorage.setItem("".concat(e).concat(this._env),t),[2]})})},e.prototype.getItemSync=function(e){return window.localStorage.getItem("".concat(e).concat(this._env))},e.prototype.removeItemSync=function(e){window.localStorage.removeItem("".concat(e).concat(this._env))},e.prototype.setItemSync=function(e,t){window.localStorage.setItem("".concat(e).concat(this._env),t)},e}();function b(e){var t=!0;return(null==e?void 0:e.expires_at)&&(null==e?void 0:e.access_token)&&(t=e.expires_at<new Date),t}t.defaultStorage=new g;var E=function(){function e(e){this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=e.tokenSectionName,this.storage=e.storage,this.clientId=e.clientId,this.singlePromise=new h.SinglePromise({clientId:this.clientId}),this.credentials=e.credentials||null}return e.prototype.getStorageCredentialsSync=function(){var e=null,t=this.storage.getItemSync(this.tokenSectionName);if(null!=t)try{(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at))}catch(t){this.storage.removeItem(this.tokenSectionName),e=null}return e},e.prototype.setCredentials=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return(null==e?void 0:e.expires_in)?((null==e?void 0:e.expires_at)||(e.expires_at=new Date(Date.now()+1e3*(e.expires_in-30))),this.storage?(t=JSON.stringify(e),[4,this.storage.setItem(this.tokenSectionName,t)]):[3,2]):[3,3];case 1:r.sent(),r.label=2;case 2:return this.credentials=e,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:r.sent(),r.label=5;case 5:this.credentials=null,r.label=6;case 6:return[2]}})})},e.prototype.setAccessKeyCredentials=function(e){this.accessKeyCredentials=e,e.scope===u.DEFAULT_NODE_ACCESS_SCOPE&&(this.credentials=e)},e.prototype.getCredentials=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){return[2,this.singlePromise.run("getCredentials",function(){return o(e,void 0,void 0,function(){var e,t;return i(this,function(r){switch(r.label){case 0:return b(this.credentials)?[4,this.getStorageCredentials()]:[3,2];case 1:if(e=r.sent(),t=e.credentials,e.isAccessKeyCredentials)return[2,t];this.credentials=t,r.label=2;case 2:return[2,this.credentials]}})})})]})})},e.prototype.getStorageCredentials=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){return[2,this.singlePromise.run("_getStorageCredentials",function(){return o(e,void 0,void 0,function(){var e,t,r;return i(this,function(n){switch(n.label){case 0:return e=null,t=!1,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(!(r=n.sent()))return[3,6];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(e=JSON.parse(r))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),e=null,[3,5];case 5:return[3,7];case 6:e=this.accessKeyCredentials||null,t=!0,n.label=7;case 7:return[2,{credentials:e,isAccessKeyCredentials:t}]}})})})]})})},e}();t.OAuth2Client=function(){function e(r){var n,o=this;this.initializePromise=null,this.lockAcquired=!1,this.pendingInLock=[],this.singlePromise=null,r.clientSecret||(r.clientSecret=""),!r.clientId&&r.env&&(r.clientId=r.env),this.apiOrigin=r.apiOrigin,this.getApiOriginFunc=r.getApiOrigin,this.apiPath=r.apiPath||u.AUTH_API_PREFIX,this.clientId=r.clientId,this.i18n=r.i18n,this.eventBus=r.eventBus,this.singlePromise=new h.SinglePromise({clientId:this.clientId}),this.retry=this.formatRetry(r.retry,e.defaultRetry),r.baseRequest?this.baseRequest=r.baseRequest:this.baseRequest=t.defaultRequest,this.tokenInURL=r.tokenInURL,this.headers=r.headers,this.storage=r.storage||t.defaultStorage,this.localCredentials=new E({tokenSectionName:"credentials_".concat(r.clientId),storage:this.storage,clientId:r.clientId}),this.clientSecret=r.clientSecret,r.clientId&&(this.basicAuth="Basic ".concat((0,d.weBtoa)("".concat(r.clientId,":").concat(this.clientSecret)))),this.wxCloud=r.wxCloud;try{(0,f.isMp)()&&(this.useWxCloud=r.useWxCloud,void 0===this.wxCloud&&r.env&&(wx.cloud.init({env:r.env}),this.wxCloud=wx.cloud))}catch(e){}this.refreshTokenFunc=r.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=r.anonymousSignInFunc,this.onCredentialsError=r.onCredentialsError,this.getInitialSession=r.getInitialSession,this.onInitialSessionObtained=r.onInitialSessionObtained,this.logDebugMessages=null!==(n=r.debug)&&void 0!==n&&n,p.langEvent.bus.on(p.langEvent.LANG_CHANGE_EVENT,function(e){var t;o.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||o.i18n})}return e.prototype.setGetInitialSession=function(e){this.getInitialSession=e},e.prototype.setOnInitialSessionObtained=function(e){this.onInitialSessionObtained=e},e.prototype.initialize=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(r){switch(r.label){case 0:return this.initializePromise?[4,this.initializePromise]:[3,2];case 1:case 3:case 5:return[2,r.sent()];case 2:return void 0===e?[3,4]:(this.initializePromise=e,[4,this.initializePromise]);case 4:return this.initializePromise=o(t,void 0,void 0,function(){var e=this;return i(this,function(t){switch(t.label){case 0:return[4,this._acquireLock(-1,function(){return o(e,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this._initialize()];case 1:return[2,e.sent()]}})})})];case 1:return[2,t.sent()]}})}),[4,this.initializePromise]}})})},e.prototype.setCredentials=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[2,this._acquireLock(-1,function(){return o(t,void 0,void 0,function(){return i(this,function(t){return[2,this.localCredentials.setCredentials(e)]})})})]}})})},e.prototype.setAccessKeyCredentials=function(e){return this.localCredentials.setAccessKeyCredentials(e)},e.prototype.getAccessToken=function(){return o(this,void 0,Promise,function(){var e,t;return i(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[4,this.getCredentials()];case 2:return(null==(e=r.sent())?void 0:e.scope)===u.DEFAULT_NODE_ACCESS_SCOPE||(null==e?void 0:e.access_token)?[2,Promise.resolve(e.access_token)]:(t={error:a.ErrorType.UNAUTHENTICATED},[2,Promise.reject(t)])}})})},e.prototype.request=function(t,r){var s,u;return o(this,void 0,Promise,function(){var o,c,l,h,d,f,p,m,g,b;return i(this,function(i){switch(i.label){case 0:return r||(r={}),o=this.formatRetry(r.retry,this.retry),r.headers=n(n({},r.headers),((b={})[null===(s=this.i18n)||void 0===s?void 0:s.LANG_HEADER_KEY]=null===(u=this.i18n)||void 0===u?void 0:u.lang,b)),this.headers&&(r.headers=n(n({},this.headers),r.headers)),r.headers[v]||(r.headers[v]=y()),r.headers[_]?[3,2]:[4,this.getDeviceId()];case 1:c=i.sent(),r.headers[_]=c,i.label=2;case 2:return(null==r?void 0:r.withBasicAuth)&&this.basicAuth&&(r.headers.Authorization=this.basicAuth),(null==r?void 0:r.withCredentials)?r.getCredentials?[4,r.getCredentials()]:[3,4]:[3,7];case 3:return h=i.sent(),[3,6];case 4:return[4,this.getCredentials()];case 5:h=i.sent(),i.label=6;case 6:return(l=h)&&(this.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+="access_token=".concat(l.access_token)):r.headers.Authorization="".concat(l.token_type," ").concat(l.access_token)),[3,8];case 7:this.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+="client_id=".concat(this.clientId)),i.label=8;case 8:t.startsWith("/")&&(d=this.getApiOriginFunc?this.getApiOriginFunc():this.apiOrigin,t="".concat(d).concat(this.apiPath).concat(t)),f=null,p=o+1,m=0,i.label=9;case 9:if(!(m<p))return[3,21];i.label=10;case 10:return i.trys.push([10,15,,18]),r.useWxCloud||this.useWxCloud?[4,this.wxCloudCallFunction(t,r)]:[3,12];case 11:return f=i.sent(),[3,14];case 12:return[4,this.baseRequest(t,r)];case 13:f=i.sent(),i.label=14;case 14:if(null==f?void 0:f.code)throw{error:f.code,error_description:f.message,error_uri:new URL(t).pathname};return[3,21];case 15:g=i.sent();try{g.requestId=g.requestId||r.headers[v]||""}catch(e){}return r.withCredentials&&g&&g.error===a.ErrorType.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,17];case 16:return i.sent(),[2,Promise.reject(g)];case 17:return m!==o&&g&&"unreachable"===g.error?[3,18]:[2,Promise.reject(g)];case 18:return[4,this.sleep(e.retryInterval)];case 19:i.sent(),i.label=20;case 20:return m++,[3,9];case 21:return[2,f]}})})},e.prototype.wxCloudCallFunction=function(e,t){var r;return o(this,void 0,Promise,function(){var o,s,u,c,h;return i(this,function(i){switch(i.label){case 0:o=null,s=null,i.label=1;case 1:i.trys.push([1,7,,8]),u="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,wx.getRendererUserAgent()];case 3:return u=i.sent(),[3,5];case 4:return i.sent(),[3,5];case 5:return[4,this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:e,method:t.method,headers:n({origin:"https://servicewechat.com","User-Agent":u},t.headers),body:t.body}})];case 6:return c=i.sent().result,(null===(r=null==c?void 0:c.body)||void 0===r?void 0:r.error_code)?(s=null==c?void 0:c.body).error_uri=(0,l.getPathName)(e):o=null==c?void 0:c.body,[3,8];case 7:return h=i.sent(),s={error:a.ErrorType.UNREACHABLE,error_description:h.message,error_uri:(0,l.getPathName)(e)},[3,8];case 8:if(s)throw s;return[2,o]}})})},e.prototype.getCredentials=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){switch(t.label){case 0:return[4,this.initializePromise];case 1:return t.sent(),[2,this._acquireLock(-1,function(){return o(e,void 0,void 0,function(){return i(this,function(e){return[2,this._getCredentials()]})})})]}})})},e.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},e.prototype.getCredentialsAsync=function(){return this.getCredentials()},e.prototype.getScope=function(){var e;return o(this,void 0,Promise,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=n.sent())?[2,t.scope]:(r="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}})})},e.prototype.getGroups=function(){var e;return o(this,void 0,Promise,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=n.sent())?[2,t.groups]:(r="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}})})},e.prototype.refreshToken=function(e,t){return o(this,void 0,Promise,function(){var r=this;return i(this,function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[2,this._acquireLock(-1,function(){return o(r,void 0,void 0,function(){return i(this,function(r){return[2,this._refreshToken(e,t)]})})})]}})})},e.prototype._refreshToken=function(e,t){return o(this,void 0,Promise,function(){var r=this;return i(this,function(n){return[2,this.singlePromise.run("_refreshToken",function(){return o(r,void 0,void 0,function(){var r,n,o,s,c,l,h;return i(this,function(i){switch(i.label){case 0:if((null==e?void 0:e.scope)===u.DEFAULT_NODE_ACCESS_SCOPE)return[2,e];if(!e||!e.refresh_token)return o="no refresh token found in credentials",null===(s=this.onCredentialsError)||void 0===s||s.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];i.label=1;case 1:return i.trys.push([1,4,,7]),[4,this.refreshTokenFunc(e.refresh_token,e)];case 2:return r=i.sent(),[4,this.localCredentials.setCredentials(r)];case 3:return i.sent(),null===(c=this.eventBus)||void 0===c||c.fire(u.EVENTS.AUTH_STATE_CHANGED,{event:u.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED}),[2,r];case 4:if(n=i.sent(),null==t?void 0:t.throwError)throw n;return n.error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return i.sent(),o=n.error_description,null===(l=this.onCredentialsError)||void 0===l||l.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];case 6:return null===(h=this.onCredentialsError)||void 0===h||h.call(this,{msg:n.error_description}),[2,Promise.reject(n)];case 7:return[2]}})})})]})})},e.prototype.anonymousLogin=function(e){return o(this,void 0,void 0,function(){var t=this;return i(this,function(r){return[2,this.singlePromise.run("_anonymousLogin",function(){return o(t,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return this.anonymousSignInFunc?[4,this.anonymousSignInFunc(e)]:[3,4];case 1:return t=n.sent(),(r=t)?[3,3]:[4,this.localCredentials.getCredentials()];case 2:r=n.sent(),n.label=3;case 3:return e=r,[3,6];case 4:return[4,this.anonymousSignIn(e)];case 5:e=n.sent(),n.label=6;case 6:return[2,e]}})})})]})})},e.prototype.checkRetry=function(t){var r=null;if(("number"!=typeof t||t<e.minRetry||t>e.maxRetry)&&(r={error:a.ErrorType.UNREACHABLE,error_description:"wrong options param: retry"}),r)throw r;return t},e.prototype.formatRetry=function(e,t){return void 0===e?t:this.checkRetry(e)},e.prototype.sleep=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,new Promise(function(t){setTimeout(function(){t()},e)})]})})},e.prototype.anonymousSignIn=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(r){return[2,this.singlePromise.run("_anonymous",function(){return o(t,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:if(!e||"anonymous"!==e.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];n.label=1;case 1:return n.trys.push([1,4,,7]),[4,this.request(u.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}})];case 2:return t=n.sent(),[4,this.localCredentials.setCredentials(t)];case 3:return n.sent(),[2,t];case 4:return(r=n.sent()).error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return n.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}})})})]})})},e.prototype.defaultRefreshTokenFunc=function(e,t){var r;return o(this,void 0,Promise,function(){var o,s,a;return i(this,function(i){switch(i.label){case 0:return void 0===e||""===e?(o="refresh token not found",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:o}),[2,this.unAuthenticatedError(o)]):(s=u.ApiUrls.AUTH_TOKEN_URL,"v2"===(null==t?void 0:t.version)&&(s=u.ApiUrlsV2.AUTH_TOKEN_URL),[4,this.request(s,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:e}})]);case 1:return a=i.sent(),[2,n(n({},a),{version:(null==t?void 0:t.version)||"v1"})]}})})},e.prototype.getDeviceId=function(){return o(this,void 0,Promise,function(){var e;return i(this,function(t){switch(t.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(m)];case 1:return"string"==typeof(e=t.sent())&&e.length>=16&&e.length<=48?[3,3]:(e=(0,c.uuidv4)(),[4,this.storage.setItem(m,e)]);case 2:t.sent(),t.label=3;case 3:return this.deviceID=e,[2,e]}})})},e.prototype.unAuthenticatedError=function(e){var t={error:a.ErrorType.UNAUTHENTICATED,error_description:e};return Promise.reject(t)},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logDebugMessages&&console.log.apply(console,s(["[OAuth2Client]"],e,!1))},e.prototype._initialize=function(){return o(this,void 0,Promise,function(){var e,t,r,n,o,s;return i(this,function(i){switch(i.label){case 0:if(i.trys.push([0,11,12,13]),!this.getInitialSession)return this._debug("#_initialize()","no getInitialSession callback set, skipping"),[2,{error:null}];this._debug("#_initialize()","calling getInitialSession callback"),i.label=1;case 1:return i.trys.push([1,9,,10]),[4,this.getInitialSession()];case 2:return s=i.sent(),e=s.data,t=s.error,(null==e?void 0:e.session)?(this._debug("#_initialize()","session obtained from getInitialSession",e.session),[4,this.localCredentials.setCredentials(null==e?void 0:e.session)]):[3,4];case 3:i.sent(),i.label=4;case 4:if(!this.onInitialSessionObtained)return[3,8];this._debug("#_initialize()","calling onInitialSessionObtained callback"),i.label=5;case 5:return i.trys.push([5,7,,8]),[4,this.onInitialSessionObtained(e,t)];case 6:return i.sent(),[3,8];case 7:return r=i.sent(),this._debug("#_initialize()","error in onInitialSessionObtained",r),[3,8];case 8:return t?(this._debug("#_initialize()","error from getInitialSession",t),[2,{error:t}]):[2,{error:null}];case 9:return n=i.sent(),this._debug("#_initialize()","exception during getInitialSession",n),[2,{error:n instanceof Error?n:new Error(String(n))}];case 10:return[3,13];case 11:return o=i.sent(),this._debug("#_initialize()","unexpected error",o),[2,{error:o instanceof Error?o:new Error(String(o))}];case 12:return this._debug("#_initialize()","end"),[7];case 13:return[2]}})})},e.prototype._acquireLock=function(e,t){return o(this,void 0,Promise,function(){var r,n,a,u,c=this;return i(this,function(l){switch(l.label){case 0:this._debug("#_acquireLock","begin",e),l.label=1;case 1:if(l.trys.push([1,,10,11]),this.lockAcquired)return r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=o(c,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,r];case 1:return e.sent(),[4,t()];case 2:return[2,e.sent()]}})}),this.pendingInLock.push(o(c,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,n];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})),[2,n];this._debug("#_acquireLock","acquiring lock for client",this.clientId),l.label=2;case 2:return l.trys.push([2,,8,9]),this.lockAcquired=!0,a=t(),this.pendingInLock.push(o(c,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,a];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})),[4,a];case 3:l.sent(),l.label=4;case 4:return this.pendingInLock.length?(u=s([],this.pendingInLock,!0),[4,Promise.all(u)]):[3,6];case 5:return l.sent(),this.pendingInLock.splice(0,u.length),[3,4];case 6:return[4,a];case 7:return[2,l.sent()];case 8:return this._debug("#_acquireLock","releasing lock for client",this.clientId),this.lockAcquired=!1,[7];case 9:return[3,11];case 10:return this._debug("#_acquireLock","end"),[7];case 11:return[2]}})})},e.prototype._getCredentials=function(){var e,t,r;return o(this,void 0,Promise,function(){var n,o,s;return i(this,function(i){switch(i.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:if((null==(n=i.sent())?void 0:n.scope)===u.DEFAULT_NODE_ACCESS_SCOPE)return[2,n];if(!n)return s="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];if(!b(n))return[3,12];if(!n.refresh_token)return[3,9];i.label=2;case 2:return i.trys.push([2,4,,8]),[4,this._refreshToken(n)];case 3:return n=i.sent(),[3,8];case 4:return o=i.sent(),"anonymous"!==n.scope?[3,6]:[4,this.anonymousLogin(n)];case 5:return n=i.sent(),[3,7];case 6:return null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:o.error_description}),[2,Promise.reject(o)];case 7:return[3,8];case 8:return[3,12];case 9:return"anonymous"!==n.scope?[3,11]:[4,this.anonymousLogin(n)];case 10:return n=i.sent(),[3,12];case 11:return s="no refresh token found in credentials",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];case 12:return[2,n]}})})},e.defaultRetry=2,e.minRetry=0,e.maxRetry=5,e.retryInterval=1e3,e}()},344:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.weAppJwtDecodeAll=t.weappJwtDecode=t.base64_url_decode=t.weAtob=t.weBtoa=void 0;var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function o(e){var r=e.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(e){return decodeURIComponent((0,t.weAtob)(e).replace(/(.)/g,function(e){var t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0".concat(t)),"%".concat(t)}))}(r)}catch(e){return(0,t.weAtob)(r)}}t.weBtoa=function(e){for(var t,n,o,i,s="",a=0,u=(e=String(e)).length%3;a<e.length;){if((n=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");s+=r.charAt((t=n<<16|o<<8|i)>>18&63)+r.charAt(t>>12&63)+r.charAt(t>>6&63)+r.charAt(63&t)}return u?s.slice(0,u-3)+"===".substring(u):s},t.weAtob=function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!n.test(e))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var o,i,s="",a=0;a<e.length;)t=r.indexOf(e.charAt(a++))<<18|r.indexOf(e.charAt(a++))<<12|(o=r.indexOf(e.charAt(a++)))<<6|(i=r.indexOf(e.charAt(a++))),s+=64===o?String.fromCharCode(t>>16&255):64===i?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return s},t.base64_url_decode=o,t.weappJwtDecode=function(e,t){if("string"!=typeof e)throw new Error("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(o(e.split(".")[r]))}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}},t.weAppJwtDecodeAll=function(e){if("string"!=typeof e)throw new Error("Invalid token specified");try{var t=e.split(".").map(function(e,t){return 2===t?e:JSON.parse(o(e))});return{claims:t[1],header:t[0],signature:t[2]}}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}}},814:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getEncryptInfo=void 0;var o=n(r(12)),i=r(631);t.getEncryptInfo=function(e){var t=void 0===e?{}:e,r=t.publicKey,n=void 0===r?"":r,s=t.payload,a=void 0===s?{}:s;if(!n)return"";try{var u=(0,i.deepClone)(a),c=new o.default;return c.setPublicKey(n),c.encryptLong("object"==typeof u?JSON.stringify(u):u)}catch(e){console.error("encrypt error:",e)}return""}},547:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SinglePromise=void 0;var o=new Map,i=function(){function e(e){this.clientId=(null==e?void 0:e.clientId)||"",o=o||new Map}return e.prototype.run=function(e,t){return r(this,void 0,Promise,function(){var i,s=this;return n(this,function(a){return e="".concat(this.clientId,"_").concat(e),(i=o.get(e))||(i=new Promise(function(i,a){r(s,void 0,void 0,function(){var r,s,u;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return n.sent(),r=t(),s=i,[4,r];case 2:return s.apply(void 0,[n.sent()]),[3,5];case 3:return u=n.sent(),a(u),[3,5];case 4:return o.delete(e),[7];case 5:return[2]}})})}),o.set(e,i)),[2,i]})})},e.prototype.runIdlePromise=function(){return Promise.resolve()},e}();t.SinglePromise=i},631:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getPathName=t.deepClone=void 0,t.deepClone=function(e){var r=function(r){for(var n in e)e.hasOwnProperty(n)&&(r[n]=(0,t.deepClone)(e[n]));return r},n=null==e?"NullOrUndefined":Object.prototype.toString.call(e).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(n))return e.slice();switch(n){case"Object":return r(Object.create(Object.getPrototypeOf(e)));case"Array":return r([]);case"Date":return new Date(e.valueOf());case"RegExp":return new RegExp(e.source,(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":""));default:return e}},t.getPathName=function(e){var t=e.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return t&&t[2]||""}},425:(e,t)=>{function r(){if("undefined"==typeof globalThis)return!1;var e=globalThis.wx;if(void 0===e)return!1;if(void 0===globalThis.Page)return!1;if(!e.getDeviceInfo)return!1;if(!e.getStorageSync)return!1;if(!e.setStorageSync)return!1;if(!e.connectSocket)return!1;if(!e.request)return!1;try{if(!e.getDeviceInfo())return!1;if("qq"===e.getDeviceInfo().platform)return!1}catch(e){return!1}return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.isInMpWebView=t.isMp=void 0,t.isMp=r;var n=!1;function o(){n=n||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{r()||(n=n||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?o():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",o,!1))}catch(e){}t.isInMpWebView=function(){return n}},639:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){if(this.params={},"string"==typeof e)this.parse(e);else if(e&&"object"==typeof e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.append(t,e[t])}return e.prototype.parse=function(e){var t=this;e.split("&").forEach(function(e){var r=e.split("=").map(decodeURIComponent),n=r[0],o=r[1];t.append(n,o)})},e.prototype.append=function(e,t){this.params[e]?this.params[e]=this.params[e].concat([t]):this.params[e]=[t]},e.prototype.get=function(e){return this.params[e]?this.params[e][0]:null},e.prototype.getAll=function(e){return this.params[e]||[]},e.prototype.delete=function(e){delete this.params[e]},e.prototype.has=function(e){return Object.prototype.hasOwnProperty.call(this.params,e)},e.prototype.set=function(e,t){this.params[e]=[t]},e.prototype.toString=function(){var e=[],t=function(t){Object.prototype.hasOwnProperty.call(r.params,t)&&r.params[t].forEach(function(r){e.push("".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(r)))})},r=this;for(var n in this.params)t(n);return e.join("&")},e}();t.default=r},873:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=void 0,t.uuidv4=function(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}},563:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(92)),c=r(962);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,o=(0,c.isArray)(e)?e:[e];r<o.length;r++){var i=o[r],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:n({isMatch:s},a(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},92:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(829),c=r(962),l=r(464),h=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,s=e.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(t).forEach(function(e){c.append(e,t[e])}),c.append("key",n),c.append("file",r),this.request(i(i({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,Promise,function(){var t,r,n,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise(function(t){t({statusCode:200,tempFilePath:e.url})})]}})})},t.prototype.fetch=function(e){var t;return s(this,void 0,Promise,function(){var r,n,o,u,c,l,h,d,f,p,v,_,m,y=this;return a(this,function(g){switch(g.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,u=void 0!==o&&o,c=e.stream,l=void 0!==c&&c,h=e.signal,d=e.timeout,f=e.shouldThrowOnError,p=void 0===f||f,v=null!=d?d:this.timeout,h&&(h.aborted&&r.abort(),h.addEventListener("abort",function(){return r.abort()})),_=null,u&&v&&(_=setTimeout(function(){console.warn(y.timeoutMsg),r.abort(new Error(y.timeoutMsg))},v)),[4,fetch(n,i(i({},e),{signal:r.signal})).then(function(e){return s(y,void 0,void 0,function(){var t,r,n;return a(this,function(o){switch(o.label){case 0:return clearTimeout(_),p?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(_),Promise.reject(e)})];case 1:return m=g.sent(),[2,{data:l?m.body:(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers,response:m}]}})})},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise(function(o){var i=e.url,s=e.headers,a=void 0===s?{}:s,u=e.data,h=e.responseType,d=e.withCredentials,f=e.body,p=e.onUploadProgress,v=(0,c.formatUrl)((0,l.getProtocol)(),i,"get"===n?u:{}),_=new XMLHttpRequest;_.open(n,v),h&&(_.responseType=h);var m,y,g=e.signal;g&&(g.aborted?_.abort():g.addEventListener("abort",function(){return _.abort()},{once:!0})),Object.keys(a).forEach(function(e){_.setRequestHeader(e,a[e])}),p&&_.upload.addEventListener("progress",p),_.onreadystatechange=function(){var e={};if(4===_.readyState){var t=_.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach(function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o}),e.header=r,e.statusCode=_.status;try{e.data="blob"===h?_.response:JSON.parse(_.responseText)}catch(t){e.data="blob"===h?_.response:_.responseText}clearTimeout(m),o(e)}},t&&r.timeout&&(m=setTimeout(function(){console.warn(r.timeoutMsg),_.abort()},r.timeout)),y=(0,c.isFormData)(u)?u:"application/x-www-form-urlencoded"===a["content-type"]?(0,c.toQueryString)(u):f||(u?JSON.stringify(u):void 0),d&&(_.withCredentials=!0),_.send(y)})},t}(u.AbstractSDKRequest);t.WebRequest=h,t.genAdapter=function(){return{type:"default",root:window,reqClass:h,wsClass:WebSocket,localStorage}}},464:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var r="@cloudbase/js-sdk";t.setSdkName=function(e){r=e},t.getSdkName=function(){return r};var n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},519:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},778:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(r(464),t),o(r(519),t),t.OATUH_LOGINTYPE="constants"},517:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=r(962),s=r(778),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),h=s.findIndex(function(e){return u.test(e)});if(-1!==h){var d=s.filter(function(e,t){return t>h});d.unshift(s[h].replace(l,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,h=void 0===a?{}:a,d=e.title,f=e.messages,p=void 0===f?[]:f;return function(e,t,a){if(s.IS_DEBUG_MODE){var f=h.className||e.constructor.name,v=h.methodName||t,_=a.value,m=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex(function(e){return u.test(e)});if(-1!==r){var n=c.exec(t[r+1]||"");e=n?n[0]:""}return e}();a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=l({err:new Error,className:f,methodName:v,sourceLink:m});try{return _.apply(this,e)}catch(e){var n=e,o=e.message,s=e.error,a=e.error_description,u={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=p.map(function(e){return{type:"info",body:e}}))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,function(){var t,r,n,s,a,u,c,h;return o(this,function(o){switch(o.label){case 0:t=l({err:new Error,className:f,methodName:v,sourceLink:m}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,_.apply(this,e)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(h=JSON.parse(s),c.subtitle=h,h.code&&(t?(t.code=h.code,t.message=h.msg):(r.code=h.code,r.message=h.msg),n=t||r,c.content=p.map(function(e){return{type:"info",body:e}}))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(c),n;case 4:return[2]}})})}}}}},260:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(517),t)},683:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.langEvent=t.AbortController=t.jwt=t.helpers=t.utils=t.events=t.cache=t.adapters=t.constants=void 0;var a=i(r(778));t.constants=a;var u=i(r(563));t.adapters=u;var c=i(r(865));t.cache=c;var l=i(r(940));t.events=l;var h=i(r(991));t.langEvent=h;var d=i(r(962));t.utils=d;var f=i(r(260));t.helpers=f;var p=s(r(644));t.AbortController=p.default;var v={decode:s(r(254)).default};t.jwt=v},644:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){var e=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(t,r){"abort"===t&&e.listeners.push(r)}}}return e.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach(function(e){return e()}))},e}();t.default=r},865:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(829),u=r(962),c=r(778),l=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage),h=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(t.root));case"none":return new l(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return i(this,void 0,void 0,function(){var n;return s(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return i(this,void 0,void 0,function(){var n;return s(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}})})},e}();t.CloudbaseCache=h},940:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(962),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return o(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,c=this.listeners[n]?i([],this.listeners[n],!0):[];o<c.length;o++)c[o].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var l=new c;t.addEventListener=function(e,t){l.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),l.fire(e,t)},t.removeEventListener=function(e,t){l.off(e,t)}},991:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LANG_CHANGE_EVENT=t.bus=void 0;var n=r(940);t.bus=new n.CloudbaseEventEmitter,t.LANG_CHANGE_EVENT="lang_change"},962:function(e,t,r){var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=r(778);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)})},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach(function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))}),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise(function(t,r){e=function(e,n){return e?r(e):t(n)}});return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,u=void 0!==a&&a,c=e.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,h=s;l<h.length;l++){var d=h[l],f=d.type,p=d.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)}),t},t.parseCaptcha=function(e){var r={},o=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){e=o[1];var i=o[2];i&&(r=(0,t.parseQueryString)(i))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},12:(e,t,r)=>{var n;if(r.r(t),r.d(t,{default:()=>x}),!globalThis.IS_MP_BUILD){var o="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;function M(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function j(e,t){return e&t}function q(e,t){return e|t}function B(e,t){return e^t}function W(e,t){return e&~t}function H(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function V(e){for(var t=0;0!=e;)e&=e-1,++t;return t}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function F(e){var t,r,n="";for(t=0;t+3<=e.length;t+=3)r=parseInt(e.substring(t,t+3),16),n+=i.charAt(r>>6)+i.charAt(63&r);for(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=i.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=i.charAt(r>>2)+i.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function G(e){var t,r="",n=0,o=0;for(t=0;t<e.length&&"="!=e.charAt(t);++t){var s=i.indexOf(e.charAt(t));s<0||(0==n?(r+=M(s>>2),o=3&s,n=1):1==n?(r+=M(o<<2|s>>4),o=15&s,n=2):2==n?(r+=M(o),r+=M(s>>2),o=3&s,n=3):(r+=M(o<<2|s>>4),r+=M(15&s),n=0))}return 1==n&&(r+=M(o<<2)),r}var s,a,u={decode:function(e){var t;if(void 0===s){var r="0123456789ABCDEF";for(s={},t=0;t<16;++t)s[r.charAt(t)]=t;for(r=r.toLowerCase(),t=10;t<16;++t)s[r.charAt(t)]=t;for(t=0;t<8;++t)s[" \f\n\r\t \u2028\u2029".charAt(t)]=-1}var n=[],o=0,i=0;for(t=0;t<e.length;++t){var a=e.charAt(t);if("="==a)break;if(-1!=(a=s[a])){if(void 0===a)throw new Error("Illegal character at offset "+t);o|=a,++i>=2?(n[n.length]=o,o=0,i=0):o<<=4}}if(i)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},c={decode:function(e){var t;if(void 0===a){for(a=Object.create(null),t=0;t<64;++t)a["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)]=t;for(t=0;t<9;++t)a["= \f\n\r\t \u2028\u2029".charAt(t)]=-1}var r=[],n=0,o=0;for(t=0;t<e.length;++t){var i=e.charAt(t);if("="==i)break;if(-1!=(i=a[i])){if(void 0===i)throw new Error("Illegal character at offset "+t);n|=i,++o>=4?(r[r.length]=n>>16,r[r.length]=n>>8&255,r[r.length]=255&n,n=0,o=0):n<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=n>>10;break;case 3:r[r.length]=n>>16,r[r.length]=n>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(e){var t=c.re.exec(e);if(t)if(t[1])e=t[1];else{if(!t[2])throw new Error("RegExp out of sync");e=t[2]}return c.decode(e)}},l=1e13;class Y{constructor(e){this.buf=[+e||0]}mulAdd(e,t){var r,n,o=this.buf,i=o.length;for(r=0;r<i;++r)(n=o[r]*e+t)<l?t=0:n-=(t=0|n/l)*l,o[r]=n;t>0&&(o[r]=t)}sub(e){var t,r,n=this.buf,o=n.length;for(t=0;t<o;++t)(r=n[t]-e)<0?(r+=l,e=1):e=0,n[t]=r;for(;0===n[n.length-1];)n.pop()}toString(e){if(10!=(e||10))throw new Error("only base 10 is supported");for(var t=this.buf,r=t[t.length-1].toString(),n=t.length-2;n>=0;--n)r+=(l+t[n]).toString().substring(1);return r}valueOf(){for(var e=this.buf,t=0,r=e.length-1;r>=0;--r)t=t*l+e[r];return t}simplify(){var e=this.buf;return 1==e.length?e[0]:this}}var h,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)?)?$/,f=/^(\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 z(e,t){return e.length>t&&(e=e.substring(0,t)+"…"),e}class K{constructor(e,t){this.hexDigits="0123456789ABCDEF",e instanceof K?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=t)}get(e){if(void 0===e&&(e=this.pos++),e>=this.enc.length)throw new Error("Requesting byte offset "+e+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(e):this.enc[e]}hexByte(e){return this.hexDigits.charAt(e>>4&15)+this.hexDigits.charAt(15&e)}hexDump(e,t,r){for(var n="",o=e;o<t;++o)if(n+=this.hexByte(this.get(o)),!0!==r)switch(15&o){case 7:n+=" ";break;case 15:n+="\n";break;default:n+=" "}return n}isASCII(e,t){for(var r=e;r<t;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(e,t){for(var r="",n=e;n<t;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(e,t){for(var r="",n=e;n<t;){var o=this.get(n++);r+=o<128?String.fromCharCode(o):o>191&&o<224?String.fromCharCode((31&o)<<6|63&this.get(n++)):String.fromCharCode((15&o)<<12|(63&this.get(n++))<<6|63&this.get(n++))}return r}parseStringBMP(e,t){for(var r,n,o="",i=e;i<t;)r=this.get(i++),n=this.get(i++),o+=String.fromCharCode(r<<8|n);return o}parseTime(e,t,r){var n=this.parseStringISO(e,t),o=(r?d:f).exec(n);return o?(r&&(o[1]=+o[1],o[1]+=+o[1]<70?2e3:1900),n=o[1]+"-"+o[2]+"-"+o[3]+" "+o[4],o[5]&&(n+=":"+o[5],o[6]&&(n+=":"+o[6],o[7]&&(n+="."+o[7]))),o[8]&&(n+=" UTC","Z"!=o[8]&&(n+=o[8],o[9]&&(n+=":"+o[9]))),n):"Unrecognized time: "+n}parseInteger(e,t){for(var r,n=this.get(e),o=n>127,i=o?255:0,s="";n==i&&++e<t;)n=this.get(e);if(0===(r=t-e))return o?-1:0;if(r>4){for(s=n,r<<=3;!(128&(+s^i));)s=+s<<1,--r;s="("+r+" bit)\n"}o&&(n-=256);for(var a=new Y(n),u=e+1;u<t;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(e,t,r){for(var n=this.get(e),o="("+((t-e-1<<3)-n)+" bit)\n",i="",s=e+1;s<t;++s){for(var a=this.get(s),u=s==t-1?n:0,c=7;c>=u;--c)i+=a>>c&1?"1":"0";if(i.length>r)return o+z(i,r)}return o+i}parseOctetString(e,t,r){if(this.isASCII(e,t))return z(this.parseStringISO(e,t),r);var n=t-e,o="("+n+" byte)\n";n>(r/=2)&&(t=e+r);for(var i=e;i<t;++i)o+=this.hexByte(this.get(i));return n>r&&(o+="…"),o}parseOID(e,t,r){for(var n="",o=new Y,i=0,s=e;s<t;++s){var a=this.get(s);if(o.mulAdd(128,127&a),i+=7,!(128&a)){if(""===n)if((o=o.simplify())instanceof Y)o.sub(80),n="2."+o.toString();else{var u=o<80?o<40?0:1:2;n=u+"."+(o-40*u)}else n+="."+o.toString();if(n.length>r)return z(n,r);o=new Y,i=0}}return i>0&&(n+=".incomplete"),n}}class ${constructor(e,t,r,n,o){if(!(n instanceof Q))throw new Error("Invalid tag value.");this.stream=e,this.header=t,this.length=r,this.tag=n,this.sub=o}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(e){if(void 0===this.tag)return null;void 0===e&&(e=1/0);var t=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(t)?"false":"true";case 2:return this.stream.parseInteger(t,t+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+r,e);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);case 6:return this.stream.parseOID(t,t+r,e);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return z(this.stream.parseStringUTF(t,t+r),e);case 18:case 19:case 20:case 21:case 22:case 26:return z(this.stream.parseStringISO(t,t+r),e);case 30:return z(this.stream.parseStringBMP(t,t+r),e);case 23:case 24:return this.stream.parseTime(t,t+r,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(e){void 0===e&&(e="");var t=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(t+=" (encapsulates)"),t+="\n",null!==this.sub){e+=" ";for(var r=0,n=this.sub.length;r<n;++r)t+=this.sub[r].toPrettyString(e)}return t}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(e){var t=e.get(),r=127&t;if(r==t)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(e.pos-1));if(0===r)return null;t=0;for(var n=0;n<r;++n)t=256*t+e.get();return t}getHexStringValue(){var e=this.toHexString(),t=2*this.header,r=2*this.length;return e.substr(t,r)}static decode(e){var t;t=e instanceof K?e:new K(e,0);var r=new K(t),n=new Q(t),o=$.decodeLength(t),i=t.pos,s=i-r.pos,a=null,u=function(){var e=[];if(null!==o){for(var r=i+o;t.pos<r;)e[e.length]=$.decode(t);if(t.pos!=r)throw new Error("Content size is not correct for container starting at offset "+i)}else try{for(;;){var n=$.decode(t);if(n.tag.isEOC())break;e[e.length]=n}o=i-t.pos}catch(e){throw new Error("Exception while decoding undefined length content: "+e)}return e};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=t.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(e){a=null}if(null===a){if(null===o)throw new Error("We can't skip over an invalid tag with undefined length at offset "+i);t.pos=i+Math.abs(o)}return new $(r,s,o,n,a)}}class Q{constructor(e){var t=e.get();if(this.tagClass=t>>6,this.tagConstructed=!!(32&t),this.tagNumber=31&t,31==this.tagNumber){var r=new Y;do{t=e.get(),r.mulAdd(128,127&t)}while(128&t);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var p=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],v=(1<<26)/p[p.length-1];class J{constructor(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}toString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,o=!1,i="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(o=!0,i=M(r));s>=0;)a<t?(r=(this[s]&(1<<a)-1)<<t-a,r|=this[--s]>>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(o=!0),o&&(i+=M(r));return o?i:"0"}negate(){var e=X();return J.ZERO.subTo(this,e),e}abs(){return this.s<0?this.negate():this}compareTo(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+ie(this[this.t-1]^this.s&this.DM)}mod(e){var t=X();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(J.ZERO)>0&&e.subTo(t,t),t}modPowInt(e,t){var r;return r=e<256||t.isEven()?new m(t):new y(t),this.exp(e,r)}clone(){var e=X();return this.copyTo(e),e}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var e=this.t,t=[];t[0]=this.s;var r,n=this.DB-e*this.DB%8,o=0;if(e-- >0)for(n<this.DB&&(r=this[e]>>n)!=(this.s&this.DM)>>n&&(t[o++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this[e]&(1<<n)-1)<<8-n,r|=this[--e]>>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),128&r&&(r|=-256),0==o&&(128&this.s)!=(128&r)&&++o,(o>0||r!=this.s)&&(t[o++]=r);return t}equals(e){return 0==this.compareTo(e)}min(e){return this.compareTo(e)<0?this:e}max(e){return this.compareTo(e)>0?this:e}and(e){var t=X();return this.bitwiseTo(e,j,t),t}or(e){var t=X();return this.bitwiseTo(e,q,t),t}xor(e){var t=X();return this.bitwiseTo(e,B,t),t}andNot(e){var t=X();return this.bitwiseTo(e,W,t),t}not(){for(var e=X(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e}shiftLeft(e){var t=X();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}shiftRight(e){var t=X();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}getLowestSetBit(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+H(this[e]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=V(this[r]^t);return e}testBit(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)}setBit(e){return this.changeBit(e,q)}clearBit(e){return this.changeBit(e,W)}flipBit(e){return this.changeBit(e,B)}add(e){var t=X();return this.addTo(e,t),t}subtract(e){var t=X();return this.subTo(e,t),t}multiply(e){var t=X();return this.multiplyTo(e,t),t}divide(e){var t=X();return this.divRemTo(e,t,null),t}remainder(e){var t=X();return this.divRemTo(e,null,t),t}divideAndRemainder(e){var t=X(),r=X();return this.divRemTo(e,t,r),[t,r]}modPow(e,t){var r,n,o=e.bitLength(),i=oe(1);if(o<=0)return i;r=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new m(t):t.isEven()?new g(t):new y(t);var s=[],a=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var l=X();for(n.sqrTo(s[1],l);a<=c;)s[a]=X(),n.mulTo(l,s[a-2],s[a]),a+=2}var h,d,f=e.t-1,p=!0,v=X();for(o=ie(e[f])-1;f>=0;){for(o>=u?h=e[f]>>o-u&c:(h=(e[f]&(1<<o+1)-1)<<u-o,f>0&&(h|=e[f-1]>>this.DB+o-u)),a=r;!(1&h);)h>>=1,--a;if((o-=a)<0&&(o+=this.DB,--f),p)s[h].copyTo(i),p=!1;else{for(;a>1;)n.sqrTo(i,v),n.sqrTo(v,i),a-=2;a>0?n.sqrTo(i,v):(d=i,i=v,v=d),n.mulTo(v,s[h],i)}for(;f>=0&&!(e[f]&1<<o);)n.sqrTo(i,v),d=i,i=v,v=d,--o<0&&(o=this.DB-1,--f)}return n.revert(i)}modInverse(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return J.ZERO;for(var r=e.clone(),n=this.clone(),o=oe(1),i=oe(0),s=oe(0),a=oe(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(o.isEven()&&i.isEven()||(o.addTo(this,o),i.subTo(e,i)),o.rShiftTo(1,o)):i.isEven()||i.subTo(e,i),i.rShiftTo(1,i);for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),t&&o.subTo(s,o),i.subTo(a,i)):(n.subTo(r,n),t&&s.subTo(o,s),a.subTo(i,a))}return 0!=n.compareTo(J.ONE)?J.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a}pow(e){return this.exp(e,new _)}gcd(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var o=t.getLowestSetBit(),i=r.getLowestSetBit();if(i<0)return t;for(o<i&&(i=o),i>0&&(t.rShiftTo(i,t),r.rShiftTo(i,r));t.signum()>0;)(o=t.getLowestSetBit())>0&&t.rShiftTo(o,t),(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return i>0&&r.lShiftTo(i,r),r}isProbablePrime(e){var t,r=this.abs();if(1==r.t&&r[0]<=p[p.length-1]){for(t=0;t<p.length;++t)if(r[0]==p[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<p.length;){for(var n=p[t],o=t+1;o<p.length&&n<v;)n*=p[o++];for(n=r.modInt(n);t<o;)if(n%p[t++]==0)return!1}return r.millerRabin(e)}copyTo(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}fromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}fromString(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,o=!1,i=0;--n>=0;){var s=8==r?255&+e[n]:ne(e,n);s<0?"-"==e.charAt(n)&&(o=!0):(o=!1,0==i?this[this.t++]=s:i+r>this.DB?(this[this.t-1]|=(s&(1<<this.DB-i)-1)<<i,this[this.t++]=s>>this.DB-i):this[this.t-1]|=s<<i,(i+=r)>=this.DB&&(i-=this.DB))}8==r&&128&+e[0]&&(this.s=-1,i>0&&(this[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),o&&J.ZERO.subTo(this,this)}clamp(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t}dlShiftTo(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s}drShiftTo(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s}lShiftTo(e,t){for(var r=e%this.DB,n=this.DB-r,o=(1<<n)-1,i=Math.floor(e/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)t[a+i+1]=this[a]>>n|s,s=(this[a]&o)<<r;for(a=i-1;a>=0;--a)t[a]=0;t[i]=s,t.t=this.t+i+1,t.s=this.s,t.clamp()}rShiftTo(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,o=this.DB-n,i=(1<<n)-1;t[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)t[s-r-1]|=(this[s]&i)<<o,t[s-r]=this[s]>>n;n>0&&(t[this.t-r-1]|=(this.s&i)<<o),t.t=this.t-r,t.clamp()}}subTo(e,t){for(var r=0,n=0,o=Math.min(e.t,this.t);r<o;)n+=this[r]-e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e[r],t[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()}multiplyTo(e,t){var r=this.abs(),n=e.abs(),o=r.t;for(t.t=o+n.t;--o>=0;)t[o]=0;for(o=0;o<n.t;++o)t[o+r.t]=r.am(0,n[o],t,o,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&J.ZERO.subTo(t,t)}squareTo(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()}divRemTo(e,t,r){var n=e.abs();if(!(n.t<=0)){var o=this.abs();if(o.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=X());var i=X(),s=this.s,a=e.s,u=this.DB-ie(n[n.t-1]);u>0?(n.lShiftTo(u,i),o.lShiftTo(u,r)):(n.copyTo(i),o.copyTo(r));var c=i.t,l=i[c-1];if(0!=l){var h=l*(1<<this.F1)+(c>1?i[c-2]>>this.F2:0),d=this.FV/h,f=(1<<this.F1)/h,p=1<<this.F2,v=r.t,_=v-c,m=null==t?X():t;for(i.dlShiftTo(_,m),r.compareTo(m)>=0&&(r[r.t++]=1,r.subTo(m,r)),J.ONE.dlShiftTo(c,m),m.subTo(i,i);i.t<c;)i[i.t++]=0;for(;--_>=0;){var y=r[--v]==l?this.DM:Math.floor(r[v]*d+(r[v-1]+p)*f);if((r[v]+=i.am(0,y,r,_,0,c))<y)for(i.dlShiftTo(_,m),r.subTo(m,r);r[v]<--y;)r.subTo(m,r)}null!=t&&(r.drShiftTo(c,t),s!=a&&J.ZERO.subTo(t,t)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&&J.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(e,t){if(e>4294967295||e<1)return J.ONE;var r=X(),n=X(),o=t.convert(this),i=ie(e)-1;for(o.copyTo(r);--i>=0;)if(t.sqrTo(r,n),(e&1<<i)>0)t.mulTo(n,o,r);else{var s=r;r=n,n=s}return t.revert(r)}chunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}toRadix(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=oe(r),o=X(),i=X(),s="";for(this.divRemTo(n,o,i);o.signum()>0;)s=(r+i.intValue()).toString(e).substr(1)+s,o.divRemTo(n,o,i);return i.intValue().toString(e)+s}fromRadix(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),o=!1,i=0,s=0,a=0;a<e.length;++a){var u=ne(e,a);u<0?"-"==e.charAt(a)&&0==this.signum()&&(o=!0):(s=t*s+u,++i>=r&&(this.dMultiply(n),this.dAddOffset(s,0),i=0,s=0))}i>0&&(this.dMultiply(Math.pow(t,i)),this.dAddOffset(s,0)),o&&J.ZERO.subTo(this,this)}fromNumber(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(J.ONE.shiftLeft(e-1),q,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(J.ONE.shiftLeft(e-1),this);else{var n=[],o=7&e;n.length=1+(e>>3),t.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(e,t,r){var n,o,i=Math.min(e.t,this.t);for(n=0;n<i;++n)r[n]=t(this[n],e[n]);if(e.t<this.t){for(o=e.s&this.DM,n=i;n<this.t;++n)r[n]=t(this[n],o);r.t=this.t}else{for(o=this.s&this.DM,n=i;n<e.t;++n)r[n]=t(o,e[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()}changeBit(e,t){var r=J.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r}addTo(e,t){for(var r=0,n=0,o=Math.min(e.t,this.t);r<o;)n+=this[r]+e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e[r],t[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()}dMultiply(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}multiplyLowerTo(e,t,r){var n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(var o=r.t-this.t;n<o;++n)r[n+this.t]=this.am(0,e[n],r,n,0,this.t);for(o=Math.min(e.t,t);n<o;++n)this.am(0,e[n],r,n,0,t-n);r.clamp()}multiplyUpperTo(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r[this.t+n-t]=this.am(t-n,e[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)}modInt(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r}millerRabin(e){var t=this.subtract(J.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>p.length&&(e=p.length);for(var o=X(),i=0;i<e;++i){o.fromInt(p[Math.floor(Math.random()*p.length)]);var s=o.modPow(n,this);if(0!=s.compareTo(J.ONE)&&0!=s.compareTo(t)){for(var a=1;a++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(J.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0}square(){var e=X();return this.squareTo(e),e}gcda(e,t){var r=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(r.compareTo(n)<0){var o=r;r=n,n=o}var i=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)t(r);else{i<s&&(s=i),s>0&&(r.rShiftTo(s,r),n.rShiftTo(s,n));var a=()=>{(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),(i=n.getLowestSetBit())>0&&n.rShiftTo(i,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n)),r.signum()>0?setTimeout(a,0):(s>0&&n.lShiftTo(s,n),setTimeout(function(){t(n)},0))};setTimeout(a,10)}}fromNumberAsync(e,t,r,n){if("number"==typeof t)if(e<2)this.fromInt(1);else{this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(J.ONE.shiftLeft(e-1),q,this),this.isEven()&&this.dAddOffset(1,0);var o=this,i=function(){o.dAddOffset(2,0),o.bitLength()>e&&o.subTo(J.ONE.shiftLeft(e-1),o),o.isProbablePrime(t)?setTimeout(function(){n()},0):setTimeout(i,0)};setTimeout(i,0)}else{var s=[],a=7&e;s.length=1+(e>>3),t.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var _=function(){function e(){}return e.prototype.convert=function(e){return e},e.prototype.revert=function(e){return e},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},e.prototype.sqrTo=function(e,t){e.squareTo(t)},e}(),m=function(){function e(e){this.m=e}return e.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),y=function(){function e(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}return e.prototype.convert=function(e){var t=X();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(J.ZERO)>0&&this.m.subTo(t,t),t},e.prototype.revert=function(e){var t=X();return e.copyTo(t),this.reduce(t),t},e.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],n=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),g=function(){function e(e){this.m=e,this.r2=X(),this.q3=X(),J.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e)}return e.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=X();return e.copyTo(t),this.reduce(t),t},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}();function X(){return new J(null)}function Z(e,t){return new J(e,t)}function ee(e,t,r,n,o,i){for(;--i>=0;){var s=t*this[e++]+r[n]+o;o=Math.floor(s/67108864),r[n++]=67108863&s}return o}function te(e,t,r,n,o,i){for(var s=32767&t,a=t>>15;--i>=0;){var u=32767&this[e],c=this[e++]>>15,l=a*u+c*s;o=((u=s*u+((32767&l)<<15)+r[n]+(1073741823&o))>>>30)+(l>>>15)+a*c+(o>>>30),r[n++]=1073741823&u}return o}function re(e,t,r,n,o,i){for(var s=16383&t,a=t>>14;--i>=0;){var u=16383&this[e],c=this[e++]>>14,l=a*u+c*s;o=((u=s*u+((16383&l)<<14)+r[n]+o)>>28)+(l>>14)+a*c,r[n++]=268435455&u}return o}void 0!==o&&"Microsoft Internet Explorer"==(null==o?void 0:o.appName)?(J.prototype.am=te,h=30):"Netscape"!=(null==o?void 0:o.appName)?(J.prototype.am=ee,h=26):(J.prototype.am=re,h=28),J.prototype.DB=h,J.prototype.DM=(1<<h)-1,J.prototype.DV=1<<h,J.prototype.FV=Math.pow(2,52),J.prototype.F1=52-h,J.prototype.F2=2*h-52;var b,E,w=[];for(b="0".charCodeAt(0),E=0;E<=9;++E)w[b++]=E;for(b="a".charCodeAt(0),E=10;E<36;++E)w[b++]=E;for(b="A".charCodeAt(0),E=10;E<36;++E)w[b++]=E;function ne(e,t){var r=w[e.charCodeAt(t)];return null==r?-1:r}function oe(e){var t=X();return t.fromInt(e),t}function ie(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}J.ZERO=oe(0),J.ONE=oe(1);class se{constructor(){this.i=0,this.j=0,this.S=[]}init(e){var t,r,n;for(t=0;t<256;++t)this.S[t]=t;for(r=0,t=0;t<256;++t)r=r+this.S[t]+e[t%e.length]&255,n=this.S[t],this.S[t]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]}}var S,I,A=null;if(null==A){A=[],I=0;var T,P,O=void 0;if("undefined"!=typeof window&&null!==(T=window)&&void 0!==T&&T.crypto&&null!==(P=window)&&void 0!==P&&P.crypto.getRandomValues){var R,C=new Uint32Array(256);for(null===(R=window)||void 0===R||R.crypto.getRandomValues(C),O=0;O<C.length;++O)A[I++]=255&C[O]}var N,U,D,L=function(e){var t,r,n;if(this.count=this.count||0,this.count>=256||I>=256){if("undefined"!=typeof window)if(null!==(t=window)&&void 0!==t&&t.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",L,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",L)}}else try{var i=e.x+e.y;A[I++]=255&i,this.count+=1}catch(e){}};if("undefined"!=typeof window)if(null!==(N=window)&&void 0!==N&&N.addEventListener)null===(D=window)||void 0===D||D.addEventListener("mousemove",L,!1);else if(null!==(U=window)&&void 0!==U&&U.attachEvent){var k;null===(k=window)||void 0===k||k.attachEvent("onmousemove",L)}}function ae(){if(null==S){for(S=new se;I<256;){var e=Math.floor(65536*Math.random());A[I++]=255&e}for(S.init(A),I=0;I<A.length;++I)A[I]=0;I=0}return S.next()}class ue{constructor(){}nextBytes(e){for(var t=0;t<e.length;++t)e[t]=ae()}}function ce(e,t){if(t<e.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=e.length-1;n>=0&&t>0;){var o=e.charCodeAt(n--);o<128?r[--t]=o:o>127&&o<2048?(r[--t]=63&o|128,r[--t]=o>>6|192):(r[--t]=63&o|128,r[--t]=o>>6&63|128,r[--t]=o>>12|224)}r[--t]=0;for(var i=new ue,s=[];t>2;){for(s[0]=0;0==s[0];)i.nextBytes(s);r[--t]=s[0]}return r[--t]=2,r[--t]=0,new J(r)}class le{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(e){return e.modPowInt(this.e,this.n)}doPrivate(e){if(null==this.p||null==this.q)return e.modPow(this.d,this.n);for(var t=e.mod(this.p).modPow(this.dmp1,this.p),r=e.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(r)<0;)t=t.add(this.p);return t.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(e,t){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=Z(e,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")}encrypt(e){var t=ce(e,this.n.bitLength()+7>>3);if(null==t)return null;var r=this.doPublic(t);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n}encryptLong(e){var t=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return e.length>r?(e.match(/.{1,117}/g).forEach(function(e){var r=t.encrypt(e);n+=r}),F(n)):F(this.encrypt(e))}catch(e){return!1}}decryptLong(e){var t=this,r=this.n.bitLength()+7>>3;e=G(e);try{if(e.length>r){var n="";return e.match(/.{1,256}/g).forEach(function(e){var r=t.decrypt(e);n+=r}),n}return this.decrypt(e)}catch(e){return!1}}setPrivate(e,t,r){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=Z(e,16),this.e=parseInt(t,16),this.d=Z(r,16)):console.error("Invalid RSA private key")}setPrivateEx(e,t,r,n,o,i,s,a){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=Z(e,16),this.e=parseInt(t,16),this.d=Z(r,16),this.p=Z(n,16),this.q=Z(o,16),this.dmp1=Z(i,16),this.dmq1=Z(s,16),this.coeff=Z(a,16)):console.error("Invalid RSA private key")}generate(e,t){var r=new ue,n=e>>1;this.e=parseInt(t,16);for(var o=new J(t,16);;){for(;this.p=new J(e-n,1,r),0!=this.p.subtract(J.ONE).gcd(o).compareTo(J.ONE)||!this.p.isProbablePrime(10););for(;this.q=new J(n,1,r),0!=this.q.subtract(J.ONE).gcd(o).compareTo(J.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var i=this.p;this.p=this.q,this.q=i}var s=this.p.subtract(J.ONE),a=this.q.subtract(J.ONE),u=s.multiply(a);if(0==u.gcd(o).compareTo(J.ONE)){this.n=this.p.multiply(this.q),this.d=o.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(e){var t=Z(e,16),r=this.doPrivate(t);return null==r?null:he(r,this.n.bitLength()+7>>3)}generateAsync(e,t,r){var n=new ue,o=e>>1;this.e=parseInt(t,16);var i=new J(t,16),s=this,a=()=>{var t=()=>{if(s.p.compareTo(s.q)<=0){var e=s.p;s.p=s.q,s.q=e}var t=s.p.subtract(J.ONE),n=s.q.subtract(J.ONE),o=t.multiply(n);0==o.gcd(i).compareTo(J.ONE)?(s.n=s.p.multiply(s.q),s.d=i.modInverse(o),s.dmp1=s.d.mod(t),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout(function(){r()},0)):setTimeout(a,0)},u=()=>{s.q=X(),s.q.fromNumberAsync(o,1,n,function(){s.q.subtract(J.ONE).gcda(i,function(e){0==e.compareTo(J.ONE)&&s.q.isProbablePrime(10)?setTimeout(t,0):setTimeout(u,0)})})},c=()=>{s.p=X(),s.p.fromNumberAsync(e-o,1,n,function(){s.p.subtract(J.ONE).gcda(i,function(e){0==e.compareTo(J.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)})})};setTimeout(c,0)};setTimeout(a,0)}}function he(e,t){for(var r=e.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=t-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var o="";++n<r.length;){var i=255&r[n];i<128?o+=String.fromCharCode(i):i>191&&i<224?(o+=String.fromCharCode((31&i)<<6|63&r[n+1]),++n):(o+=String.fromCharCode((15&i)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return o}class de extends le{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),e&&("string"==typeof e?this.parseKey(e):(this.hasPrivateKeyProperty(e)||this.hasPublicKeyProperty(e))&&this.parsePropertiesFrom(e))}parseKey(e){try{var t=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(e)?u.decode(e):c.unarmor(e),o=$.decode(n);if(3===o.sub.length&&(o=o.sub[2].sub[0]),9===o.sub.length){t=o.sub[1].getHexStringValue(),this.n=Z(t,16),r=o.sub[2].getHexStringValue(),this.e=parseInt(r,16);var i=o.sub[3].getHexStringValue();this.d=Z(i,16);var s=o.sub[4].getHexStringValue();this.p=Z(s,16);var a=o.sub[5].getHexStringValue();this.q=Z(a,16);var l=o.sub[6].getHexStringValue();this.dmp1=Z(l,16);var h=o.sub[7].getHexStringValue();this.dmq1=Z(h,16);var d=o.sub[8].getHexStringValue();this.coeff=Z(d,16)}else{if(2!==o.sub.length)return!1;var f=o.sub[1].sub[0];t=f.sub[0].getHexStringValue(),this.n=Z(t,16),r=f.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(e){return!1}}hasPublicKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")}hasPrivateKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")}parsePropertiesFrom(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)}}(n=function(e){e=e||{},this.default_key_size=parseInt(e.default_key_size,10)||1024,this.default_public_exponent=e.default_public_exponent||"010001",this.log=e.log||!1,this.key=null}).prototype.setKey=function(e){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new de(e)},n.prototype.setPrivateKey=function(e){this.setKey(e)},n.prototype.setPublicKey=function(e){this.setKey(e)},n.prototype.decrypt=function(e){try{return this.getKey().decrypt(G(e))}catch(e){return!1}},n.prototype.encrypt=function(e){try{return F(this.getKey().encrypt(e))}catch(e){return!1}},n.prototype.encryptLong=function(e){try{for(var t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",n=0,o=/null$/g;o.test(r)&&(n++,t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",!(n>10)););return t}catch(e){return!1}},n.prototype.getKey=function(e){if(!this.key){if(this.key=new de,e&&"[object Function]"==={}.toString.call(e))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}const x=n},182:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(274)),c=r(616);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,o=(0,c.isArray)(e)?e:[e];r<o.length;r++){var i=o[r],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:n({isMatch:s},a(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},274:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(829),c=r(616),l=r(946),h=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,s=e.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(t).forEach(function(e){c.append(e,t[e])}),c.append("key",n),c.append("file",r),this.request(i(i({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,function(){var t,r,n,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise(function(t){t({statusCode:200,tempFilePath:e.url})})]}})})},t.prototype.fetch=function(e){var t;return s(this,void 0,void 0,function(){var r,n,o,u,c,l,h,d,f,p,v,_,m,y=this;return a(this,function(g){switch(g.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,u=void 0!==o&&o,c=e.stream,l=void 0!==c&&c,h=e.signal,d=e.timeout,f=e.shouldThrowOnError,p=void 0===f||f,v=null!=d?d:this.timeout,h&&(h.aborted&&r.abort(),h.addEventListener("abort",function(){return r.abort()})),_=null,u&&v&&(_=setTimeout(function(){console.warn(y.timeoutMsg),r.abort(new Error(y.timeoutMsg))},v)),[4,fetch(n,i(i({},e),{signal:r.signal})).then(function(e){return s(y,void 0,void 0,function(){var t,r,n;return a(this,function(o){switch(o.label){case 0:return clearTimeout(_),p?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(_),Promise.reject(e)})];case 1:return m=g.sent(),[2,{data:l?m.body:(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers,response:m}]}})})},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise(function(o){var i=e.url,s=e.headers,a=void 0===s?{}:s,u=e.data,h=e.responseType,d=e.withCredentials,f=e.body,p=e.onUploadProgress,v=(0,c.formatUrl)((0,l.getProtocol)(),i,"get"===n?u:{}),_=new XMLHttpRequest;_.open(n,v),h&&(_.responseType=h);var m,y,g=e.signal;g&&(g.aborted?_.abort():g.addEventListener("abort",function(){return _.abort()},{once:!0})),Object.keys(a).forEach(function(e){_.setRequestHeader(e,a[e])}),p&&_.upload.addEventListener("progress",p),_.onreadystatechange=function(){var e={};if(4===_.readyState){var t=_.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach(function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o}),e.header=r,e.statusCode=_.status;try{e.data="blob"===h?_.response:JSON.parse(_.responseText)}catch(t){e.data="blob"===h?_.response:_.responseText}clearTimeout(m),o(e)}},t&&r.timeout&&(m=setTimeout(function(){console.warn(r.timeoutMsg),_.abort()},r.timeout)),y=(0,c.isFormData)(u)?u:"application/x-www-form-urlencoded"===a["content-type"]?(0,c.toQueryString)(u):f||(u?JSON.stringify(u):void 0),d&&(_.withCredentials=!0),_.send(y)})},t}(u.AbstractSDKRequest);t.WebRequest=h,t.genAdapter=function(){return{type:"default",root:window,reqClass:h,wsClass:WebSocket,localStorage}}},946:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var r="@cloudbase/js-sdk";t.setSdkName=function(e){r=e},t.getSdkName=function(){return r};var n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},205:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},794:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(r(946),t),o(r(205),t),t.OATUH_LOGINTYPE="constants"},718:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=r(616),s=r(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),h=s.findIndex(function(e){return u.test(e)});if(-1!==h){var d=s.filter(function(e,t){return t>h});d.unshift(s[h].replace(l,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,h=void 0===a?{}:a,d=e.title,f=e.messages,p=void 0===f?[]:f;return function(e,t,a){if(s.IS_DEBUG_MODE){var f=h.className||e.constructor.name,v=h.methodName||t,_=a.value,m=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex(function(e){return u.test(e)});if(-1!==r){var n=c.exec(t[r+1]||"");e=n?n[0]:""}return e}();a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=l({err:new Error,className:f,methodName:v,sourceLink:m});try{return _.apply(this,e)}catch(e){var n=e,o=e.message,s=e.error,a=e.error_description,u={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=p.map(function(e){return{type:"info",body:e}}))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,function(){var t,r,n,s,a,u,c,h;return o(this,function(o){switch(o.label){case 0:t=l({err:new Error,className:f,methodName:v,sourceLink:m}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,_.apply(this,e)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(h=JSON.parse(s),c.subtitle=h,h.code&&(t?(t.code=h.code,t.message=h.msg):(r.code=h.code,r.message=h.msg),n=t||r,c.content=p.map(function(e){return{type:"info",body:e}}))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(c),n;case 4:return[2]}})})}}}}},141:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(718),t)},197:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(829),u=r(616),c=r(794),l=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage),h=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(t.root));case"none":return new l(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return i(this,void 0,void 0,function(){var n;return s(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return i(this,void 0,void 0,function(){var n;return s(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}})})},e}();t.CloudbaseCache=h},689:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(616),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return o(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,c=this.listeners[n]?i([],this.listeners[n],!0):[];o<c.length;o++)c[o].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var l=new c;t.addEventListener=function(e,t){l.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),l.fire(e,t)},t.removeEventListener=function(e,t){l.off(e,t)}},616:function(e,t,r){var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=r(794);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)})},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach(function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))}),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise(function(t,r){e=function(e,n){return e?r(e):t(n)}});return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,u=void 0!==a&&a,c=e.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,h=s;l<h.length;l++){var d=h[l],f=d.type,p=d.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)}),t},t.parseCaptcha=function(e){var r={},o=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){e=o[1];var i=o[2];i&&(r=(0,t.parseQueryString)(i))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},254:(e,t,r)=>{function n(e){this.message=e}r.r(t),r.d(t,{InvalidTokenError:()=>s,default:()=>a}),n.prototype=new Error,n.prototype.name="InvalidCharacterError";var o="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,o,i=0,s=0,a="";o=t.charAt(s++);~o&&(r=i%4?64*r+o:o,i++%4)?a+=String.fromCharCode(255&r>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return a};function i(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(o(e).replace(/(.)/g,function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}(t)}catch(e){return o(t)}}function s(e){this.message=e}s.prototype=new Error,s.prototype.name="InvalidTokenError";const a=function(e,t){if("string"!=typeof e)throw new s("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(i(e.split(".")[r]))}catch(e){throw new s("Invalid token specified: "+e.message)}}}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e].call(i.exports,i,i.exports,o),i.exports}return t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var i=Object.create(null);o.r(i);var s={};e=e||[null,t({}),t([]),t(t)];for(var a=2&n&&r;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach(e=>s[e]=()=>r[e]);return s.default=()=>r,o.d(i,s),i},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o(304)})());