@cloudbase/js-sdk 3.7.1 → 3.7.2-cbf.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/dist/index.js +1 -1
- package/app/dist/index.js.map +1 -1
- package/app/dist/index.node.esm.js +1 -1
- package/app/dist/index.node.esm.js.map +1 -1
- package/app/dist/index.node.js +1 -1
- package/app/dist/index.node.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.node.cjs.js +1 -1
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.esm.js +1 -1
- package/dist/index.node.esm.js.map +1 -1
- package/miniprogram_dist/ai.js +2 -0
- package/miniprogram_dist/analytics.js +1 -0
- package/miniprogram_dist/apis.js +1 -0
- package/miniprogram_dist/app.js +2 -0
- package/miniprogram_dist/auth.js +2 -0
- package/miniprogram_dist/cloudrun.js +1 -0
- package/miniprogram_dist/container.js +1 -0
- package/miniprogram_dist/database.js +1 -0
- package/miniprogram_dist/functions.js +1 -0
- package/miniprogram_dist/index.js +1 -1
- package/miniprogram_dist/model/index.js +1 -1
- package/miniprogram_dist/model.js +1 -0
- package/miniprogram_dist/mysql.js +1 -0
- package/miniprogram_dist/oauth.js +2 -0
- package/miniprogram_dist/realtime.js +1 -0
- package/miniprogram_dist/storage.js +1 -0
- package/package.json +2 -2
- package/utilities/dist/cjs/adapters/index.d.ts +0 -45
- package/utilities/dist/cjs/adapters/index.js +0 -68
- package/utilities/dist/cjs/adapters/platforms/web.d.ts +0 -20
- package/utilities/dist/cjs/adapters/platforms/web.js +0 -286
- package/utilities/dist/cjs/constants/common.d.ts +0 -6
- package/utilities/dist/cjs/constants/common.js +0 -24
- package/utilities/dist/cjs/constants/errors.d.ts +0 -8
- package/utilities/dist/cjs/constants/errors.js +0 -12
- package/utilities/dist/cjs/constants/index.d.ts +0 -3
- package/utilities/dist/cjs/constants/index.js +0 -21
- package/utilities/dist/cjs/helpers/decorators.d.ts +0 -11
- package/utilities/dist/cjs/helpers/decorators.js +0 -238
- package/utilities/dist/cjs/helpers/index.d.ts +0 -1
- package/utilities/dist/cjs/helpers/index.js +0 -18
- package/utilities/dist/cjs/index.d.ts +0 -13
- package/utilities/dist/cjs/index.js +0 -51
- package/utilities/dist/cjs/libs/abortController.d.ts +0 -9
- package/utilities/dist/cjs/libs/abortController.js +0 -25
- package/utilities/dist/cjs/libs/cache.d.ts +0 -17
- package/utilities/dist/cjs/libs/cache.js +0 -261
- package/utilities/dist/cjs/libs/events.d.ts +0 -27
- package/utilities/dist/cjs/libs/events.js +0 -108
- package/utilities/dist/cjs/libs/langEvent.d.ts +0 -3
- package/utilities/dist/cjs/libs/langEvent.js +0 -7
- package/utilities/dist/cjs/libs/util.d.ts +0 -49
- package/utilities/dist/cjs/libs/util.js +0 -282
- package/utilities/dist/esm/adapters/index.d.ts +0 -45
- package/utilities/dist/esm/adapters/index.js +0 -40
- package/utilities/dist/esm/adapters/platforms/web.d.ts +0 -20
- package/utilities/dist/esm/adapters/platforms/web.js +0 -282
- package/utilities/dist/esm/constants/common.d.ts +0 -6
- package/utilities/dist/esm/constants/common.js +0 -17
- package/utilities/dist/esm/constants/errors.d.ts +0 -8
- package/utilities/dist/esm/constants/errors.js +0 -9
- package/utilities/dist/esm/constants/index.d.ts +0 -3
- package/utilities/dist/esm/constants/index.js +0 -4
- package/utilities/dist/esm/helpers/decorators.d.ts +0 -11
- package/utilities/dist/esm/helpers/decorators.js +0 -234
- package/utilities/dist/esm/helpers/index.d.ts +0 -1
- package/utilities/dist/esm/helpers/index.js +0 -2
- package/utilities/dist/esm/index.d.ts +0 -13
- package/utilities/dist/esm/index.js +0 -14
- package/utilities/dist/esm/libs/abortController.d.ts +0 -9
- package/utilities/dist/esm/libs/abortController.js +0 -23
- package/utilities/dist/esm/libs/cache.d.ts +0 -17
- package/utilities/dist/esm/libs/cache.js +0 -258
- package/utilities/dist/esm/libs/events.d.ts +0 -27
- package/utilities/dist/esm/libs/events.js +0 -102
- package/utilities/dist/esm/libs/langEvent.d.ts +0 -3
- package/utilities/dist/esm/libs/langEvent.js +0 -4
- package/utilities/dist/esm/libs/util.d.ts +0 -49
- package/utilities/dist/esm/libs/util.js +0 -254
- package/utilities/dist/miniprogram/index.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_realtime",[],t):"object"==typeof exports?exports.cloudbase_realtime=t():e.cloudbase_realtime=t()}("undefined"!=typeof window?window:this,(()=>(()=>{var e={8037:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.registerRealtime=void 0;var n=r(7209);t.registerRealtime=n.registerRealtime;try{window.registerRealtime=t.registerRealtime}catch(e){}},6511:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setRuntime=t.getRuntime=t.setWsClass=t.getWsClass=void 0;var r=null,n="web";t.getWsClass=function(){return r},t.setWsClass=function(e){r=e},t.getRuntime=function(){return n},t.setRuntime=function(e){n=e}},2917:function(e,t){"use strict";var r,n=this&&this.__extends||(r=function(e,t){return r=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])},r(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 n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.ERR_CODE=t.CloudSDKError=t.isCancelledError=t.CancelledError=t.isTimeoutError=t.TimeoutError=t.isRealtimeErrorMessageError=t.RealtimeErrorMessageError=void 0;var o=function(e){function t(t){var r=e.call(this,"Watch Error ".concat(JSON.stringify(t.msgData)," (requestid: ").concat(t.requestId,")"))||this;return r.isRealtimeErrorMessageError=!0,r.payload=t,r}return n(t,e),t}(Error);t.RealtimeErrorMessageError=o,t.isRealtimeErrorMessageError=function(e){return null==e?void 0:e.isRealtimeErrorMessageError};var i=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="timeout",t.payload=null,t.generic=!0,t}return n(t,e),t}(Error);t.TimeoutError=i,t.isTimeoutError=function(e){return"timeout"===e.type};var s=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="cancelled",t.payload=null,t.generic=!0,t}return n(t,e),t}(Error);t.CancelledError=s,t.isCancelledError=function(e){return"cancelled"===e.type};var a=function(e){function r(r){var n=e.call(this,r.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: ".concat(this.errCode," ").concat(t.ERR_CODE[this.errCode]||""," | errMsg: ").concat(this.errMsg)},set:function(e){this.errMsg=e}}}),n.errCode=r.errCode||"UNKNOWN_ERROR",n.errMsg=r.errMsg,n}return n(r,e),Object.defineProperty(r.prototype,"message",{get:function(){return"errCode: ".concat(this.errCode," | errMsg: ").concat(this.errMsg)},set:function(e){this.errMsg=e},enumerable:!1,configurable:!0}),r}(Error);t.CloudSDKError=a,t.ERR_CODE={UNKNOWN_ERROR:"UNKNOWN_ERROR",SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG:"SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG",SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA:"SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED",SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL",SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR:"SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR"}},7209:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.registerRealtime=void 0;var n=r(2347),o=r(6511),i={target:"database",entity:function(){var e=this.platform,t=e.adapter,r=e.runtime;(0,o.setWsClass)(t.wsClass),(0,o.setRuntime)(r)}},s={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=n.RealtimeWebSocketClient}};try{cloudbase.registerComponent(s),cloudbase.registerHook(i)}catch(e){}t.registerRealtime=function(e){try{e.registerComponent(s),e.registerHook(i)}catch(e){console.warn(e)}}},1601:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RealtimeListener=void 0;t.RealtimeListener=function(e){this.close=e.close,this.onChange=e.onChange,this.onError=e.onError,e.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return e.virtualClient}})}},3994:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInitEventMessage=t.genRequestId=void 0,t.genRequestId=function(e){return void 0===e&&(e=""),"".concat(e?"".concat(e,"_"):"").concat(+new Date,"_").concat(Math.random())},t.isInitEventMessage=function(e){return"INIT_EVENT"===e.msgType}},9770:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Snapshot=void 0;t.Snapshot=function(e){var t,r,n=e.id,o=e.docChanges,i=e.docs,s=e.msgType,a=e.type;Object.defineProperties(this,{id:{get:function(){return n},enumerable:!0},docChanges:{get:function(){return t||(t=JSON.parse(JSON.stringify(o))),t},enumerable:!0},docs:{get:function(){return r||(r=JSON.parse(JSON.stringify(i))),r},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})}},7589:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=void 0,t.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))}},4151:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((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(c){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,c])}}},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))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VirtualWebSocketClient=void 0;var a,c=s(r(6765)),u=s(r(7195)),l=s(r(9850)),d=r(3994),h=r(1601),p=r(9770),f=r(2917),v=r(7589);!function(e){e.LOGGINGIN="LOGGINGIN",e.INITING="INITING",e.REBUILDING="REBUILDING",e.ACTIVE="ACTIVE",e.ERRORED="ERRORED",e.CLOSING="CLOSING",e.CLOSED="CLOSED",e.PAUSED="PAUSED",e.RESUMING="RESUMING"}(a||(a={}));var E=function(){function e(e){var t=this;this.watchStatus=a.INITING,this.wsLogin=function(e,r){return n(t,void 0,Promise,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return this.watchStatus=a.LOGGINGIN,[4,this.login(e,r)];case 1:return t=n.sent(),this.envId||(this.envId=t.envId),[2,t]}}))}))},this.initWatch=function(e){return n(t,void 0,Promise,(function(){var t,r=this;return o(this,(function(i){switch(i.label){case 0:if(null!==this.initWatchPromise&&void 0!==this.initWatchPromise)return[2,this.initWatchPromise];this.initWatchPromise=new Promise((function(t,i){n(r,void 0,void 0,(function(){var r,n,s,c,u,l,h,f,v,E;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.watchStatus===a.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):[4,this.wsLogin(this.envId,e)];case 1:return r=o.sent().envId,this.watchStatus===a.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(this.watchStatus=a.INITING,n={watchId:this.watchId,requestId:(0,d.genRequestId)(),msgType:"INIT_WATCH",msgData:{envId:r,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:n,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(s=o.sent(),c=s.msgData,u=c.events,l=c.currEvent,this.sessionInfo={queryID:s.msgData.queryID,currentEventId:l-1,currentDocs:[]},u.length>0){for(h=0,f=u;h<f.length;h++)f[h].ID=l;this.handleServerEvents(s)}else this.sessionInfo.currentEventId=l,v=new p.Snapshot({id:l,docChanges:[],docs:[],type:"init"}),this.listener.onChange(v),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=a.ACTIVE,this.availableRetries.INIT_WATCH=2,t(),[3,4];case 3:return E=o.sent(),this.handleWatchEstablishmentError(E,{operationName:"INIT_WATCH",resolve:t,reject:i}),[3,4];case 4:return[2]}}))}))})),t=!1,i.label=1;case 1:return i.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return i.sent(),t=!0,[3,4];case 3:return this.initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch ".concat(t?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(e){return n(t,void 0,Promise,(function(){var t,r=this;return o(this,(function(i){switch(i.label){case 0:if(null!==this.rebuildWatchPromise&&void 0!==this.rebuildWatchPromise)return[2,this.rebuildWatchPromise];this.rebuildWatchPromise=new Promise((function(t,i){n(r,void 0,void 0,(function(){var r,n,s,c;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.watchStatus===a.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):[4,this.wsLogin(this.envId,e)];case 1:if(r=o.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===a.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):(this.watchStatus=a.REBUILDING,n={watchId:this.watchId,requestId:(0,d.genRequestId)(),msgType:"REBUILD_WATCH",msgData:{envId:r,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:n,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return s=o.sent(),this.handleServerEvents(s),this.watchStatus=a.ACTIVE,this.availableRetries.REBUILD_WATCH=2,t(),[3,4];case 3:return c=o.sent(),this.handleWatchEstablishmentError(c,{operationName:"REBUILD_WATCH",resolve:t,reject:i}),[3,4];case 4:return[2]}}))}))})),t=!1,i.label=1;case 1:return i.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return i.sent(),t=!0,[3,4];case 3:return this.rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch ".concat(t?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(e,r){return n(t,void 0,void 0,(function(){var t,i,s,c=this;return o(this,(function(u){return t="INIT_WATCH"===r.operationName,i=function(){c.closeWithError(new f.CloudSDKError({errCode:t?f.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:f.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),r.reject(e)},s=function(e){c.useRetryTicket(r.operationName)?t?(c.initWatchPromise=void 0,r.resolve(c.initWatch(e))):(c.rebuildWatchPromise=void 0,r.resolve(c.rebuildWatch(e))):i()},this.handleCommonError(e,{onSignError:function(){return s(!0)},onTimeoutError:function(){return s(!1)},onNotRetryableError:i,onCancelledError:r.reject,onUnknownError:function(){n(c,void 0,void 0,(function(){var e,t=this;return o(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),e=function(){return n(t,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return e.sent(),s(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,e()];case 1:return i.sent(),[3,7];case 2:return[4,(0,v.sleep)(100)];case 3:return i.sent(),this.watchStatus!==a.PAUSED?[3,4]:(r.reject(new f.CancelledError("".concat(r.operationName," cancelled due to pause after unknownError"))),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,e()];case 5:return i.sent(),[3,7];case 6:s(!1),i.label=7;case 7:return[3,9];case 8:return i.sent(),s(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return n(t,void 0,void 0,(function(){var e,t,r;return o(this,(function(n){switch(n.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==a.ACTIVE)return this.watchStatus=a.CLOSED,this.onWatchClose(this,e),[2];n.label=1;case 1:return n.trys.push([1,3,4,5]),this.watchStatus=a.CLOSING,t={watchId:this.watchId,requestId:(0,d.genRequestId)(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];case 2:return n.sent(),this.sessionInfo=void 0,this.watchStatus=a.CLOSED,[3,5];case 3:return r=n.sent(),this.closeWithError(new f.CloudSDKError({errCode:f.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:r})),[3,5];case 4:return this.onWatchClose(this,e),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){t.clearACKSchedule(),t.ackTimeoutId=setTimeout((function(){t.waitExpectedTimeoutId?t.scheduleSendACK():t.sendACK()}),1e4)},this.clearACKSchedule=function(){t.ackTimeoutId&&clearTimeout(t.ackTimeoutId)},this.sendACK=function(){return n(t,void 0,Promise,(function(){var e,t,r;return o(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.watchStatus!==a.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(e={watchId:this.watchId,requestId:(0,d.genRequestId)(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:e})]):(console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"),[2]);case 1:return n.sent(),this.scheduleSendACK(),[3,3];case 2:if(t=n.sent(),(0,f.isRealtimeErrorMessageError)(t))switch((r=t.payload).msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return this.rebuildWatch(),[2];case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":return this.closeWithError(new f.CloudSDKError({errCode:f.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:r.msgData.code})),[2]}return this.availableRetries.CHECK_LAST&&this.availableRetries.CHECK_LAST>0?(this.availableRetries.CHECK_LAST-=1,this.scheduleSendACK()):this.closeWithError(new f.CloudSDKError({errCode:f.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if((0,f.isRealtimeErrorMessageError)(e))switch(e.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void t.onSignError(e);default:return void t.onNotRetryableError(e)}else{if((0,f.isTimeoutError)(e))return void t.onTimeoutError(e);if((0,f.isCancelledError)(e))return void t.onCancelledError(e)}t.onUnknownError(e)},this.watchId="watchid_".concat(+new Date,"_").concat(Math.random()),this.envId=e.envId,this.collectionName=e.collectionName,this.query=e.query,this.limit=e.limit,this.orderBy=e.orderBy,this.send=e.send,this.login=e.login,this.isWSConnected=e.isWSConnected,this.onceWSConnected=e.onceWSConnected,this.getWaitExpectedTimeoutLength=e.getWaitExpectedTimeoutLength,this.onWatchStart=e.onWatchStart,this.onWatchClose=e.onWatchClose,this.debug=e.debug,this.availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new h.RealtimeListener({close:function(){t.closeWatch()},onChange:e.onChange,onError:e.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return e.prototype.onMessage=function(e){var t=this;switch(this.watchStatus){case a.PAUSED:if("ERROR"!==e.msgType)return;break;case a.LOGGINGIN:case a.INITING:case a.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while ".concat(this.watchStatus));case a.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case a.ERRORED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has ended with error")}if(this.sessionInfo)switch(this.scheduleSendACK(),e.msgType){case"NEXT_EVENT":console.warn("nextevent ".concat(e.msgData.currEvent," ignored"),e),this.handleServerEvents(e);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<e.msgData.currEvent&&(this.sessionInfo.expectEventId=e.msgData.currEvent,this.clearWaitExpectedEvent(),this.waitExpectedTimeoutId=setTimeout((function(){t.rebuildWatch()}),this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength ".concat(this.getWaitExpectedTimeoutLength())));break;case"ERROR":this.closeWithError(new f.CloudSDKError({errCode:f.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:"".concat(e.msgData.code," - ").concat(e.msgData.message)}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg ".concat(e.msgType,": "),e)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},e.prototype.closeWithError=function(e){var t;this.watchStatus=a.ERRORED,this.clearACKSchedule(),this.listener.onError(e),this.onWatchClose(this,(null===(t=this.sessionInfo)||void 0===t?void 0:t.queryID)||""),console.log("[realtime] client closed (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},e.prototype.pause=function(){this.watchStatus=a.PAUSED,console.log("[realtime] client paused (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},e.prototype.resume=function(){return n(this,void 0,Promise,(function(){var e;return o(this,(function(t){switch(t.label){case 0:this.watchStatus=a.RESUMING,console.log("[realtime] client resuming with ".concat(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH"," (").concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return t.sent(),console.log("[realtime] client successfully resumed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),[3,4];case 3:return e=t.sent(),console.error("[realtime] client resume failed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")"),e),[3,4];case 4:return[2]}}))}))},e.prototype.useRetryTicket=function(e){return!!(this.availableRetries[e]&&this.availableRetries[e]>0)&&(this.availableRetries[e]-=1,console.log("[realtime] ".concat(e," use a retry ticket, now only ").concat(this.availableRetries[e]," retry left")),!0)},e.prototype.handleServerEvents=function(e){return n(this,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(e)];case 1:return r.sent(),this.postHandleServerEventsValidityCheck(e),[3,3];case 2:throw t=r.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",t),t;case 3:return[2]}}))}))},e.prototype.handleServerEventsInternel=function(e){return n(this,void 0,void 0,(function(){var t,r,n,s,a,d,h,v,E,_,m,I;return o(this,(function(b){switch(b.label){case 0:if(t=e.requestId,r=e.msgData.events,n=e.msgType,!r.length||!this.sessionInfo)return[2];s=this.sessionInfo;try{a=r.map(g)}catch(e){return this.closeWithError(new f.CloudSDKError({errCode:f.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}d=i([],s.currentDocs,!0),h=!1,v=function(r,v){var g,_,m,I,b,y,w,S,T,C,R,A;return o(this,(function(o){switch(o.label){case 0:return g=a[r],s.currentEventId>=g.id?(!a[r-1]||g.id>a[r-1].id?console.warn("[realtime] duplicate event received, cur ".concat(s.currentEventId," but got ").concat(g.id)):console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId ".concat(t,")")),[2,"continue"]):[3,1];case 1:if(s.currentEventId!==g.id-1)return[3,2];switch(g.dataType){case"update":if(!g.doc)switch(g.queueType){case"update":case"dequeue":if(_=d.find((function(e){return e._id===g.docId})),_){if(m=(0,l.default)(_),g.updatedFields&&Object.keys(g.updatedFields).forEach((function(e){(0,c.default)(m,e,g.updatedFields[e])})),g.removedFields)for(I=0,b=g.removedFields;I<b.length;I++)y=b[I],(0,u.default)(m,y);g.doc=m}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw S=new f.CloudSDKError({errCode:f.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '.concat(e.requestId,")")}),E.closeWithError(S),S}break;case"replace":if(!g.doc)throw S=new f.CloudSDKError({errCode:f.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '.concat(e.requestId,")")}),E.closeWithError(S),S;break;case"remove":(w=d.find((function(e){return e._id===g.docId})))?g.doc=w:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!g.doc)switch(g.queueType){case"dequeue":(w=d.find((function(e){return e._id===g.docId})))?g.doc=w:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw S=new f.CloudSDKError({errCode:f.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '.concat(e.requestId,")")}),E.closeWithError(S),S}}switch(g.queueType){case"init":h?d.push(g.doc):(h=!0,d=[g.doc]);break;case"enqueue":d.push(g.doc);break;case"dequeue":T=d.findIndex((function(e){return e._id===g.docId})),T>-1?d.splice(T,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":T=d.findIndex((function(e){return e._id===g.docId})),T>-1?d[T]=g.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(r===v-1||a[r+1]&&a[r+1].id!==g.id)&&(C=i([],d,!0),R=a.slice(0,r+1).filter((function(e){return e.id===g.id})),E.sessionInfo.currentEventId=g.id,E.sessionInfo.currentDocs=d,A=new p.Snapshot({id:g.id,docChanges:R,docs:C,msgType:n}),E.listener.onChange(A)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(E.sessionInfo.currentEventId," but got ").concat(g.id)),[4,E.rebuildWatch()];case 3:return o.sent(),[2,{value:void 0}];case 4:return[2]}}))},E=this,_=0,m=a.length,b.label=1;case 1:return _<m?[5,v(_,m)]:[3,4];case 2:if("object"==typeof(I=b.sent()))return[2,I.value];b.label=3;case 3:return _++,[3,1];case 4:return[2]}}))}))},e.prototype.postHandleServerEventsValidityCheck=function(e){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<e.msgData.currEvent&&console.warn("[realtime listener] internal non-fatal error: client eventId does not match with server event id after server event handling")):console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur")},e.prototype.clearWaitExpectedEvent=function(){this.waitExpectedTimeoutId&&(clearTimeout(this.waitExpectedTimeoutId),this.waitExpectedTimeoutId=void 0)},e}();function g(e){var t={id:e.ID,dataType:e.DataType,queueType:e.QueueType,docId:e.DocID,doc:e.Doc&&"{}"!==e.Doc?JSON.parse(e.Doc):void 0};return"update"===e.DataType&&(e.UpdatedFields&&(t.updatedFields=JSON.parse(e.UpdatedFields)),(e.removedFields||e.RemovedFields)&&(t.removedFields=JSON.parse(e.removedFields))),t}t.VirtualWebSocketClient=E},2347:function(e,t,r){"use strict";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{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((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(c){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,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.RealtimeWebSocketClient=void 0;var s=r(4151),a=r(3994),c=r(636),u=r(2917),l=r(6511),d=r(7589),h=function(){function e(e){var t=this;this.virtualWSClient=new Set,this.queryIdClientMap=new Map,this.watchIdClientMap=new Map,this.pingFailed=0,this.pongMissed=0,this.logins=new Map,this.wsReadySubsribers=[],this.wsResponseWait=new Map,this.rttObserved=[],this.send=function(e){return o(t,void 0,Promise,(function(){var t=this;return i(this,(function(r){return[2,new Promise((function(r,n){o(t,void 0,void 0,(function(){var t,s,a,c,l,h,p,f,v=this;return i(this,(function(E){switch(E.label){case 0:s=!1,a=!1,c=function(e){s=!0,t&&clearTimeout(t),r(e)},l=function(e){a=!0,t&&clearTimeout(t),n(e)},e.timeout&&(t=setTimeout((function(){o(v,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return s&&a?[3,2]:[4,(0,d.sleep)(0)];case 1:e.sent(),s&&a||l(new u.TimeoutError("wsclient.send timedout")),e.label=2;case 2:return[2]}}))}))}),e.timeout)),E.label=1;case 1:return E.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:E.sent(),E.label=3;case 3:if(!this.ws)return l(new Error("invalid state: ws connection not exists, can not send message")),[2];if(1!==this.ws.readyState)return l(new Error("ws readyState invalid: ".concat(this.ws.readyState,", can not send message"))),[2];e.waitResponse&&(h={resolve:c,reject:l,skipOnMessage:e.skipOnMessage},this.wsResponseWait.set(e.msg.requestId,h)),E.label=4;case 4:return E.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(e.msg))];case 5:return E.sent(),e.waitResponse||c(void 0),[3,7];case 6:return(p=E.sent())&&(l(p),e.waitResponse&&this.wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return f=E.sent(),l(f),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(e){t.virtualWSClient.forEach((function(t){t.closeWithError(e)}))},this.pauseClients=function(e){(e||t.virtualWSClient).forEach((function(e){e.pause()}))},this.resumeClients=function(e){(e||t.virtualWSClient).forEach((function(e){e.resume()}))},this.initWebSocketConnection=function(e,r){return void 0===r&&(r=t.maxReconnect),o(t,void 0,Promise,(function(){var t=this;return i(this,(function(n){switch(n.label){case 0:if(e&&this.reconnectState)return[2];if(e&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];e&&this.pauseClients(),this.close(c.CloseEventCode.ReconnectWebSocket),this.wsInitPromise=new Promise((function(n,s){o(t,void 0,void 0,(function(){var t,o,a=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return t=i.sent(),[4,new Promise((function(e){var r=t.wsUrl||"wss://tcb-ws.tencentcloudapi.com",n=(0,l.getWsClass)();a.ws=n?new n(r):new WebSocket(r),e(void 0)}))];case 2:return i.sent(),this.ws.connect?[4,this.ws.connect()]:[3,4];case 3:i.sent(),i.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return i.sent(),n(),e&&(this.resumeClients(),this.reconnectState=!1),[3,11];case 6:return o=i.sent(),console.error("[realtime] initWebSocketConnection connect fail",o),r>0?(this.wsInitPromise=void 0,[4,(0,d.sleep)(this.reconnectInterval)]):[3,9];case 7:i.sent(),e&&(this.reconnectState=!1),i.label=8;case 8:return n(this.initWebSocketConnection(e,r-1)),[3,10];case 9:s(o),e&&this.closeAllClients(new u.CloudSDKError({errCode:u.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:o})),i.label=10;case 10:return[3,11];case 11:return[2]}}))}))})),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,this.wsInitPromise];case 2:return n.sent(),this.wsReadySubsribers.forEach((function(e){return(0,e.resolve)()})),[3,5];case 3:return n.sent(),this.wsReadySubsribers.forEach((function(e){return(0,e.reject)()})),[3,5];case 4:return this.wsInitPromise=void 0,this.wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(e,r){if(!t.ws)throw new Error("can not initWebSocketEvent, ws not exists");var n=!1;t.ws.onopen=function(t){console.warn("[realtime] ws event: open",t),n=!0,e()},t.ws.onerror=function(e){t.logins=new Map,n?(console.error("[realtime] ws event: error",e),t.clearHeartbeat(),t.virtualWSClient.forEach((function(t){return t.closeWithError(new u.CloudSDKError({errCode:u.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:e}))}))):(console.error("[realtime] ws open failed with ws event: error",e),r(e))},t.ws.onclose=function(e){switch(console.warn("[realtime] ws event: close",e),t.logins=new Map,t.clearHeartbeat(),e.code){case c.CloseEventCode.ReconnectWebSocket:case c.CloseEventCode.NoRealtimeListeners:break;case c.CloseEventCode.HeartbeatPingError:case c.CloseEventCode.HeartbeatPongTimeoutError:case c.CloseEventCode.NormalClosure:case c.CloseEventCode.AbnormalClosure:t.maxReconnect>0?t.initWebSocketConnection(!0,t.maxReconnect):t.closeAllClients((0,c.getWSCloseError)(e.code));break;case c.CloseEventCode.NoAuthentication:t.closeAllClients((0,c.getWSCloseError)(e.code,e.reason));break;default:t.maxReconnect>0?t.initWebSocketConnection(!0,t.maxReconnect):t.closeAllClients((0,c.getWSCloseError)(e.code))}},t.ws.onmessage=function(e){var r,n,o=(null===(r=e.data)||void 0===r?void 0:r.data)||e.data;t.heartbeat();try{n="string"==typeof o?JSON.parse(o):o}catch(e){throw new Error("[realtime] onMessage parse res.data error: ".concat(e))}if("ERROR"===n.msgType){var i=null;t.virtualWSClient.forEach((function(e){e.watchId===n.watchId&&(i=e)})),i&&i.listener.onError(n)}var s=t.wsResponseWait.get(n.requestId);if(s){try{"ERROR"===n.msgType?s.reject(new u.RealtimeErrorMessageError(n)):s.resolve(n)}catch(e){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",e)}finally{t.wsResponseWait.delete(n.requestId)}if(s.skipOnMessage)return}if("PONG"!==n.msgType){var a=n.watchId&&t.watchIdClientMap.get(n.watchId);if(a)a.onMessage(n);else switch(console.error("[realtime] no realtime listener found responsible for watchId ".concat(n.watchId,": "),n),n.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(a=t.queryIdClientMap.get(n.msgData.queryID))&&a.onMessage(n);break;default:for(var c=0,l=Array.from(t.watchIdClientMap.entries());c<l.length;c++){l[c][1].onMessage(n);break}}}else if(t.lastPingSendTS){var d=Date.now()-t.lastPingSendTS;if(d>1e4)return void console.warn("[realtime] untrusted rtt observed: ".concat(d));t.rttObserved.length>=3&&t.rttObserved.splice(0,t.rttObserved.length-3+1),t.rttObserved.push(d)}},t.heartbeat()}))},this.isWSConnected=function(){return Boolean(t.ws&&1===t.ws.readyState)},this.onceWSConnected=function(){return o(t,void 0,Promise,(function(){var e=this;return i(this,(function(t){return this.isWSConnected()?[2]:null!==this.wsInitPromise&&void 0!==this.wsInitPromise?[2,this.wsInitPromise]:[2,new Promise((function(t,r){e.wsReadySubsribers.push({resolve:t,reject:r})}))]}))}))},this.webLogin=function(e,r){return o(t,void 0,Promise,(function(){var t,n,s,c,u,d,h,p,f=this;return i(this,(function(v){switch(v.label){case 0:if(!r)if(e){if(t=this.logins.get(e)){if(t.loggedIn&&t.loginResult)return[2,t.loginResult];if(null!==t.loggingInPromise&&void 0!==t.loggingInPromise)return[2,t.loggingInPromise]}}else if(null!==(null==(n=this.logins.get(""))?void 0:n.loggingInPromise)&&void 0!==(null==n?void 0:n.loggingInPromise))return[2,n.loggingInPromise];s=new Promise((function(e,t){o(f,void 0,void 0,(function(){var r,n,o,s,c;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return r=i.sent(),n={envId:r.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:(0,a.genRequestId)(),msgType:"LOGIN",msgData:n,exMsgData:{runtime:(0,l.getRuntime)(),signStr:r.signStr,secretVersion:r.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(s=i.sent()).msgData.code?t(new Error("".concat(s.msgData.code," ").concat(s.msgData.message))):e({envId:r.envId}),[3,4];case 3:return c=i.sent(),t(c),[3,4];case 4:return[2]}}))}))})),c=e&&this.logins.get(e),u=Date.now(),c?(c.loggedIn=!1,c.loggingInPromise=s,c.loginStartTS=u):(c={loggedIn:!1,loggingInPromise:s,loginStartTS:u},this.logins.set(e||"",c)),v.label=1;case 1:return v.trys.push([1,3,,4]),[4,s];case 2:if(d=v.sent(),(h=e&&this.logins.get(e))&&h===c&&h.loginStartTS===u)return c.loggedIn=!0,c.loggingInPromise=void 0,c.loginStartTS=void 0,c.loginResult=d,[2,d];if(h){if(h.loggedIn&&h.loginResult)return[2,h.loginResult];if(null!==h.loggingInPromise&&void 0!==h.loggingInPromise)return[2,h.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw p=v.sent(),c.loggedIn=!1,c.loggingInPromise=void 0,c.loginStartTS=void 0,c.loginResult=void 0,p;case 4:return[2]}}))}))},this.getWsSign=function(){return o(t,void 0,Promise,(function(){var e,t,r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:return this.wsSign&&this.wsSign.expiredTs>Date.now()?[2,this.wsSign]:(e=Date.now()+6e4,[4,this.context.appConfig.request.send("auth.wsWebSign",{runtime:(0,l.getRuntime)()})]);case 1:if((t=i.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: ".concat(t.code));if(t.data)return r=t.data,n=r.signStr,o=r.wsUrl,s=r.secretVersion,a=r.envId,[2,{signStr:n,wsUrl:o,secretVersion:s,envId:a,expiredTs:e}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return t.rttObserved.length?t.rttObserved.reduce((function(e,t){return e+t}))/t.rttObserved.length*1.5:5e3},this.ping=function(){return o(t,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:(0,a.genRequestId)(),msgType:"PING",msgData:null},[4,this.send({msg:e})];case 1:return t.sent(),[2]}}))}))},this.onWatchStart=function(e,r){t.queryIdClientMap.set(r,e)},this.onWatchClose=function(e,r){r&&t.queryIdClientMap.delete(r),t.watchIdClientMap.delete(e.watchId),t.virtualWSClient.delete(e),t.virtualWSClient.size||t.close(c.CloseEventCode.NoRealtimeListeners)},this.maxReconnect=e.maxReconnect||5,this.reconnectInterval=e.reconnectInterval||1e4,this.context=e.context}return e.prototype.clearHeartbeat=function(){this.pingTimeoutId&&clearTimeout(this.pingTimeoutId),this.pongTimeoutId&&clearTimeout(this.pongTimeoutId)},e.prototype.close=function(e){this.clearHeartbeat(),this.ws&&(this.ws.close(e,c.CLOSE_EVENT_CODE_INFO[e].name),this.ws=void 0)},e.prototype.watch=function(e){this.ws||void 0!==this.wsInitPromise&&null!==this.wsInitPromise||this.initWebSocketConnection(!1);var t=new s.VirtualWebSocketClient(n(n({},e),{send:this.send,login:this.webLogin,isWSConnected:this.isWSConnected,onceWSConnected:this.onceWSConnected,getWaitExpectedTimeoutLength:this.getWaitExpectedTimeoutLength,onWatchStart:this.onWatchStart,onWatchClose:this.onWatchClose,debug:!0}));return this.virtualWSClient.add(t),this.watchIdClientMap.set(t.watchId,t),t.listener},e.prototype.heartbeat=function(e){var t=this;this.clearHeartbeat(),this.pingTimeoutId=setTimeout((function(){o(t,void 0,void 0,(function(){var e=this;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.ws&&1===this.ws.readyState?(this.lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return t.sent(),this.pingFailed=0,this.pongTimeoutId=setTimeout((function(){console.error("pong timed out"),e.pongMissed<2?(e.pongMissed+=1,e.heartbeat(!0)):e.initWebSocketConnection(!0)}),this.context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return t.sent(),this.pingFailed<2?(this.pingFailed+=1,this.heartbeat()):this.close(c.CloseEventCode.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),e?0:this.context.appConfig.realtimePingInterval)},e}();t.RealtimeWebSocketClient=h},636:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getWSCloseError=t.CloseEventCode=t.CLOSE_EVENT_CODE_INFO=void 0;var n,o=r(2917);t.CLOSE_EVENT_CODE_INFO={1e3:{code:1e3,name:"Normal Closure",description:"Normal closure; the connection successfully completed whatever purpose for which it was created."},1001:{code:1001,name:"Going Away",description:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{code:1002,name:"Protocol Error",description:"The endpoint is terminating the connection due to a protocol error."},1003:{code:1003,name:"Unsupported Data",description:"The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)."},1005:{code:1005,name:"No Status Received",description:"Indicates that no status code was provided even though one was expected."},1006:{code:1006,name:"Abnormal Closure",description:"Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{code:1007,name:"Invalid frame payload data",description:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{code:1008,name:"Policy Violation",description:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{code:1009,name:"Message too big",description:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{code:1010,name:"Missing Extension",description:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{code:1011,name:"Internal Error",description:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{code:1012,name:"Service Restart",description:"The server is terminating the connection because it is restarting."},1013:{code:1013,name:"Try Again Later",description:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{code:1014,name:"Bad Gateway",description:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{code:1015,name:"TLS Handshake",description:"Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},3e3:{code:3e3,name:"Reconnect WebSocket",description:"The client is terminating the connection because it wants to reconnect"},3001:{code:3001,name:"No Realtime Listeners",description:"The client is terminating the connection because no more realtime listeners exist"},3002:{code:3002,name:"Heartbeat Ping Error",description:"The client is terminating the connection due to its failure in sending heartbeat messages"},3003:{code:3003,name:"Heartbeat Pong Timeout Error",description:"The client is terminating the connection because no heartbeat response is received from the server"},3050:{code:3050,name:"Server Close",description:"The client is terminating the connection because no heartbeat response is received from the server"}},(n=t.CloseEventCode||(t.CloseEventCode={}))[n.NormalClosure=1e3]="NormalClosure",n[n.GoingAway=1001]="GoingAway",n[n.ProtocolError=1002]="ProtocolError",n[n.UnsupportedData=1003]="UnsupportedData",n[n.NoStatusReceived=1005]="NoStatusReceived",n[n.AbnormalClosure=1006]="AbnormalClosure",n[n.InvalidFramePayloadData=1007]="InvalidFramePayloadData",n[n.PolicyViolation=1008]="PolicyViolation",n[n.MessageTooBig=1009]="MessageTooBig",n[n.MissingExtension=1010]="MissingExtension",n[n.InternalError=1011]="InternalError",n[n.ServiceRestart=1012]="ServiceRestart",n[n.TryAgainLater=1013]="TryAgainLater",n[n.BadGateway=1014]="BadGateway",n[n.TLSHandshake=1015]="TLSHandshake",n[n.ReconnectWebSocket=3e3]="ReconnectWebSocket",n[n.NoRealtimeListeners=3001]="NoRealtimeListeners",n[n.HeartbeatPingError=3002]="HeartbeatPingError",n[n.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",n[n.NoAuthentication=3050]="NoAuthentication",t.getWSCloseError=function(e,r){var n=t.CLOSE_EVENT_CODE_INFO[e],i=n?"".concat(n.name,", code ").concat(e,", reason ").concat(r||n.description):"code ".concat(e);return new o.CloudSDKError({errCode:o.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:i})}},9515:(e,t,r)=>{var n=r(8761)(r(7772),"DataView");e.exports=n},9612:(e,t,r)=>{var n=r(2118),o=r(6909),i=r(8138),s=r(4174),a=r(7942);function c(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}c.prototype.clear=n,c.prototype.delete=o,c.prototype.get=i,c.prototype.has=s,c.prototype.set=a,e.exports=c},235:(e,t,r)=>{var n=r(3945),o=r(1846),i=r(8028),s=r(2344),a=r(4769);function c(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}c.prototype.clear=n,c.prototype.delete=o,c.prototype.get=i,c.prototype.has=s,c.prototype.set=a,e.exports=c},326:(e,t,r)=>{var n=r(8761)(r(7772),"Map");e.exports=n},6738:(e,t,r)=>{var n=r(2411),o=r(6417),i=r(6928),s=r(9493),a=r(4150);function c(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}c.prototype.clear=n,c.prototype.delete=o,c.prototype.get=i,c.prototype.has=s,c.prototype.set=a,e.exports=c},2760:(e,t,r)=>{var n=r(8761)(r(7772),"Promise");e.exports=n},2143:(e,t,r)=>{var n=r(8761)(r(7772),"Set");e.exports=n},6571:(e,t,r)=>{var n=r(235),o=r(5243),i=r(2858),s=r(4417),a=r(8605),c=r(1418);function u(e){var t=this.__data__=new n(e);this.size=t.size}u.prototype.clear=o,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=a,u.prototype.set=c,e.exports=u},857:(e,t,r)=>{var n=r(7772).Symbol;e.exports=n},9162:(e,t,r)=>{var n=r(7772).Uint8Array;e.exports=n},3215:(e,t,r)=>{var n=r(8761)(r(7772),"WeakMap");e.exports=n},2517:e=>{e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}},7552:e=>{e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length,o=0,i=[];++r<n;){var s=e[r];t(s,r,e)&&(i[o++]=s)}return i}},1634:(e,t,r)=>{var n=r(6473),o=r(9631),i=r(6152),s=r(3226),a=r(9045),c=r(7598),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var r=i(e),l=!r&&o(e),d=!r&&!l&&s(e),h=!r&&!l&&!d&&c(e),p=r||l||d||h,f=p?n(e.length,String):[],v=f.length;for(var E in e)!t&&!u.call(e,E)||p&&("length"==E||d&&("offset"==E||"parent"==E)||h&&("buffer"==E||"byteLength"==E||"byteOffset"==E)||a(E,v))||f.push(E);return f}},343:e=>{e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}},5067:e=>{e.exports=function(e,t){for(var r=-1,n=t.length,o=e.length;++r<n;)e[o+r]=t[r];return e}},91:(e,t,r)=>{var n=r(3940),o=r(1225),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,r){var s=e[t];i.call(e,t)&&o(s,r)&&(void 0!==r||t in e)||n(e,t,r)}},2218:(e,t,r)=>{var n=r(1225);e.exports=function(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}},7993:(e,t,r)=>{var n=r(752),o=r(249);e.exports=function(e,t){return e&&n(t,o(t),e)}},5906:(e,t,r)=>{var n=r(752),o=r(8582);e.exports=function(e,t){return e&&n(t,o(t),e)}},3940:(e,t,r)=>{var n=r(3043);e.exports=function(e,t,r){"__proto__"==t&&n?n(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}},8874:(e,t,r)=>{var n=r(6571),o=r(2517),i=r(91),s=r(7993),a=r(5906),c=r(2175),u=r(1522),l=r(7680),d=r(9987),h=r(3483),p=r(6939),f=r(940),v=r(9917),E=r(8222),g=r(8725),_=r(6152),m=r(3226),I=r(4714),b=r(9259),y=r(3679),w=r(249),S=r(8582),T="[object Arguments]",C="[object Function]",R="[object Object]",A={};A[T]=A["[object Array]"]=A["[object ArrayBuffer]"]=A["[object DataView]"]=A["[object Boolean]"]=A["[object Date]"]=A["[object Float32Array]"]=A["[object Float64Array]"]=A["[object Int8Array]"]=A["[object Int16Array]"]=A["[object Int32Array]"]=A["[object Map]"]=A["[object Number]"]=A[R]=A["[object RegExp]"]=A["[object Set]"]=A["[object String]"]=A["[object Symbol]"]=A["[object Uint8Array]"]=A["[object Uint8ClampedArray]"]=A["[object Uint16Array]"]=A["[object Uint32Array]"]=!0,A["[object Error]"]=A[C]=A["[object WeakMap]"]=!1,e.exports=function e(t,r,D,x,O,N){var W,L=1&r,j=2&r,P=4&r;if(D&&(W=O?D(t,x,O,N):D(t)),void 0!==W)return W;if(!b(t))return t;var M=_(t);if(M){if(W=v(t),!L)return u(t,W)}else{var k=f(t),K=k==C||"[object GeneratorFunction]"==k;if(m(t))return c(t,L);if(k==R||k==T||K&&!O){if(W=j||K?{}:g(t),!L)return j?d(t,a(W,t)):l(t,s(W,t))}else{if(!A[k])return O?t:{};W=E(t,k,L)}}N||(N=new n);var q=N.get(t);if(q)return q;N.set(t,W),y(t)?t.forEach((function(n){W.add(e(n,r,D,n,t,N))})):I(t)&&t.forEach((function(n,o){W.set(o,e(n,r,D,o,t,N))}));var B=M?void 0:(P?j?p:h:j?S:w)(t);return o(B||t,(function(n,o){B&&(n=t[o=n]),i(W,o,e(n,r,D,o,t,N))})),W}},9413:(e,t,r)=>{var n=r(9259),o=Object.create,i=function(){function e(){}return function(t){if(!n(t))return{};if(o)return o(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();e.exports=i},3324:(e,t,r)=>{var n=r(7297),o=r(3812);e.exports=function(e,t){for(var r=0,i=(t=n(t,e)).length;null!=e&&r<i;)e=e[o(t[r++])];return r&&r==i?e:void 0}},1897:(e,t,r)=>{var n=r(5067),o=r(6152);e.exports=function(e,t,r){var i=t(e);return o(e)?i:n(i,r(e))}},3366:(e,t,r)=>{var n=r(857),o=r(2107),i=r(7157),s=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},5183:(e,t,r)=>{var n=r(3366),o=r(5125);e.exports=function(e){return o(e)&&"[object Arguments]"==n(e)}},4511:(e,t,r)=>{var n=r(940),o=r(5125);e.exports=function(e){return o(e)&&"[object Map]"==n(e)}},6840:(e,t,r)=>{var n=r(1049),o=r(7394),i=r(9259),s=r(7035),a=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,l=c.toString,d=u.hasOwnProperty,h=RegExp("^"+l.call(d).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!i(e)||o(e))&&(n(e)?h:a).test(s(e))}},8436:(e,t,r)=>{var n=r(940),o=r(5125);e.exports=function(e){return o(e)&&"[object Set]"==n(e)}},5522:(e,t,r)=>{var n=r(3366),o=r(1158),i=r(5125),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,e.exports=function(e){return i(e)&&o(e.length)&&!!s[n(e)]}},6411:(e,t,r)=>{var n=r(6001),o=r(4248),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!n(e))return o(e);var t=[];for(var r in Object(e))i.call(e,r)&&"constructor"!=r&&t.push(r);return t}},8390:(e,t,r)=>{var n=r(9259),o=r(6001),i=r(2966),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!n(e))return i(e);var t=o(e),r=[];for(var a in e)("constructor"!=a||!t&&s.call(e,a))&&r.push(a);return r}},2857:(e,t,r)=>{var n=r(91),o=r(7297),i=r(9045),s=r(9259),a=r(3812);e.exports=function(e,t,r,c){if(!s(e))return e;for(var u=-1,l=(t=o(t,e)).length,d=l-1,h=e;null!=h&&++u<l;){var p=a(t[u]),f=r;if("__proto__"===p||"constructor"===p||"prototype"===p)return e;if(u!=d){var v=h[p];void 0===(f=c?c(v,p,h):void 0)&&(f=s(v)?v:i(t[u+1])?[]:{})}n(h,p,f),h=h[p]}return e}},9872:e=>{e.exports=function(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(r=r>o?o:r)<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}},6473:e=>{e.exports=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}},1054:(e,t,r)=>{var n=r(857),o=r(343),i=r(6152),s=r(4795),a=n?n.prototype:void 0,c=a?a.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(i(t))return o(t,e)+"";if(s(t))return c?c.call(t):"";var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}},7826:e=>{e.exports=function(e){return function(t){return e(t)}}},9078:(e,t,r)=>{var n=r(7297),o=r(6974),i=r(2721),s=r(3812);e.exports=function(e,t){return t=n(t,e),null==(e=i(e,t))||delete e[s(o(t))]}},7297:(e,t,r)=>{var n=r(6152),o=r(1401),i=r(4452),s=r(6188);e.exports=function(e,t){return n(e)?e:o(e,t)?[e]:i(s(e))}},9882:(e,t,r)=>{var n=r(9162);e.exports=function(e){var t=new e.constructor(e.byteLength);return new n(t).set(new n(e)),t}},2175:(e,t,r)=>{e=r.nmd(e);var n=r(7772),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o?n.Buffer:void 0,a=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=a?a(r):new e.constructor(r);return e.copy(n),n}},4727:(e,t,r)=>{var n=r(9882);e.exports=function(e,t){var r=t?n(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}},6058:e=>{var t=/\w*$/;e.exports=function(e){var r=new e.constructor(e.source,t.exec(e));return r.lastIndex=e.lastIndex,r}},169:(e,t,r)=>{var n=r(857),o=n?n.prototype:void 0,i=o?o.valueOf:void 0;e.exports=function(e){return i?Object(i.call(e)):{}}},6190:(e,t,r)=>{var n=r(9882);e.exports=function(e,t){var r=t?n(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}},1522:e=>{e.exports=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}},752:(e,t,r)=>{var n=r(91),o=r(3940);e.exports=function(e,t,r,i){var s=!r;r||(r={});for(var a=-1,c=t.length;++a<c;){var u=t[a],l=i?i(r[u],e[u],u,r,e):void 0;void 0===l&&(l=e[u]),s?o(r,u,l):n(r,u,l)}return r}},7680:(e,t,r)=>{var n=r(752),o=r(633);e.exports=function(e,t){return n(e,o(e),t)}},9987:(e,t,r)=>{var n=r(752),o=r(2680);e.exports=function(e,t){return n(e,o(e),t)}},4019:(e,t,r)=>{var n=r(7772)["__core-js_shared__"];e.exports=n},3043:(e,t,r)=>{var n=r(8761),o=function(){try{var e=n(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=o},1242:(e,t,r)=>{var n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g;e.exports=n},3483:(e,t,r)=>{var n=r(1897),o=r(633),i=r(249);e.exports=function(e){return n(e,i,o)}},6939:(e,t,r)=>{var n=r(1897),o=r(2680),i=r(8582);e.exports=function(e){return n(e,i,o)}},7937:(e,t,r)=>{var n=r(8304);e.exports=function(e,t){var r=e.__data__;return n(t)?r["string"==typeof t?"string":"hash"]:r.map}},8761:(e,t,r)=>{var n=r(6840),o=r(8109);e.exports=function(e,t){var r=o(e,t);return n(r)?r:void 0}},7353:(e,t,r)=>{var n=r(241)(Object.getPrototypeOf,Object);e.exports=n},2107:(e,t,r)=>{var n=r(857),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=n?n.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),r=e[a];try{e[a]=void 0;var n=!0}catch(e){}var o=s.call(e);return n&&(t?e[a]=r:delete e[a]),o}},633:(e,t,r)=>{var n=r(7552),o=r(981),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(e){return null==e?[]:(e=Object(e),n(s(e),(function(t){return i.call(e,t)})))}:o;e.exports=a},2680:(e,t,r)=>{var n=r(5067),o=r(7353),i=r(633),s=r(981),a=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)n(t,i(e)),e=o(e);return t}:s;e.exports=a},940:(e,t,r)=>{var n=r(9515),o=r(326),i=r(2760),s=r(2143),a=r(3215),c=r(3366),u=r(7035),l="[object Map]",d="[object Promise]",h="[object Set]",p="[object WeakMap]",f="[object DataView]",v=u(n),E=u(o),g=u(i),_=u(s),m=u(a),I=c;(n&&I(new n(new ArrayBuffer(1)))!=f||o&&I(new o)!=l||i&&I(i.resolve())!=d||s&&I(new s)!=h||a&&I(new a)!=p)&&(I=function(e){var t=c(e),r="[object Object]"==t?e.constructor:void 0,n=r?u(r):"";if(n)switch(n){case v:return f;case E:return l;case g:return d;case _:return h;case m:return p}return t}),e.exports=I},8109:e=>{e.exports=function(e,t){return null==e?void 0:e[t]}},2118:(e,t,r)=>{var n=r(9191);e.exports=function(){this.__data__=n?n(null):{},this.size=0}},6909:e=>{e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},8138:(e,t,r)=>{var n=r(9191),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(n){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return o.call(t,e)?t[e]:void 0}},4174:(e,t,r)=>{var n=r(9191),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return n?void 0!==t[e]:o.call(t,e)}},7942:(e,t,r)=>{var n=r(9191);e.exports=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=n&&void 0===t?"__lodash_hash_undefined__":t,this}},9917:e=>{var t=Object.prototype.hasOwnProperty;e.exports=function(e){var r=e.length,n=new e.constructor(r);return r&&"string"==typeof e[0]&&t.call(e,"index")&&(n.index=e.index,n.input=e.input),n}},8222:(e,t,r)=>{var n=r(9882),o=r(4727),i=r(6058),s=r(169),a=r(6190);e.exports=function(e,t,r){var c=e.constructor;switch(t){case"[object ArrayBuffer]":return n(e);case"[object Boolean]":case"[object Date]":return new c(+e);case"[object DataView]":return o(e,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return a(e,r);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(e);case"[object RegExp]":return i(e);case"[object Symbol]":return s(e)}}},8725:(e,t,r)=>{var n=r(9413),o=r(7353),i=r(6001);e.exports=function(e){return"function"!=typeof e.constructor||i(e)?{}:n(o(e))}},9045:e=>{var t=/^(?:0|[1-9]\d*)$/;e.exports=function(e,r){var n=typeof e;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<r}},1401:(e,t,r)=>{var n=r(6152),o=r(4795),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(n(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!o(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},8304:e=>{e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},7394:(e,t,r)=>{var n,o=r(4019),i=(n=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"";e.exports=function(e){return!!i&&i in e}},6001:e=>{var t=Object.prototype;e.exports=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}},3945:e=>{e.exports=function(){this.__data__=[],this.size=0}},1846:(e,t,r)=>{var n=r(2218),o=Array.prototype.splice;e.exports=function(e){var t=this.__data__,r=n(t,e);return!(r<0||(r==t.length-1?t.pop():o.call(t,r,1),--this.size,0))}},8028:(e,t,r)=>{var n=r(2218);e.exports=function(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}},2344:(e,t,r)=>{var n=r(2218);e.exports=function(e){return n(this.__data__,e)>-1}},4769:(e,t,r)=>{var n=r(2218);e.exports=function(e,t){var r=this.__data__,o=n(r,e);return o<0?(++this.size,r.push([e,t])):r[o][1]=t,this}},2411:(e,t,r)=>{var n=r(9612),o=r(235),i=r(326);e.exports=function(){this.size=0,this.__data__={hash:new n,map:new(i||o),string:new n}}},6417:(e,t,r)=>{var n=r(7937);e.exports=function(e){var t=n(this,e).delete(e);return this.size-=t?1:0,t}},6928:(e,t,r)=>{var n=r(7937);e.exports=function(e){return n(this,e).get(e)}},9493:(e,t,r)=>{var n=r(7937);e.exports=function(e){return n(this,e).has(e)}},4150:(e,t,r)=>{var n=r(7937);e.exports=function(e,t){var r=n(this,e),o=r.size;return r.set(e,t),this.size+=r.size==o?0:1,this}},7777:(e,t,r)=>{var n=r(733);e.exports=function(e){var t=n(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}},9191:(e,t,r)=>{var n=r(8761)(Object,"create");e.exports=n},4248:(e,t,r)=>{var n=r(241)(Object.keys,Object);e.exports=n},2966:e=>{e.exports=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}},4146:(e,t,r)=>{e=r.nmd(e);var n=r(1242),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o&&n.process,a=function(){try{return i&&i.require&&i.require("util").types||s&&s.binding&&s.binding("util")}catch(e){}}();e.exports=a},7157:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},241:e=>{e.exports=function(e,t){return function(r){return e(t(r))}}},2721:(e,t,r)=>{var n=r(3324),o=r(9872);e.exports=function(e,t){return t.length<2?e:n(e,o(t,0,-1))}},7772:(e,t,r)=>{var n=r(1242),o="object"==typeof self&&self&&self.Object===Object&&self,i=n||o||Function("return this")();e.exports=i},5243:(e,t,r)=>{var n=r(235);e.exports=function(){this.__data__=new n,this.size=0}},2858:e=>{e.exports=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}},4417:e=>{e.exports=function(e){return this.__data__.get(e)}},8605:e=>{e.exports=function(e){return this.__data__.has(e)}},1418:(e,t,r)=>{var n=r(235),o=r(326),i=r(6738);e.exports=function(e,t){var r=this.__data__;if(r instanceof n){var s=r.__data__;if(!o||s.length<199)return s.push([e,t]),this.size=++r.size,this;r=this.__data__=new i(s)}return r.set(e,t),this.size=r.size,this}},4452:(e,t,r)=>{var n=r(7777),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=n((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(o,(function(e,r,n,o){t.push(n?o.replace(i,"$1"):r||e)})),t}));e.exports=s},3812:(e,t,r)=>{var n=r(4795);e.exports=function(e){if("string"==typeof e||n(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}},7035:e=>{var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},9850:(e,t,r)=>{var n=r(8874);e.exports=function(e){return n(e,5)}},1225:e=>{e.exports=function(e,t){return e===t||e!=e&&t!=t}},9631:(e,t,r)=>{var n=r(5183),o=r(5125),i=Object.prototype,s=i.hasOwnProperty,a=i.propertyIsEnumerable,c=n(function(){return arguments}())?n:function(e){return o(e)&&s.call(e,"callee")&&!a.call(e,"callee")};e.exports=c},6152:e=>{var t=Array.isArray;e.exports=t},7878:(e,t,r)=>{var n=r(1049),o=r(1158);e.exports=function(e){return null!=e&&o(e.length)&&!n(e)}},3226:(e,t,r)=>{e=r.nmd(e);var n=r(7772),o=r(6330),i=t&&!t.nodeType&&t,s=i&&e&&!e.nodeType&&e,a=s&&s.exports===i?n.Buffer:void 0,c=(a?a.isBuffer:void 0)||o;e.exports=c},1049:(e,t,r)=>{var n=r(3366),o=r(9259);e.exports=function(e){if(!o(e))return!1;var t=n(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},1158:e=>{e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},4714:(e,t,r)=>{var n=r(4511),o=r(7826),i=r(4146),s=i&&i.isMap,a=s?o(s):n;e.exports=a},9259:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},5125:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},3679:(e,t,r)=>{var n=r(8436),o=r(7826),i=r(4146),s=i&&i.isSet,a=s?o(s):n;e.exports=a},4795:(e,t,r)=>{var n=r(3366),o=r(5125);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==n(e)}},7598:(e,t,r)=>{var n=r(5522),o=r(7826),i=r(4146),s=i&&i.isTypedArray,a=s?o(s):n;e.exports=a},249:(e,t,r)=>{var n=r(1634),o=r(6411),i=r(7878);e.exports=function(e){return i(e)?n(e):o(e)}},8582:(e,t,r)=>{var n=r(1634),o=r(8390),i=r(7878);e.exports=function(e){return i(e)?n(e,!0):o(e)}},6974:e=>{e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},733:(e,t,r)=>{var n=r(6738);function o(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=e.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(o.Cache||n),r}o.Cache=n,e.exports=o},6765:(e,t,r)=>{var n=r(2857);e.exports=function(e,t,r){return null==e?e:n(e,t,r)}},981:e=>{e.exports=function(){return[]}},6330:e=>{e.exports=function(){return!1}},6188:(e,t,r)=>{var n=r(1054);e.exports=function(e){return null==e?"":n(e)}},7195:(e,t,r)=>{var n=r(9078);e.exports=function(e,t){return null==e||n(e,t)}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}return r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),r(8037)})()));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_storage",[],e):"object"==typeof exports?exports.cloudbase_storage=e():t.cloudbase_storage=e()}("undefined"!=typeof window?window:this,(()=>(()=>{var t={829:(t,e,r)=>{"use strict";var n;r.r(e),r.d(e,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>n,formatUrl:()=>a}),function(t){t.local="local",t.none="none",t.session="session"}(n||(n={}));var o=function(){},i=function(){};function a(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";for(var i in r)""===o?!n&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},891:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__decorate||function(t,e,r,n){var o,i=arguments.length,a=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},i=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},a=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseStorage=e.COMPONENT_NAME=e.EUploadMethod=void 0;var c,u=r(877),l=r(90),d=r(388);!function(t){t.put="put",t.post="post"}(c=e.EUploadMethod||(e.EUploadMethod={}));var f=u.constants.getSdkName,h=u.constants.ERRORS,p=u.constants.COMMUNITY_SITE_URL,v=u.utils.isArray,y=u.utils.isString,g=u.utils.isPalinObject,m=u.utils.execCallback,b=u.helpers.catchErrorsDecorator;e.COMPONENT_NAME="storage";var w=function(t,e,r){return a(void 0,void 0,void 0,(function(){var o,i,a;return s(this,(function(s){switch(s.label){case 0:return[4,t.gateWay({path:"storages",name:"get-objects-upload-info",data:[n({objectId:e.path},e.signedHeader?{signedHeader:e.signedHeader}:{})]},r)];case 1:return o=s.sent(),i=(null===(a=o.data)||void 0===a?void 0:a[0])||{},[2,n(n({},o),{data:n(n({},i.code?n({},i):{}),{authorization:i.authorization,token:i.token,url:i.uploadUrl,fileId:i.cloudObjectId,cosFileId:i.cloudObjectMeta,download_url:i.downloadUrl})})]}}))}))},O=function(t,e,r){return a(void 0,void 0,void 0,(function(){var o,i;return s(this,(function(a){switch(a.label){case 0:return[4,t.gateWay({path:"storages",name:"get-objects-download-info",data:e.convertedFileList.map((function(t){return{cloudObjectId:t.fileid}}))},r)];case 1:return o=a.sent(),[2,n(n({},o),{data:{download_list:null===(i=o.data)||void 0===i?void 0:i.map((function(t){return{code:t.code||"SUCCESS",message:t.message,fileid:t.cloudObjectId,download_url:t.downloadUrl,fileID:t.cloudObjectId,tempFileURL:t.downloadUrl}}))}})]}}))}))},_=function(t,e,r){return a(void 0,void 0,void 0,(function(){var o,i;return s(this,(function(a){switch(a.label){case 0:return[4,t.gateWay({path:"storages",name:"delete-objects",data:e.fileList.map((function(t){return{cloudObjectId:t}}))},r)];case 1:return o=a.sent(),[2,n(n({},o),{data:{delete_list:null===(i=o.data)||void 0===i?void 0:i.map((function(t){return{code:t.code||"SUCCESS",fileID:t.cloudObjectId,message:t.message}}))}})]}}))}))},S=function(t,e,r){return a(void 0,void 0,void 0,(function(){var o,i;return s(this,(function(a){switch(a.label){case 0:return[4,t.gateWay({path:"storages",name:"copy-objects",data:e.convertedFileList.map((function(t){return{srcPath:t.src_path,dstPath:t.dst_path,overwrite:t.overwrite,removeOriginal:t.remove_original}}))},r)];case 1:return o=a.sent(),[2,n(n({},o),{data:{copy_list:null===(i=o.data)||void 0===i?void 0:i.map((function(t){return{code:t.code||"SUCCESS",fileID:t.cloudObjectId,message:t.message}}))}})]}}))}))},E={txt:"text/plain",json:"application/json",html:"text/html",htm:"text/html",css:"text/css",js:"application/javascript",csv:"text/csv",xml:"application/xml",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",pdf:"application/pdf",zip:"application/zip",gz:"application/gzip",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav"};function P(t,e){if("undefined"!=typeof Blob&&t instanceof Blob&&t.type)return t.type;var r=/\.([a-zA-Z0-9]+)$/.exec(e||""),n=r?r[1].toLowerCase():"";return E[n]||"application/octet-stream"}function I(t,e){var r=e.toLowerCase();return Object.keys(t).some((function(t){return t.toLowerCase()===r}))}function j(t){return Object.keys(t).reduce((function(e,r){var o;return n(n({},e),((o={})[r]=[t[r]],o))}),{})}e.CloudbaseStorage=function(){function t(t){this.context=t}var r,u,E,N,C,x,T,A,R,U,k,L,F,M,D,B;return Object.defineProperty(t.prototype,"config",{get:function(){var t;return null===(t=this.context)||void 0===t?void 0:t.config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){var t;return null===(t=this.context)||void 0===t?void 0:t.request},enumerable:!1,configurable:!0}),t.prototype.isGateWay=function(){return"GATEWAY"===(this.config.endPointMode||"CLOUD_API")},t.prototype.uploadFile=function(t,r){return a(this,void 0,Promise,(function(){var o,i,a,u,d,p,v,g,b,w,O,_,S,E,N,C,x,T,A,R,U,k,L,F,M,D,B,q,G,W,V;return s(this,(function(s){switch(s.label){case 0:if(o=t.cloudPath,i=t.filePath,a=t.onUploadProgress,G=t.method,u=void 0===G?"put":G,W=t.headers,d=void 0===W?{}:W,p=t.fileContent,!y(o)||!i&&!p)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".uploadFile] invalid params")}));return v={put:c.put,post:c.post}[u.toLocaleLowerCase()]||c.put,g=this.isGateWay(),b=n({},d),w=Object.keys(d).reduce((function(t,e){return"content-length"!==e.toLowerCase()&&(t[e]=d[e]),t}),{}),v===c.put&&g&&(I(b,"content-length")||(O=function(t,e){var r=null!=t?t:e;if(null!==r){if("undefined"!=typeof Blob&&r instanceof Blob)return r.size;if("undefined"!=typeof ArrayBuffer){if(r instanceof ArrayBuffer)return r.byteLength;if("function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(r))return r.byteLength}if("string"==typeof r){if("undefined"!=typeof Blob)return new Blob([r]).size;var n=(0,l.getStringByteLength)(r);return"number"==typeof n?n:r.length}return"object"==typeof r&&"number"==typeof r.size?r.size:void 0}}(i,p),"number"==typeof O&&(b["content-length"]=String(O))),I(b,"content-type")||(b["content-type"]=P(i,o)),I(w,"content-type")||(w["content-type"]=P(i,o))),[4,this.getUploadMetadata({cloudPath:o,method:v,headers:v!==c.put||g?void 0:w,signedHeader:v===c.put&&g?j(b):void 0,customReqOpts:t.customReqOpts})];case 1:return _=s.sent(),S=_.data,E=_.requestId,(null==(N=S)?void 0:N.code)||!(null==N?void 0:N.url)?(C=(null==N?void 0:N.code)||h.OPERATION_FAIL,x=(null==N?void 0:N.message)||"get upload info failed",[2,m(r,new Error("[".concat(f(),"][").concat(C,"][").concat(e.COMPONENT_NAME,"]:").concat(x)))]):(T=S.url,A=S.authorization,R=S.token,U=S.fileId,k=S.cosFileId,L=S.download_url,M=n(n({},F={url:T,file:i,name:o,onUploadProgress:a,fileContent:p,fileId:U,requestId:E}),{method:c.put,headers:n(n({},w),{authorization:A,"x-cos-meta-fileid":k,"x-cos-security-token":R})}),D=n(n({},F),{method:c.post,data:{key:o,signature:A,"x-cos-meta-fileid":k,success_action_status:"201","x-cos-security-token":R}}),(V={})[c.put]={params:M,isSuccess:function(t){return t>=200&&t<300}},V[c.post]={params:D,isSuccess:function(t){return 201===t}},B=V,[4,this.request.upload(B[v].params)]);case 2:return q=s.sent(),B[v].isSuccess(q.statusCode)?[2,m(r,null,{fileID:U,download_url:L,requestId:E})]:[2,m(r,new Error("[".concat(f(),"][").concat(h.OPERATION_FAIL,"][").concat(e.COMPONENT_NAME,"]:").concat(q.data)))]}}))}))},t.prototype.getUploadMetadata=function(t,r){return a(this,void 0,Promise,(function(){var n,o,i,a,u,l,d,f,p,v;return s(this,(function(s){switch(s.label){case 0:if(n=t.cloudPath,o=t.method,i=t.headers,a=t.signedHeader,!y(n))throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getUploadMetadata] invalid cloudPath")}));u=this.request,l="storage.getUploadMetadata",s.label=1;case 1:return s.trys.push([1,6,,7]),d=void 0,f={path:n},p=this.isGateWay(),o&&(f.method=o),o===c.put&&(p&&a?f.signedHeader=a:!p&&i&&(f.headers=i)),p?[4,w(u,f,t.customReqOpts)]:[3,3];case 2:return d=s.sent(),[3,5];case 3:return[4,u.send(l,f,t.customReqOpts)];case 4:d=s.sent(),s.label=5;case 5:return[2,m(r,null,d)];case 6:return v=s.sent(),[2,m(r,v)];case 7:return[2]}}))}))},t.prototype.deleteFile=function(t,r){return a(this,void 0,Promise,(function(){var n,o,i,a,c,u,l,d;return s(this,(function(s){switch(s.label){case 0:if(!(n=t.fileList)||!v(n)||0===n.length)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".deleteFile] fileList must not be empty")}));for(o=0,i=n;o<i.length;o++)if(!(a=i[o])||!y(a))throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".deleteFile] fileID must be string")}));return c="storage.batchDeleteFile",u=this.request,l={},this.isGateWay()?[4,_(u,{fileList:n},t.customReqOpts)]:[3,2];case 1:return l=s.sent(),[3,4];case 2:return[4,u.send(c,{fileid_list:n},t.customReqOpts)];case 3:l=s.sent(),s.label=4;case 4:return l.code?[2,m(r,null,l)]:(d={fileList:l.data.delete_list,requestId:l.requestId},[2,m(r,null,d)])}}))}))},t.prototype.getTempFileURL=function(t,r){return a(this,void 0,Promise,(function(){var n,o,i,a,c,u,l,d;return s(this,(function(s){switch(s.label){case 0:if(!(n=t.fileList)||!v(n)||0===n.length)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getTempFileURL] fileList must not be empty")}));for(o=[],i=0,a=n;i<a.length;i++)if(c=a[i],g(c)){if(!Object.prototype.hasOwnProperty.call(c,"fileID"))throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getTempFileURL] file info must include fileID")}));o.push({fileid:c.fileID,max_age:c.maxAge||7200})}else{if(!y(c))throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getTempFileURL] invalid fileList")}));o.push({fileid:c})}return u="storage.batchGetDownloadUrl",l=this.request,d={},this.isGateWay()?[4,O(l,{convertedFileList:o},t.customReqOpts)]:[3,2];case 1:return d=s.sent(),[3,4];case 2:return[4,l.send(u,{file_list:o},t.customReqOpts)];case 3:d=s.sent(),s.label=4;case 4:return d.code?[2,m(r,null,d)]:[2,m(r,null,{fileList:d.data.download_list,requestId:d.requestId})]}}))}))},t.prototype.downloadFile=function(t,r){return a(this,void 0,Promise,(function(){var n,o,i,a,c,u;return s(this,(function(s){switch(s.label){case 0:if(n=t.fileID,!y(n))throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}],customReqOpts:t.customReqOpts})];case 1:return o=s.sent(),"SUCCESS"!==(i=o.fileList[0]).code?[2,m(r,i)]:(a=this.request,c=encodeURI(i.download_url),[4,a.download({url:c,tempFilePath:t.tempFilePath})]);case 2:return u=s.sent(),[2,m(r,null,u)]}}))}))},t.prototype.copyFile=function(t,r){return a(this,void 0,Promise,(function(){var n,o,i,a,c,u,l,d,f;return s(this,(function(s){switch(s.label){case 0:if(!(n=t.fileList)||!v(n)||0===n.length)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".copyFile] fileList must not be empty")}));for(o=[],i=0,a=n;i<a.length;i++){if(c=a[i],u=c.srcPath,l=c.dstPath,!u||!l||"string"!=typeof u||"string"!=typeof l)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".copyFile] srcPath and dstPath may not be empty")}));if(u===l)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".copyFile] srcPath and dstPath can not be the same")}));o.push({src_path:u,dst_path:l,overwrite:c.overwrite,remove_original:c.removeOriginal})}return d=this.request,f={},this.isGateWay()?[4,S(d,{convertedFileList:o},t.customReqOpts)]:[3,2];case 1:return f=s.sent(),[3,4];case 2:return[4,d.send("storage.batchCopyFile",{file_list:o},t.customReqOpts)];case 3:f=s.sent(),s.label=4;case 4:return f.code?[2,m(r,null,f)]:[2,m(r,null,{fileList:f.data.copy_list,requestId:f.requestId})]}}))}))},t.prototype.getFileInfo=function(t){var e;return a(this,void 0,Promise,(function(){var r,n=this;return s(this,(function(o){switch(o.label){case 0:return[4,this.getTempFileURL(t)];case 1:return(null==(r=o.sent())?void 0:r.fileList)&&(null===(e=null==r?void 0:r.fileList)||void 0===e?void 0:e.length)>0?[4,Promise.all(r.fileList.map((function(t){return a(n,void 0,void 0,(function(){var e,r,n,o,i,a,c;return s(this,(function(s){switch(s.label){case 0:if("SUCCESS"!==t.code)return[2,{code:t.code,fileID:t.fileID,tempFileURL:t.tempFileURL,message:t.message}];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.request.fetch({url:t.tempFileURL,method:"HEAD"})];case 2:return e=s.sent(),r=e.header,"undefined"!=typeof Headers&&r instanceof Headers&&(n={},r.forEach((function(t,e){n[e]=t})),r=n),o=parseInt(r["content-length"])||0,i=r["content-type"]||"",[400,404].includes(Number(e.statusCode))?[2,{code:"FILE_NOT_FOUND",fileID:t.fileID,tempFileURL:t.tempFileURL,message:"file not found"}]:[2,{code:t.code,fileID:t.fileID,tempFileURL:t.tempFileURL,cloudId:t.fileID,fileName:t.fileID.split("/").pop(),contentType:i,mime:i.split(";")[0].trim(),size:o,etag:r.etag||"",lastModified:r["last-modified"]||"",cacheControl:r["cache-control"]||""}];case 3:return a=s.sent(),c="object"==typeof a&&null!==a&&"message"in a?String(a.message):void 0,[2,{code:"FETCH_FILE_INFO_ERROR",fileID:t.fileID,tempFileURL:t.tempFileURL,message:c}];case 4:return[2]}}))}))})))]:[3,3];case 2:return[2,{fileList:o.sent(),requestId:r.requestId}];case 3:return[2,{fileList:[],requestId:r.requestId}]}}))}))},o([b({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",[Object,"function"==typeof(r="undefined"!=typeof Function&&Function)?r:Object]),i("design:returntype","function"==typeof(u="undefined"!=typeof Promise&&Promise)?u:Object)],t.prototype,"uploadFile",null),o([b({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",[Object,"function"==typeof(E="undefined"!=typeof Function&&Function)?E:Object]),i("design:returntype","function"==typeof(N="undefined"!=typeof Promise&&Promise)?N:Object)],t.prototype,"getUploadMetadata",null),o([b({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(C=void 0!==d.ICloudbaseDeleteFileParams&&d.ICloudbaseDeleteFileParams)?C:Object,"function"==typeof(x="undefined"!=typeof Function&&Function)?x:Object]),i("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],t.prototype,"deleteFile",null),o([b({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(A=void 0!==d.ICloudbaseGetTempFileURLParams&&d.ICloudbaseGetTempFileURLParams)?A:Object,"function"==typeof(R="undefined"!=typeof Function&&Function)?R:Object]),i("design:returntype","function"==typeof(U="undefined"!=typeof Promise&&Promise)?U:Object)],t.prototype,"getTempFileURL",null),o([b({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(k=void 0!==d.ICloudbaseDownloadFileParams&&d.ICloudbaseDownloadFileParams)?k:Object,"function"==typeof(L="undefined"!=typeof Function&&Function)?L:Object]),i("design:returntype","function"==typeof(F="undefined"!=typeof Promise&&Promise)?F:Object)],t.prototype,"downloadFile",null),o([b({customInfo:{className:"Cloudbase",methodName:"copyFile"},title:"批量复制文件",messages:["请确认以下各项:"," 1 - 调用 copyFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(M=void 0!==d.ICloudbaseCopyFileParams&&d.ICloudbaseCopyFileParams)?M:Object,"function"==typeof(D="undefined"!=typeof Function&&Function)?D:Object]),i("design:returntype","function"==typeof(B="undefined"!=typeof Promise&&Promise)?B:Object)],t.prototype,"copyFile",null),t}()},656:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.DownloadBuilder=e.StreamDownloadBuilder=void 0;var a=r(957),s=r(90);function c(t){return(0,a.isStorageError)(t)?t:new a.StorageError((null==t?void 0:t.message)||String(t))}function u(t){var e={};return void 0!==(null==t?void 0:t.download)&&(e.download=!0===t.download?"":t.download),void 0!==(null==t?void 0:t.cacheNonce)&&(e.cacheNonce=String(t.cacheNonce)),{headers:{},query:e}}var l=function(){function t(t){this.ctx=t}return t.prototype.then=function(t,e){return this.execute().then(t,e)},t.prototype.execute=function(){var t,e;return o(this,void 0,Promise,(function(){var r,o,l,d,f;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r=u(this.ctx.options),o=r.headers,l=r.query,[4,this.ctx.http.download({path:"/object/".concat(this.ctx.bucketId,"/").concat((0,s.encodeObjectName)(this.ctx.cleanName)),headers:n(n({},this.ctx.headers),o),query:l,signal:null===(t=this.ctx.parameters)||void 0===t?void 0:t.signal,cache:null===(e=this.ctx.parameters)||void 0===e?void 0:e.cache})];case 1:if(!(d=i.sent().response).body)throw new a.StorageApiError("Response body is empty",d.status,"STORAGE_PG_EMPTY_BODY");return[2,{data:d.body,error:null}];case 2:if(f=i.sent(),this.ctx.shouldThrowOnError)throw f;return[2,{data:null,error:c(f)}];case 3:return[2]}}))}))},t}();e.StreamDownloadBuilder=l;var d=function(){function t(t){this.ctx=t}return t.prototype.asStream=function(){return new l(this.ctx)},t.prototype.then=function(t,e){return this.execute().then(t,e)},t.prototype.execute=function(){var t,e;return o(this,void 0,Promise,(function(){var r,o,a,l,d,f;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),r=u(this.ctx.options),o=r.headers,a=r.query,[4,this.ctx.http.download({path:"/object/".concat(this.ctx.bucketId,"/").concat((0,s.encodeObjectName)(this.ctx.cleanName)),headers:n(n({},this.ctx.headers),o),query:a,signal:null===(t=this.ctx.parameters)||void 0===t?void 0:t.signal,cache:null===(e=this.ctx.parameters)||void 0===e?void 0:e.cache})];case 1:return l=i.sent().response,f={},[4,l.blob()];case 2:return[2,(f.data=i.sent(),f.error=null,f)];case 3:if(d=i.sent(),this.ctx.shouldThrowOnError)throw d;return[2,{data:null,error:c(d)}];case 4:return[2]}}))}))},t}();e.DownloadBuilder=d},90:(t,e)=>{"use strict";function r(){return globalThis.Buffer}Object.defineProperty(e,"__esModule",{value:!0}),e.encodeObjectName=e.toBase64=e.getStringByteLength=void 0,e.getStringByteLength=function(t){var e;return null===(e=r())||void 0===e?void 0:e.byteLength(t)},e.toBase64=function(t){var e=r();return e?e.from(t).toString("base64"):btoa(t)},e.encodeObjectName=function(t){return t.split("/").map((function(t){return encodeURIComponent(t)})).join("/")}},98:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.Http=e.handleOperation=void 0;var a=r(957),s="/v1/storages";e.handleOperation=function(t,e){return o(this,void 0,Promise,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,t()];case 1:return[2,{data:n.sent(),error:null}];case 2:if(r=n.sent(),e)throw r;return(0,a.isStorageError)(r)?[2,{data:null,error:r}]:[2,{data:null,error:new a.StorageError((null==r?void 0:r.message)||String(r))}];case 3:return[2]}}))}))};var c=function(){function t(t){this.ctx=t}return Object.defineProperty(t.prototype,"request",{get:function(){return this.ctx.request},enumerable:!1,configurable:!0}),t.prototype.gatewayOrigin=function(){return this.request.getBaseEndPoint("GATEWAY")},t.prototype.buildUrl=function(t,e){var r="".concat(this.gatewayOrigin()).concat(s).concat(t),n=function(t){if(!t)return"";var e=[];return Object.keys(t).forEach((function(r){var n=t[r];null!=n&&e.push("".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(String(n))))})),e.join("&")}(e);return n&&(r+=(r.includes("?")?"&":"?")+n),r},t.prototype.toFullUrl=function(t){return t?/^https?:\/\//.test(t)||t.startsWith("//")?t:"".concat(this.gatewayOrigin()).concat(s).concat(t.startsWith("/")?"":"/").concat(t):t},t.prototype.send=function(t){return o(this,void 0,Promise,(function(){var e,r,o,a,s,c;return i(this,(function(i){switch(i.label){case 0:return e=this.buildUrl(t.path,t.query),r=t.method.toUpperCase(),o=["GET","HEAD"].includes(r),a=n({},t.headers||{}),o||(void 0!==t.rawBody?s=t.rawBody:void 0!==t.json&&(a["Content-Type"]=a["Content-Type"]||"application/json",s=JSON.stringify(t.json))),[4,this.request.fetch(n(n(n(n({url:e,method:r,headers:a},void 0!==s?{body:s}:{}),{withCredentials:!1!==t.withCredentials,shouldThrowOnError:!1}),t.signal?{signal:t.signal}:{}),t.cache?{cache:t.cache}:{}))];case 1:return c=i.sent(),[2,this.unwrap(c,e)]}}))}))},t.prototype.download=function(t){var e,r;return o(this,void 0,Promise,(function(){var o,s,c,u;return i(this,(function(i){switch(i.label){case 0:return o=this.buildUrl(t.path,t.query),[4,this.request.fetch(n(n({url:o,method:"GET",headers:n({},t.headers||{}),stream:!0,withCredentials:!1!==t.withCredentials,shouldThrowOnError:!1},t.signal?{signal:t.signal}:{}),t.cache?{cache:t.cache}:{}))];case 1:if(s=i.sent(),null===(e=t.signal)||void 0===e?void 0:e.aborted)throw new a.StorageApiError("The download was aborted",0,"STORAGE_PG_ABORTED");if(304===(c=Number(null!==(r=null==s?void 0:s.statusCode)&&void 0!==r?r:200)))throw new a.StorageApiError("Not Modified",c,"STORAGE_PG_NOT_MODIFIED");if(c>=400)throw new a.StorageApiError("Download failed with status ".concat(c),c,"STORAGE_PG_REQUEST_FAIL");if(!(u=null==s?void 0:s.response))throw new a.StorageApiError("Underlying adapter did not expose the raw Response",c,"STORAGE_PG_NO_RESPONSE");return[2,{response:u,status:c,header:null==s?void 0:s.header}]}}))}))},t.prototype.unwrap=function(t,e){var r,n;return o(this,void 0,Promise,(function(){var o,s,c,u;return i(this,(function(i){switch(i.label){case 0:o=Number(null!==(n=null!==(r=null==t?void 0:t.statusCode)&&void 0!==r?r:null==t?void 0:t.status)&&void 0!==n?n:200),s=null==t?void 0:t.data,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,s];case 2:return s=i.sent(),[3,4];case 3:return i.sent(),s=void 0,[3,4];case 4:if(o>=200&&o<300)return[2,s];throw c=(null==s?void 0:s.code)||(null==s?void 0:s.error)||"STORAGE_PG_REQUEST_FAIL",u=(null==s?void 0:s.message)||"Storage request failed with status ".concat(o,": ").concat(e),new a.StorageApiError(u,o,c)}}))}))},t}();e.Http=c},456:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.registerStorage=e.StorageClient=e.StorageFileApi=e.ClassicStorageFileApi=e.CloudbaseStorage=e.COMPONENT_NAME=void 0;var i=r(502),a=r(14),s=r(504),c=r(891),u=r(77),l=r(891);Object.defineProperty(e,"COMPONENT_NAME",{enumerable:!0,get:function(){return l.COMPONENT_NAME}}),Object.defineProperty(e,"CloudbaseStorage",{enumerable:!0,get:function(){return l.CloudbaseStorage}});var d=r(77);Object.defineProperty(e,"ClassicStorageFileApi",{enumerable:!0,get:function(){return d.ClassicStorageFileApi}});var f=r(502);Object.defineProperty(e,"StorageFileApi",{enumerable:!0,get:function(){return f.StorageFileApi}});var h=new c.CloudbaseStorage,p={name:c.COMPONENT_NAME,entity:{uploadFile:h.uploadFile,deleteFile:h.deleteFile,getTempFileURL:h.getTempFileURL,downloadFile:h.downloadFile,getUploadMetadata:h.getUploadMetadata,copyFile:h.copyFile,getFileInfo:h.getFileInfo,isGateWay:h.isGateWay}},v=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.from=function(t){return t?((0,s.assertValidBucketId)(t,"from"),new i.StorageFileApi(this.http,t,this.shouldThrowOnError)):new u.ClassicStorageFileApi(this.http.ctx,this.shouldThrowOnError)},e}(a.StorageBucketApi);e.StorageClient=v;var y={name:"".concat(c.COMPONENT_NAME,"/supabase"),IIFE:!0,entity:function(){var t=new WeakMap;Object.defineProperty(this.prototype,"storage",{get:function(){if(t.has(this))return t.get(this);var e=this,r=new Proxy({},{get:function(t,r){return"config"===r?e.config:"request"===r?e.request:void 0}}),n=new v(r);return t.set(this,n),n},configurable:!0,enumerable:!0})}};try{cloudbase.registerComponent(p),cloudbase.registerComponent(y)}catch(t){}function g(t){try{t.registerComponent(p),t.registerComponent(y)}catch(t){console.warn(t)}}e.registerStorage=g;try{window.registerStorage=g}catch(t){}},14:function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.StorageBucketApi=void 0;var i=r(98),a=r(504),s=function(){function t(t,e){void 0===e&&(e=!1),this.http=new i.Http(t),this.shouldThrowOnError=e}return t.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},t.prototype.listBuckets=function(t){return n(this,void 0,Promise,(function(){var e=this;return o(this,(function(r){return[2,(0,i.handleOperation)((function(){var r={};return void 0!==(null==t?void 0:t.limit)&&(r.limit=t.limit),void 0!==(null==t?void 0:t.offset)&&(r.offset=t.offset),(null==t?void 0:t.sortColumn)&&(r.sortColumn=t.sortColumn),(null==t?void 0:t.sortOrder)&&(r.sortOrder=t.sortOrder),(null==t?void 0:t.search)&&(r.search=t.search),e.http.send({method:"GET",path:"/bucket/",query:r})}),this.shouldThrowOnError)]}))}))},t.prototype.getBucket=function(t){return n(this,void 0,Promise,(function(){var e=this;return o(this,(function(r){return[2,(0,i.handleOperation)((function(){return(0,a.assertValidBucketId)(t,"getBucket"),e.http.send({method:"GET",path:"/bucket/".concat(t)})}),this.shouldThrowOnError)]}))}))},t.prototype.createBucket=function(t,e){return n(this,void 0,Promise,(function(){var r=this;return o(this,(function(n){return[2,(0,i.handleOperation)((function(){var n;return(0,a.assertValidBucketId)(t,"createBucket"),r.http.send({method:"POST",path:"/bucket/",json:{id:t,name:t,public:null!==(n=null==e?void 0:e.public)&&void 0!==n&&n,type:null==e?void 0:e.type,file_size_limit:null==e?void 0:e.fileSizeLimit,allowed_mime_types:null==e?void 0:e.allowedMimeTypes}})}),this.shouldThrowOnError)]}))}))},t.prototype.updateBucket=function(t,e){return n(this,void 0,Promise,(function(){var r=this;return o(this,(function(n){return[2,(0,i.handleOperation)((function(){return(0,a.assertValidBucketId)(t,"updateBucket"),r.http.send({method:"PUT",path:"/bucket/".concat(t),json:{public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes}})}),this.shouldThrowOnError)]}))}))},t.prototype.deleteBucket=function(t){return n(this,void 0,Promise,(function(){var e=this;return o(this,(function(r){return[2,(0,i.handleOperation)((function(){return(0,a.assertValidBucketId)(t,"deleteBucket"),e.http.send({method:"DELETE",path:"/bucket/".concat(t)})}),this.shouldThrowOnError)]}))}))},t}();e.StorageBucketApi=s},77:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.ClassicStorageFileApi=void 0;var a=r(877),s=r(957),c=r(891),u=r(90),l=a.constants.ERRORS,d=function(){function t(t,e){void 0===e&&(e=!1),this.shouldThrowOnError=!1,this.bucketId="",this.context=t,this.shouldThrowOnError=e,this.storage=new c.CloudbaseStorage(t)}return Object.defineProperty(t.prototype,"config",{get:function(){var t;return null===(t=this.context)||void 0===t?void 0:t.config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){var t;return null===(t=this.context)||void 0===t?void 0:t.request},enumerable:!1,configurable:!0}),t.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},t.prototype.upload=function(t,e,r){return o(this,void 0,Promise,(function(){var o,a,u,d,f,h,p,v,y;return i(this,(function(i){switch(i.label){case 0:o=n({upsert:!0},r),a=o.cacheControl,u=o.contentType,d=o.metadata,i.label=1;case 1:return i.trys.push([1,3,,4]),f=this.getCloudPath(t),h={cloudPath:f,filePath:e},(a||u||d)&&(p={},a&&(p["cache-control"]=a),u&&(p["content-type"]=u),d&&(p["x-cos-metadata-metadata"]=this.toBase64(JSON.stringify(d))),h.headers=p),[4,this.storage.uploadFile(h)];case 2:if(!(v=i.sent()).fileID)throw new Error(JSON.stringify({code:l.OPERATION_FAIL,msg:"[".concat(c.COMPONENT_NAME,".update] no fileID returned")}));return[2,{data:{id:v.fileID,path:t,fullPath:t},error:null}];case 3:if(y=i.sent(),this.shouldThrowOnError)throw y;if((0,s.isStorageError)(y))return[2,{data:null,error:y}];throw y;case 4:return[2]}}))}))},t.prototype.uploadToSignedUrl=function(t,e,r,n){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.upload(t,r,n)]}))}))},t.prototype.createSignedUploadUrl=function(t){return o(this,void 0,Promise,(function(){var e,r,n;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),e=this.getCloudPath(t),[4,this.storage.getUploadMetadata({cloudPath:e})];case 1:return[2,{data:{signedUrl:(r=o.sent().data).url,token:r.token,path:t,authorization:r.authorization,id:r.fileId,cosFileId:r.cosFileId,downloadUrl:r.download_url},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;return[2,{data:null,error:n instanceof s.StorageError?n:new s.StorageError(n.message)}];case 3:return[2]}}))}))},t.prototype.update=function(t,e,r){return o(this,void 0,Promise,(function(){return i(this,(function(o){return[2,this.upload(t,e,n(n({},r),{upsert:!0}))]}))}))},t.prototype.move=function(t,e){return o(this,void 0,Promise,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.copyFile({fileList:[{srcPath:this.getCloudPath(t),dstPath:this.getCloudPath(e),overwrite:!0,removeOriginal:!0}]})];case 1:if((r=o.sent()).fileList[0].code&&"SUCCESS"!==r.fileList[0].code)throw new s.StorageError(r.fileList[0].message||"Move failed");return[2,{data:{message:"File moved from ".concat(t," to ").concat(e)},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if((0,s.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.copy=function(t,e){return o(this,void 0,Promise,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.copyFile({fileList:[{srcPath:this.getCloudPath(t),dstPath:this.getCloudPath(e),overwrite:!0,removeOriginal:!1}]})];case 1:if((r=o.sent()).fileList[0].code&&"SUCCESS"!==r.fileList[0].code)throw new s.StorageError(r.fileList[0].message||"Copy failed");return[2,{data:{path:this.getCloudPath(e)},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if((0,s.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.createSignedUrl=function(t,e,r){return o(this,void 0,Promise,(function(){var n,o,a,c,u,l,d;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=this.normalizeCloudId(t),[4,this.storage.getTempFileURL({fileList:[{fileID:n,maxAge:e}]})];case 1:if("SUCCESS"!==(o=i.sent()).fileList[0].code)throw new s.StorageError("Failed to create signed URL: [".concat(o.fileList[0].code,"] ").concat(o.fileList[0].fileID));return a=o.fileList[0].download_url,c=[],void 0!==(null==r?void 0:r.download)&&("string"==typeof r.download?c.push("download=".concat(encodeURIComponent(r.download))):!0===r.download&&c.push("download=true")),(null==r?void 0:r.transform)&&(u=this.transformOptsToQueryString(r.transform))&&c.push(u),c.length>0&&(l=a.includes("?")?"&":"?",a="".concat(a).concat(l).concat(c.join("&"))),[2,{data:{signedUrl:a},error:null}];case 2:if(d=i.sent(),this.shouldThrowOnError)throw d;if((0,s.isStorageError)(d))return[2,{data:null,error:d}];throw d;case 3:return[2]}}))}))},t.prototype.createSignedUrls=function(t,e){return o(this,void 0,Promise,(function(){var r,n,o=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r=t.map((function(t){return{fileID:o.normalizeCloudId(t),maxAge:e}})),[4,this.storage.getTempFileURL({fileList:r})];case 1:return[2,{data:i.sent().fileList.map((function(e,r){return{path:t[r],signedUrl:e.tempFileURL||"",error:"SUCCESS"===e.code?null:e.message}})),error:null}];case 2:if(n=i.sent(),this.shouldThrowOnError)throw n;if((0,s.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.download=function(t,e){return o(this,void 0,Promise,(function(){var r,n,a=this;return i(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),n={},[4,o(a,void 0,void 0,(function(){var r,n,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.createSignedUrl(t,600,{transform:e})];case 1:if((r=i.sent()).error)throw r.error;return n=encodeURI(null===(a=r.data)||void 0===a?void 0:a.signedUrl),[4,this.request.reqClass.get({url:n,headers:{},responseType:"blob"})];case 2:if(!(o=i.sent().data))throw new s.StorageError("Download failed: no file content");return[2,new Blob([o])]}}))}))];case 1:return[2,(n.data=c.sent(),n.error=null,n)];case 2:if(r=c.sent(),this.shouldThrowOnError)throw r;if((0,s.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}}))}))},t.prototype.info=function(t){return o(this,void 0,Promise,(function(){var e,r,n,o,a,c,u,l;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),e=t.startsWith("cloud://"),r=e?this.extractPathFromFileId(t):t,n=e?this.extractBucketFromFileId(t):this.bucketId,[4,this.storage.getFileInfo({fileList:[this.normalizeCloudId(t)]})];case 1:if(o=i.sent(),"SUCCESS"!==(a=o.fileList[0]).code)throw new s.StorageError(a.message);return c=(new Date).toISOString(),u=(a.lastModified?new Date(a.lastModified):new Date).toISOString(),[2,{data:{id:a.fileID,version:"1",name:r,bucketId:n,updatedAt:u,createdAt:u,lastAccessedAt:c,size:a.size,cacheControl:a.cacheControl,contentType:a.contentType,etag:a.etag,lastModified:u,metadata:{}},error:null}];case 2:if(l=i.sent(),this.shouldThrowOnError)throw l;return[2,{data:null,error:l instanceof s.StorageError?l:new s.StorageError(l.message)}];case 3:return[2]}}))}))},t.prototype.exists=function(t){return o(this,void 0,Promise,(function(){var e,r,n;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.getFileInfo({fileList:[this.normalizeCloudId(t)]})];case 1:if(e=o.sent(),"FILE_NOT_FOUND"===(r=e.fileList[0]).code)return[2,{data:!1,error:null}];if("SUCCESS"!==r.code)throw new s.StorageError(r.message);return[2,{data:!0,error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if((0,s.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.getPublicUrl=function(t,e){return o(this,void 0,Promise,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return[4,this.createSignedUrl(t,600,e)];case 1:return(r=n.sent()).data?[2,{data:{publicUrl:r.data.signedUrl}}]:[2,{data:null,error:r.error}]}}))}))},t.prototype.remove=function(t){return o(this,void 0,Promise,(function(){var e,r,n,o,a,c,u,l,d,f,h=this;return i(this,(function(i){switch(i.label){case 0:for(i.trys.push([0,3,,4]),e=10,r=[],n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return[4,Promise.all(r.map((function(t){return Promise.all(t.map((function(t){return h.info(t)})))})))];case 1:return o=i.sent(),a=new Map,o.forEach((function(r,n){r.forEach((function(r,o){r.data&&a.set(t[n*e+o],r.data)}))})),c=t.map((function(t){return h.normalizeCloudId(t)})),[4,this.storage.deleteFile({fileList:c})];case 2:if(u=i.sent(),(l=u.fileList.filter((function(t){return"SUCCESS"!==t.code}))).length>0)throw new s.StorageError("Delete failed for ".concat(l.length," file(s)"));return d=(new Date).toISOString(),[2,{data:t.map((function(t){var e=a.get(t);return{name:null==e?void 0:e.name,id:null==e?void 0:e.id,bucket_id:null==e?void 0:e.bucketId,owner:void 0,updated_at:(null==e?void 0:e.updatedAt)||d,created_at:null==e?void 0:e.createdAt,last_accessed_at:(null==e?void 0:e.lastAccessedAt)||d,metadata:(null==e?void 0:e.metadata)||{},buckets:{id:null==e?void 0:e.bucketId,name:null==e?void 0:e.bucketId,owner:void 0,public:!1,created_at:"",updated_at:d}}})),error:null}];case 3:if(f=i.sent(),this.shouldThrowOnError)throw f;if((0,s.isStorageError)(f))return[2,{data:null,error:f}];throw f;case 4:return[2]}}))}))},t.prototype.list=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){throw new s.StorageError("Not implemented")}))}))},t.prototype.getCloudPath=function(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")},t.prototype.normalizeCloudId=function(t){var e;if(/^cloud:\/\//.test(t))return t;var r=this.getCloudPath(t);if(!this.bucketId)throw new s.StorageError("bucketId is not set");var n=(null===(e=this.config)||void 0===e?void 0:e.env)||"";return n?"cloud://".concat(n,".").concat(this.bucketId,"/").concat(r):void 0},t.prototype.toBase64=function(t){return(0,u.toBase64)(t)},t.prototype.transformOptsToQueryString=function(t){var e=["imageMogr2"];if(t.width||t.height){var r=t.width||"",n=t.height||"";"fill"===t.resize?e.push("thumbnail/".concat(r,"x").concat(n,"!")):"contain"===t.resize?e.push("thumbnail/".concat(r,"x").concat(n)):e.push("thumbnail/".concat(r,"x").concat(n,"^"))}if(t.format&&"origin"!==t.format&&e.push("format/".concat(t.format)),void 0!==t.quality){var o=Math.max(1,Math.min(100,t.quality));e.push("quality/".concat(o))}return e.join("/")},t.prototype.extractPathFromFileId=function(t){var e=t.replace(/^cloud:\/\//,"").split("/");return e.length<2?t:e.slice(1).join("/")},t.prototype.extractBucketFromFileId=function(t){var e=t.replace(/^cloud:\/\//,"").split("/");if(e.length<1)return"";var r=e[0],n=r.indexOf(".");return-1===n?r:r.substring(n+1)},t}();e.ClassicStorageFileApi=d},502:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.StorageFileApi=void 0;var a=r(957),s=r(90),c=r(98),u=r(656),l="3600",d=function(){function t(t,e,r){void 0===r&&(r=!1),this.headers={},this.http=t,this.bucketId=e,this.shouldThrowOnError=r}return t.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},t.prototype.setHeader=function(t,e){var r;if("string"!=typeof t||""===t.trim())throw new a.StorageError("setHeader requires a non-empty header name");if(/[\r\n]/.test(t)||"string"==typeof e&&/[\r\n]/.test(e))throw new a.StorageError("setHeader does not allow CR/LF characters in header name or value");return this.headers=n(n({},this.headers),((r={})[t]=String(e),r)),this},t.prototype.upload=function(t,e,r){return o(this,void 0,Promise,(function(){return i(this,(function(n){return[2,this.uploadOrUpdate("POST",t,e,r)]}))}))},t.prototype.update=function(t,e,r){return o(this,void 0,Promise,(function(){return i(this,(function(n){return[2,this.uploadOrUpdate("PUT",t,e,r)]}))}))},t.prototype.download=function(t,e,r){return new u.DownloadBuilder({http:this.http,bucketId:this.bucketId,cleanName:this.cleanPath(t),options:e,parameters:r,headers:this.headers,shouldThrowOnError:this.shouldThrowOnError})},t.prototype.list=function(t,e,r){return o(this,void 0,Promise,(function(){var n=this;return i(this,(function(a){return[2,(0,c.handleOperation)((function(){return o(n,void 0,void 0,(function(){var n;return i(this,(function(o){return n={prefix:t||""},void 0!==(null==e?void 0:e.limit)&&(n.limit=e.limit),void 0!==(null==e?void 0:e.cursor)&&(n.cursor=e.cursor),void 0!==(null==e?void 0:e.withDelimiter)&&(n.with_delimiter=e.withDelimiter),void 0!==(null==e?void 0:e.sortBy)&&(n.sortBy=e.sortBy),[2,this.send({method:"POST",path:"/object/list/".concat(this.bucketId),json:n,signal:null==r?void 0:r.signal,cache:null==r?void 0:r.cache})]}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.remove=function(t){return o(this,void 0,Promise,(function(){var e=this;return i(this,(function(r){return[2,(0,c.handleOperation)((function(){return o(e,void 0,void 0,(function(){var e,r,n,o,a,s=this;return i(this,(function(i){switch(i.label){case 0:e=t.map((function(t){return s.cleanPath(t)})),r=[],n=0,i.label=1;case 1:return n<e.length?(o=e.slice(n,n+100),[4,this.send({method:"DELETE",path:"/object/".concat(this.bucketId),json:{prefixes:o}})]):[3,4];case 2:a=i.sent(),Array.isArray(a)&&r.push.apply(r,a),i.label=3;case 3:return n+=100,[3,1];case 4:return[2,r]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.copy=function(t,e,r){return o(this,void 0,Promise,(function(){var n=this;return i(this,(function(a){return[2,(0,c.handleOperation)((function(){return o(n,void 0,void 0,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return n=this.buildCopyMoveHeaders(r),[4,this.send({method:"POST",path:"/object/copy",json:{bucketId:this.bucketId,sourceKey:this.cleanPath(t),destinationKey:this.cleanPath(e),destinationBucket:null==r?void 0:r.destinationBucket,copyMetadata:null==r?void 0:r.copyMetadata,metadata:null==r?void 0:r.metadata},headers:n})];case 1:return[2,{path:o.sent().Key}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.move=function(t,e,r){return o(this,void 0,Promise,(function(){var n=this;return i(this,(function(a){return[2,(0,c.handleOperation)((function(){return o(n,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.send({method:"POST",path:"/object/move",json:{bucketId:this.bucketId,sourceKey:this.cleanPath(t),destinationKey:this.cleanPath(e),destinationBucket:null==r?void 0:r.destinationBucket}})];case 1:return[2,{message:n.sent().message||"Successfully moved"}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.info=function(t){return o(this,void 0,Promise,(function(){var e=this;return i(this,(function(r){return[2,(0,c.handleOperation)((function(){return o(e,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return e=this.cleanPath(t),[4,this.send({method:"GET",path:"/object/info/".concat(this.bucketId,"/").concat(this.encodePath(e))})];case 1:return[2,{id:(r=n.sent()).id,name:r.name,version:r.version,bucketId:r.bucket_id,size:r.size,contentType:r.content_type,cacheControl:r.cache_control,etag:r.etag,metadata:r.metadata,lastModified:r.last_modified,createdAt:r.created_at}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.exists=function(t){return o(this,void 0,Promise,(function(){var e,r,n;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),e=this.cleanPath(t),[4,this.send({method:"GET",path:"/object/info/".concat(this.bucketId,"/").concat(this.encodePath(e))})];case 1:return o.sent(),[2,{data:!0,error:null}];case 2:if(r=o.sent(),void 0!==(n=null==r?void 0:r.status)&&[400,404].includes(Number(n)))return[2,{data:!1,error:null}];if(this.shouldThrowOnError)throw r;return[2,{data:null,error:r instanceof a.StorageError?r:new a.StorageError((null==r?void 0:r.message)||String(r))}];case 3:return[2]}}))}))},t.prototype.createSignedUrl=function(t,e,r){return o(this,void 0,Promise,(function(){var n=this;return i(this,(function(a){return[2,(0,c.handleOperation)((function(){return o(n,void 0,void 0,(function(){var n,o,a;return i(this,(function(i){switch(i.label){case 0:return n=this.cleanPath(t),[4,this.send({method:"POST",path:"/object/sign/".concat(this.bucketId,"/").concat(this.encodePath(n)),json:{expiresIn:e}})];case 1:return o=i.sent(),a=o.fullSignedURL||this.http.toFullUrl(o.signedURL||""),[2,{fullSignedURL:this.appendUrlOptions(a,r)}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.createSignedUrls=function(t,e,r){return o(this,void 0,Promise,(function(){var n=this;return i(this,(function(a){return[2,(0,c.handleOperation)((function(){return o(n,void 0,void 0,(function(){var n,o,a,s,c=this;return i(this,(function(i){switch(i.label){case 0:n=t.map((function(t){return c.cleanPath(t)})),o=[],a=0,i.label=1;case 1:return a<n.length?(s=n.slice(a,a+500),[4,this.send({method:"POST",path:"/object/sign/".concat(this.bucketId),json:{expiresIn:e,paths:s}})]):[3,4];case 2:i.sent().forEach((function(t){var e,n=t.fullSignedURL||(t.signedURL?c.http.toFullUrl(t.signedURL):null);o.push({path:t.path,fullSignedURL:n?c.appendUrlOptions(n,r):null,error:null!==(e=t.error)&&void 0!==e?e:null})})),i.label=3;case 3:return a+=500,[3,1];case 4:return[2,o]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.createSignedUploadUrl=function(t,e){return o(this,void 0,Promise,(function(){var r=this;return i(this,(function(n){return[2,(0,c.handleOperation)((function(){return o(r,void 0,void 0,(function(){var r,n,o;return i(this,(function(i){switch(i.label){case 0:return r=this.cleanPath(t),n={},(null==e?void 0:e.upsert)&&(n["x-upsert"]="true"),[4,this.send({method:"POST",path:"/object/upload/sign/".concat(this.bucketId,"/").concat(this.encodePath(r)),headers:n})];case 1:return[2,{fullSignedURL:(o=i.sent()).fullURL||this.http.toFullUrl(o.url||""),path:r,token:o.token}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.uploadToSignedUrl=function(t,e,r,n){return o(this,void 0,Promise,(function(){var a=this;return i(this,(function(s){return[2,(0,c.handleOperation)((function(){return o(a,void 0,void 0,(function(){var o,a,s,c,u;return i(this,(function(i){switch(i.label){case 0:return o=this.cleanPath(t),a=this.buildUploadBody(r,n),s=a.body,c=a.headers,[4,this.send({method:"PUT",path:"/object/upload/sign/".concat(this.bucketId,"/").concat(this.encodePath(o)),query:{token:e},rawBody:s,headers:c,withCredentials:!1})];case 1:return u=i.sent(),[2,{path:o,fullPath:u.Key}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.getPublicUrl=function(t,e){var r=this.cleanPath(t),n=this.http.buildUrl("/object/public/".concat(this.bucketId,"/").concat(this.encodePath(r)));return{data:{publicUrl:this.appendUrlOptions(n,e)}}},t.prototype.send=function(t){return this.http.send(n(n({},t),{headers:n(n({},this.headers),t.headers||{})}))},t.prototype.uploadOrUpdate=function(t,e,r,n){return o(this,void 0,Promise,(function(){var a=this;return i(this,(function(s){return[2,(0,c.handleOperation)((function(){return o(a,void 0,void 0,(function(){var o,a,s,c,u;return i(this,(function(i){switch(i.label){case 0:return o=this.cleanPath(e),a=this.buildUploadBody(r,n),s=a.body,c=a.headers,"POST"===t&&(c["x-upsert"]=String(Boolean(null==n?void 0:n.upsert))),[4,this.send({method:t,path:"/object/".concat(this.bucketId,"/").concat(this.encodePath(o)),rawBody:s,headers:c})];case 1:return[2,{id:(u=i.sent()).Id,path:o,fullPath:u.Key}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.cleanPath=function(t){var e=t.replace(/^\/+|\/+$/g,"").replace(/\/+/g,"/");if(e.split("/").some((function(t){return".."===t})))throw new a.StorageError('invalid path: ".." segment is not allowed');return e},t.prototype.encodePath=function(t){return(0,s.encodeObjectName)(t)},t.prototype.buildUploadBody=function(t,e){var r,o,i,a,s,c=n({},(null==e?void 0:e.headers)||{}),u=t,d="undefined"!=typeof FormData&&t instanceof FormData;if("undefined"!=typeof Blob&&t instanceof Blob||d){var f=void 0,h={};if(d){var p=this.extractFromFormData(t);f=p.file,h=p.fields}else f=t;var v=null!==(o=null!==(r=null==e?void 0:e.cacheControl)&&void 0!==r?r:h.cacheControl)&&void 0!==o?o:l,y=null!==(i=null==e?void 0:e.contentType)&&void 0!==i?i:h.contentType,g=void 0!==(null==e?void 0:e.metadata)?JSON.stringify(e.metadata):h.metadata,m=new FormData;void 0!==v&&m.append("cacheControl",String(v)),void 0!==y&&m.append("contentType",y),void 0!==g&&m.append("metadata",g),m.append("",f),u=m}else u=t,v=null!==(a=null==e?void 0:e.cacheControl)&&void 0!==a?a:l,y=null!==(s=null==e?void 0:e.contentType)&&void 0!==s?s:"text/plain;charset=UTF-8",c["cache-control"]="max-age=".concat(v),y&&(c["content-type"]=y),(null==e?void 0:e.metadata)&&(c["x-metadata"]=this.toBase64(JSON.stringify(e.metadata)));return{body:u,headers:c}},t.prototype.extractFromFormData=function(t){var e,r={},n=0,o=[];if(t.forEach((function(t,i){if("undefined"!=typeof Blob&&t instanceof Blob)return e=t,void(n+=1);"cacheControl"!==i&&"contentType"!==i&&"metadata"!==i?o.push(i):r[i]=String(t)})),o.length>0&&console.warn("Ignored unsupported FormData field(s): [".concat(o.join(", "),"]. Only file, cacheControl, contentType and metadata are supported")),0===n||!e)throw new a.StorageError("FormData must contain a file");if(n>1)throw new a.StorageError("FormData must contain exactly one file");return{file:e,fields:r}},t.prototype.buildCopyMoveHeaders=function(t){var e={};return(null==t?void 0:t.upsert)&&(e["x-upsert"]="true"),!1===(null==t?void 0:t.copyMetadata)&&(null==t?void 0:t.metadata)&&(e["x-metadata"]=this.toBase64(JSON.stringify(t.metadata))),e},t.prototype.appendUrlOptions=function(t,e){var r=[];if(void 0!==(null==e?void 0:e.download)){var n=!0===e.download?"":String(e.download);r.push("download=".concat(encodeURIComponent(n)))}if(void 0!==(null==e?void 0:e.cacheNonce)&&r.push("cacheNonce=".concat(encodeURIComponent(String(e.cacheNonce)))),0===r.length)return t;var o=t.includes("?")?"&":"?";return"".concat(t).concat(o).concat(r.join("&"))},t.prototype.toBase64=function(t){return(0,s.toBase64)(t)},t}();e.StorageFileApi=d},957:function(t,e){"use strict";var r,n=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.StorageUnknownError=e.StorageApiError=e.isStorageError=e.StorageError=void 0;var o=function(t){function e(e){var r=t.call(this,e)||this;return r.__isStorageError=!0,r.name="StorageError",r}return n(e,t),e}(Error);e.StorageError=o,e.isStorageError=function(t){return"object"==typeof t&&null!==t&&"__isStorageError"in t};var i=function(t){function e(e,r,n){var o=t.call(this,e)||this;return o.name="StorageApiError",o.status=r,o.statusCode=n,o}return n(e,t),e.prototype.toJSON=function(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}},e}(o);e.StorageApiError=i;var a=function(t){function e(e,r){var n=t.call(this,e)||this;return n.name="StorageUnknownError",n.originalError=r,n}return n(e,t),e}(o);e.StorageUnknownError=a},504:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assertValidBucketId=e.isValidBucketId=void 0;var n=r(957),o=/[\x00-\x20\x7f/\\?#%]/;e.isValidBucketId=function(t){return"string"==typeof t&&t.length>0&&t.length<=256&&!o.test(t)},e.assertValidBucketId=function(t,e){if("string"!=typeof t||0===t.length)throw new n.StorageError("[storage.".concat(e,"] bucketId is required"));if(t.length>256)throw new n.StorageError("[storage.".concat(e,"] invalid bucketId: length must be 1-").concat(256));var r=o.exec(t);if(r){var i="[storage.".concat(e,'] invalid bucketId "').concat(t,'": ')+"contains forbidden character ".concat(JSON.stringify(r[0]),"; ")+'must not contain whitespace, control chars, "/", "\\", "?", "#" or "%"';throw new n.StorageError(i)}}},563:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&o(e,t,r);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var s,c=a(r(92)),u=r(962);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(s=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var r=0,o=(0,u.isArray)(t)?t:[t];r<o.length;r++){var i=o[r],a=i.isMatch,s=i.genAdapter,c=i.runtime;if(a())return{adapter:n({isMatch:a},s(e)),runtime:c}}},e.useDefaultAdapter=function(){return{adapter:n({},c.genAdapter()),runtime:s.WEB}}},92:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},a=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var c=r(829),u=r(962),l=r(464),d=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(e,t),e.prototype.get=function(t){return this.request(i(i({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(i(i({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,o=t.method,a=t.headers,s=void 0===a?{}:a,c={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===c?(Object.keys(e).forEach((function(t){u.append(t,e[t])})),u.append("key",n),u.append("file",r),this.request(i(i({},t),{data:u,method:c}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return a(this,void 0,Promise,(function(){var e,r,n,o;return s(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=a.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.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 a.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;return a(this,void 0,Promise,(function(){var r,n,o,c,u,l,d,f,h,p,v,y,g,m=this;return s(this,(function(b){switch(b.label){case 0:return r=new AbortController,n=t.url,o=t.enableAbort,c=void 0!==o&&o,u=t.stream,l=void 0!==u&&u,d=t.signal,f=t.timeout,h=t.shouldThrowOnError,p=void 0===h||h,v=null!=f?f:this.timeout,d&&(d.aborted&&r.abort(),d.addEventListener("abort",(function(){return r.abort()}))),y=null,c&&v&&(y=setTimeout((function(){console.warn(m.timeoutMsg),r.abort(new Error(m.timeoutMsg))}),v)),[4,fetch(n,i(i({},t),{signal:r.signal})).then((function(t){return a(m,void 0,void 0,(function(){var e,r,n;return s(this,(function(o){switch(o.label){case 0:return clearTimeout(y),p?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,e];case 4:return[2,t]}}))}))})).catch((function(t){return clearTimeout(y),Promise.reject(t)}))];case 1:return g=b.sent(),[2,{data:l?g.body:(null===(e=g.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?g.json():g.text(),statusCode:g.status,header:g.headers,response:g}]}}))}))},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i=t.url,a=t.headers,s=void 0===a?{}:a,c=t.data,d=t.responseType,f=t.withCredentials,h=t.body,p=t.onUploadProgress,v=(0,u.formatUrl)((0,l.getProtocol)(),i,"get"===n?c:{}),y=new XMLHttpRequest;y.open(n,v),d&&(y.responseType=d);var g,m,b=t.signal;b&&(b.aborted?y.abort():b.addEventListener("abort",(function(){return y.abort()}),{once:!0})),Object.keys(s).forEach((function(t){y.setRequestHeader(t,s[t])})),p&&y.upload.addEventListener("progress",p),y.onreadystatechange=function(){var t={};if(4===y.readyState){var e=y.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o})),t.header=r,t.statusCode=y.status;try{t.data="blob"===d?y.response:JSON.parse(y.responseText)}catch(e){t.data="blob"===d?y.response:y.responseText}clearTimeout(g),o(t)}},e&&r.timeout&&(g=setTimeout((function(){console.warn(r.timeoutMsg),y.abort()}),r.timeout)),m=(0,u.isFormData)(c)?c:"application/x-www-form-urlencoded"===s["content-type"]?(0,u.toQueryString)(c):h||(c?JSON.stringify(c):void 0),f&&(y.withCredentials=!0),y.send(m)}))},e}(c.AbstractSDKRequest);e.WebRequest=d,e.genAdapter=function(){return{type:"default",root:window,reqClass:d,wsClass:WebSocket,localStorage}}},464:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var n="https:";e.setProtocol=function(t){n=t},e.getProtocol=function(){return n},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},519:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},778:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(r(464),e),o(r(519),e),e.OATUH_LOGINTYPE="constants"},517:function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=r(962),a=r(778),s=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(s=-1!==navigator.userAgent.indexOf("Firefox"));var c=s?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var i,a=e.stack.split("\n"),c=s?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),l=s?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),d=a.findIndex((function(t){return c.test(t)}));if(-1!==d){var f=a.filter((function(t,e){return e>d}));f.unshift(a[d].replace(l,"".concat(r,".").concat(n)).replace(u,o)),(i=new Error).stack="".concat(s?"@debugger":"Error","\n").concat(f.join("\n"))}return i}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,s=t.customInfo,d=void 0===s?{}:s,f=t.title,h=t.messages,p=void 0===h?[]:h;return function(t,e,s){if(a.IS_DEBUG_MODE){var h=d.className||t.constructor.name,v=d.methodName||e,y=s.value,g=function(){var t="",e=(new Error).stack.split("\n"),r=e.findIndex((function(t){return c.test(t)}));if(-1!==r){var n=u.exec(e[r+1]||"");t=n?n[0]:""}return t}();s.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=l({err:new Error,className:h,methodName:v,sourceLink:g});try{return y.apply(this,t)}catch(t){var n=t,o=t.message,a=t.error,s=t.error_description,c={title:f||"".concat(h,".").concat(v," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);c.subtitle=o,u.code&&(r?(r.code=u.code,r.msg=u.msg):(t.code=u.code,t.message=u.msg),n=r||t,c.content=p.map((function(t){return{type:"info",body:t}})))}throw a&&s&&(c.subtitle=s,r?(r.code=a,r.msg=s):(t.code=a,t.message=s),n=r||t,c.content=p.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(c),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this,void 0,void 0,(function(){var e,r,n,a,s,c,u,d;return o(this,(function(o){switch(o.label){case 0:e=l({err:new Error,className:h,methodName:v,sourceLink:g}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,t)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,a=r.message,s=r.error,c=r.error_description,u={title:f||"".concat(h,".").concat(v," failed"),content:[{type:"error",body:r}]},a&&/^\{.*\}$/.test(a)&&(d=JSON.parse(a),u.subtitle=d,d.code&&(e?(e.code=d.code,e.message=d.msg):(r.code=d.code,r.message=d.msg),n=e||r,u.content=p.map((function(t){return{type:"info",body:t}})))),s&&c&&(u.subtitle=c,e?(e.code=s,e.msg=c):(r.code=s,r.message=c),n=e||r,u.content=p.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(u),n;case 4:return[2]}}))}))}}}}},260:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(517),e)},877:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&n(e,t,r);return o(e,t),e},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.langEvent=e.AbortController=e.jwt=e.helpers=e.utils=e.events=e.cache=e.adapters=e.constants=void 0;var s=i(r(778));e.constants=s;var c=i(r(563));e.adapters=c;var u=i(r(865));e.cache=u;var l=i(r(940));e.events=l;var d=i(r(991));e.langEvent=d;var f=i(r(962));e.utils=f;var h=i(r(260));e.helpers=h;var p=a(r(644));e.AbortController=p.default;var v={decode:a(r(949)).default};e.jwt=v},644:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){var t=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(e,r){"abort"===e&&t.listeners.push(r)}}}return t.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach((function(t){return t()})))},t}();e.default=r},865:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var s=r(829),c=r(962),u=r(778),l=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return o(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(s.AbstractStorage),d=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(e.root));case"none":return new l(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,r){return i(this,void 0,void 0,(function(){var n;return a(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:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={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(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var r;return i(this,void 0,void 0,(function(){var n;return a(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(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=o.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return i(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}();e.CloudbaseCache=d},940:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var a=r(962),s=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=s;var c=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return o(e,t),e}(s);e.IErrorEvent=c;var u=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,a.isInstanceOf)(t,c))return console.error(t.error),this;var r=(0,a.isString)(t)?new s(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,u=this.listeners[n]?i([],this.listeners[n],!0):[];o<u.length;o++)u[o].call(this,r)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=u;var l=new u;e.addEventListener=function(t,e){l.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),l.fire(t,e)},e.removeEventListener=function(t,e){l.off(t,e)}},991:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LANG_CHANGE_EVENT=e.bus=void 0;var n=r(940);e.bus=new n.CloudbaseEventEmitter,e.LANG_CHANGE_EVENT="lang_change"},962:function(t,e,r){"use strict";var n=this&&this.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r};Object.defineProperty(e,"__esModule",{value:!0}),e.parseCaptcha=e.parseQueryString=e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.formatUrl=e.generateRequestId=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var o=r(778);e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.generateRequestId=function(){var t=(new Date).getTime(),e=(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 t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"===r?n:7&n|8).toString(16)}))},e.formatUrl=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";return Object.keys(r).forEach((function(t){""===o?!n&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(r[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var r=e||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""},e.removeParam=function(t,e){var r=e.split("?")[0],n=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===t&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},e.createPromiseCallback=function(){var t={};if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,t},e.execCallback=function(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r},e.printWarn=function(t,e){console.warn("[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e,r=t.title,n=t.subtitle,o=void 0===n?"":n,i=t.content,a=void 0===i?[]:i,s=t.printTrace,c=void 0!==s&&s,u=t.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,d=a;l<d.length;l++){var f=d[l],h=f.type,p=f.body;switch(h){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}c&&(console.trace||console.log)("stack trace:"),null===(e=console.groupEnd)||void 0===e||e.call(console)},e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86".concat(t)},e.parseQueryString=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach((function(t){var r=t.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(e[n]?Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]:e[n]=o)})),e},e.parseCaptcha=function(t){var r={},o=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){t=o[1];var i=o[2];i&&(r=(0,e.parseQueryString)(i))}var a=r.token,s=n(r,["token"]);return/^data:/.test(t)&&!a?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:a?{state:s.state,token:a,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}},388:t=>{t.exports={}},949:(t,e,r)=>{"use strict";function n(t){this.message=t}r.r(e),r.d(e,{InvalidTokenError:()=>a,default:()=>s}),n.prototype=new Error,n.prototype.name="InvalidCharacterError";var o="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,o,i=0,a=0,s="";o=e.charAt(a++);~o&&(r=i%4?64*r+o:o,i++%4)?s+=String.fromCharCode(255&r>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function i(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(o(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return o(e)}}function a(t){this.message=t}a.prototype=new Error,a.prototype.name="InvalidTokenError";const s=function(t,e){if("string"!=typeof t)throw new a("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(i(t.split(".")[r]))}catch(t){throw new a("Invalid token specified: "+t.message)}}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";var t=n;Object.defineProperty(t,"__esModule",{value:!0}),t.registerStorage=void 0;var e=r(456);t.registerStorage=e.registerStorage})(),n})()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/js-sdk",
|
|
3
|
-
"version": "3.7.1",
|
|
3
|
+
"version": "3.7.2-cbf.1",
|
|
4
4
|
"description": "cloudbase javascript sdk",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -173,5 +173,5 @@
|
|
|
173
173
|
"> 1%",
|
|
174
174
|
"chrome 53"
|
|
175
175
|
],
|
|
176
|
-
"gitHead": "
|
|
176
|
+
"gitHead": "859557576897d4778857c12fb8d7fe8ca1f3a052"
|
|
177
177
|
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { CloudbaseAdapter, SDKAdapterInterface, NodeAdapterInterface } from '@cloudbase/adapter-interface';
|
|
2
|
-
export declare enum RUNTIME {
|
|
3
|
-
WEB = "web",
|
|
4
|
-
WX_MP = "wx_mp"
|
|
5
|
-
}
|
|
6
|
-
type ICloudbaseAdapter = CloudbaseAdapter & {
|
|
7
|
-
genAdapter: (options?: any) => SDKAdapterInterface | NodeAdapterInterface;
|
|
8
|
-
};
|
|
9
|
-
export declare function useAdapters(adapters: ICloudbaseAdapter | ICloudbaseAdapter[], options?: any): {
|
|
10
|
-
adapter: {
|
|
11
|
-
root: any;
|
|
12
|
-
wsClass: import("@cloudbase/adapter-interface").WebSocketContructor;
|
|
13
|
-
reqClass: import("@cloudbase/adapter-interface").SDKRequestConstructor;
|
|
14
|
-
localStorage?: import("@cloudbase/adapter-interface").StorageInterface;
|
|
15
|
-
sessionStorage?: import("@cloudbase/adapter-interface").StorageInterface;
|
|
16
|
-
primaryStorage?: import("@cloudbase/adapter-interface").StorageType;
|
|
17
|
-
captchaOptions?: {
|
|
18
|
-
openURIWithCallback?: (url: string) => Promise<import("@cloudbase/adapter-interface").CaptchaToken>;
|
|
19
|
-
};
|
|
20
|
-
getAppSign?(): string;
|
|
21
|
-
isMatch: () => boolean;
|
|
22
|
-
} | {
|
|
23
|
-
wsClass: import("@cloudbase/adapter-interface").WebSocketContructor;
|
|
24
|
-
reqClass: import("@cloudbase/adapter-interface").NodeRequestConstructor;
|
|
25
|
-
isMatch: () => boolean;
|
|
26
|
-
};
|
|
27
|
-
runtime: string;
|
|
28
|
-
};
|
|
29
|
-
export declare function useDefaultAdapter(): {
|
|
30
|
-
adapter: {
|
|
31
|
-
root: any;
|
|
32
|
-
wsClass: import("@cloudbase/adapter-interface").WebSocketContructor;
|
|
33
|
-
reqClass: import("@cloudbase/adapter-interface").SDKRequestConstructor;
|
|
34
|
-
localStorage?: import("@cloudbase/adapter-interface").StorageInterface;
|
|
35
|
-
sessionStorage?: import("@cloudbase/adapter-interface").StorageInterface;
|
|
36
|
-
primaryStorage?: import("@cloudbase/adapter-interface").StorageType;
|
|
37
|
-
captchaOptions?: {
|
|
38
|
-
openURIWithCallback?: (url: string) => Promise<import("@cloudbase/adapter-interface").CaptchaToken>;
|
|
39
|
-
};
|
|
40
|
-
getAppSign?(): string;
|
|
41
|
-
type?: "" | "default";
|
|
42
|
-
};
|
|
43
|
-
runtime: RUNTIME;
|
|
44
|
-
};
|
|
45
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.useDefaultAdapter = exports.useAdapters = exports.RUNTIME = void 0;
|
|
38
|
-
var Web = __importStar(require("./platforms/web"));
|
|
39
|
-
var util_1 = require("../libs/util");
|
|
40
|
-
var RUNTIME;
|
|
41
|
-
(function (RUNTIME) {
|
|
42
|
-
RUNTIME["WEB"] = "web";
|
|
43
|
-
RUNTIME["WX_MP"] = "wx_mp";
|
|
44
|
-
})(RUNTIME = exports.RUNTIME || (exports.RUNTIME = {}));
|
|
45
|
-
function useAdapters(adapters, options) {
|
|
46
|
-
var adapterList = (0, util_1.isArray)(adapters)
|
|
47
|
-
? adapters
|
|
48
|
-
: [adapters];
|
|
49
|
-
for (var _i = 0, adapterList_1 = adapterList; _i < adapterList_1.length; _i++) {
|
|
50
|
-
var adapter = adapterList_1[_i];
|
|
51
|
-
var isMatch = adapter.isMatch, genAdapter = adapter.genAdapter, runtime = adapter.runtime;
|
|
52
|
-
if (isMatch()) {
|
|
53
|
-
return {
|
|
54
|
-
adapter: __assign({ isMatch: isMatch }, genAdapter(options)),
|
|
55
|
-
runtime: runtime,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.useAdapters = useAdapters;
|
|
61
|
-
function useDefaultAdapter() {
|
|
62
|
-
return {
|
|
63
|
-
adapter: __assign({}, Web.genAdapter()),
|
|
64
|
-
runtime: RUNTIME.WEB,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
exports.useDefaultAdapter = useDefaultAdapter;
|
|
68
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYWRhcHRlcnMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUNBLG1EQUFzQztBQUN0QyxxQ0FBc0M7QUFFdEMsSUFBWSxPQUdYO0FBSEQsV0FBWSxPQUFPO0lBQ2pCLHNCQUFXLENBQUE7SUFDWCwwQkFBZSxDQUFBO0FBQ2pCLENBQUMsRUFIVyxPQUFPLEdBQVAsZUFBTyxLQUFQLGVBQU8sUUFHbEI7QUFNRCxTQUFnQixXQUFXLENBQUMsUUFBaUQsRUFBRSxPQUFhO0lBQzFGLElBQU0sV0FBVyxHQUF3QixJQUFBLGNBQU8sRUFBQyxRQUFRLENBQUM7UUFDeEQsQ0FBQyxDQUFFLFFBQWdDO1FBQ25DLENBQUMsQ0FBQyxDQUFDLFFBQTZCLENBQUMsQ0FBQTtJQUNuQyxLQUFzQixVQUFXLEVBQVgsMkJBQVcsRUFBWCx5QkFBVyxFQUFYLElBQVcsRUFBRTtRQUE5QixJQUFNLE9BQU8sb0JBQUE7UUFDUixJQUFBLE9BQU8sR0FBMEIsT0FBTyxRQUFqQyxFQUFFLFVBQVUsR0FBYyxPQUFPLFdBQXJCLEVBQUUsT0FBTyxHQUFLLE9BQU8sUUFBWixDQUFZO1FBQ2hELElBQUksT0FBTyxFQUFFLEVBQUU7WUFDYixPQUFPO2dCQUNMLE9BQU8sYUFBSSxPQUFPLFNBQUEsSUFBSyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUU7Z0JBQzVDLE9BQU8sU0FBQTthQUNSLENBQUE7U0FDRjtLQUNGO0FBQ0gsQ0FBQztBQWJELGtDQWFDO0FBRUQsU0FBZ0IsaUJBQWlCO0lBQy9CLE9BQU87UUFDTCxPQUFPLGVBQU8sR0FBRyxDQUFDLFVBQVUsRUFBRSxDQUFFO1FBQ2hDLE9BQU8sRUFBRSxPQUFPLENBQUMsR0FBRztLQUNyQixDQUFBO0FBQ0gsQ0FBQztBQUxELDhDQUtDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQ2xvdWRiYXNlQWRhcHRlciwgU0RLQWRhcHRlckludGVyZmFjZSwgTm9kZUFkYXB0ZXJJbnRlcmZhY2UgfSBmcm9tICdAY2xvdWRiYXNlL2FkYXB0ZXItaW50ZXJmYWNlJ1xuaW1wb3J0ICogYXMgV2ViIGZyb20gJy4vcGxhdGZvcm1zL3dlYidcbmltcG9ydCB7IGlzQXJyYXkgfSBmcm9tICcuLi9saWJzL3V0aWwnXG5cbmV4cG9ydCBlbnVtIFJVTlRJTUUge1xuICBXRUIgPSAnd2ViJyxcbiAgV1hfTVAgPSAnd3hfbXAnLCAvLyDlvq7kv6HlsI/nqIvluo9cbn1cblxudHlwZSBJQ2xvdWRiYXNlQWRhcHRlciA9IENsb3VkYmFzZUFkYXB0ZXIgJiB7XG4gIGdlbkFkYXB0ZXI6IChvcHRpb25zPzogYW55KSA9PiBTREtBZGFwdGVySW50ZXJmYWNlIHwgTm9kZUFkYXB0ZXJJbnRlcmZhY2Vcbn07XG5cbmV4cG9ydCBmdW5jdGlvbiB1c2VBZGFwdGVycyhhZGFwdGVyczogSUNsb3VkYmFzZUFkYXB0ZXIgfCBJQ2xvdWRiYXNlQWRhcHRlcltdLCBvcHRpb25zPzogYW55KSB7XG4gIGNvbnN0IGFkYXB0ZXJMaXN0OiBJQ2xvdWRiYXNlQWRhcHRlcltdID0gaXNBcnJheShhZGFwdGVycylcbiAgICA/IChhZGFwdGVycyBhcyBJQ2xvdWRiYXNlQWRhcHRlcltdKVxuICAgIDogW2FkYXB0ZXJzIGFzIElDbG91ZGJhc2VBZGFwdGVyXVxuICBmb3IgKGNvbnN0IGFkYXB0ZXIgb2YgYWRhcHRlckxpc3QpIHtcbiAgICBjb25zdCB7IGlzTWF0Y2gsIGdlbkFkYXB0ZXIsIHJ1bnRpbWUgfSA9IGFkYXB0ZXJcbiAgICBpZiAoaXNNYXRjaCgpKSB7XG4gICAgICByZXR1cm4ge1xuICAgICAgICBhZGFwdGVyOiB7IGlzTWF0Y2gsIC4uLmdlbkFkYXB0ZXIob3B0aW9ucykgfSxcbiAgICAgICAgcnVudGltZSxcbiAgICAgIH1cbiAgICB9XG4gIH1cbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHVzZURlZmF1bHRBZGFwdGVyKCkge1xuICByZXR1cm4ge1xuICAgIGFkYXB0ZXI6IHsgLi4uV2ViLmdlbkFkYXB0ZXIoKSB9LFxuICAgIHJ1bnRpbWU6IFJVTlRJTUUuV0VCLFxuICB9XG59XG4iXX0=
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SDKAdapterInterface, AbstractSDKRequest, IRequestOptions, ResponseObject, IUploadRequestOptions, IRequestConfig, IFetchOptions } from '@cloudbase/adapter-interface';
|
|
2
|
-
declare class WebRequest extends AbstractSDKRequest {
|
|
3
|
-
private readonly timeout;
|
|
4
|
-
private readonly timeoutMsg;
|
|
5
|
-
private readonly restrictedMethods;
|
|
6
|
-
constructor(config: IRequestConfig);
|
|
7
|
-
get(options: IRequestOptions): Promise<ResponseObject>;
|
|
8
|
-
post(options: IRequestOptions): Promise<ResponseObject>;
|
|
9
|
-
put(options: IRequestOptions): Promise<ResponseObject>;
|
|
10
|
-
upload(options: IUploadRequestOptions): Promise<ResponseObject>;
|
|
11
|
-
download(options: IRequestOptions): Promise<any>;
|
|
12
|
-
fetch(options: IFetchOptions & {
|
|
13
|
-
shouldThrowOnError?: boolean;
|
|
14
|
-
}): Promise<ResponseObject>;
|
|
15
|
-
protected request(options: IRequestOptions, enableAbort?: boolean): Promise<ResponseObject>;
|
|
16
|
-
}
|
|
17
|
-
declare function genAdapter(): SDKAdapterInterface & {
|
|
18
|
-
type?: 'default' | '';
|
|
19
|
-
};
|
|
20
|
-
export { genAdapter, WebRequest };
|